Reputation: 41
I'm build a project using SignalR. As Front I'm using .Net Core, as Back I'm using React. So in my localhost the project is working, but when i deploy this project i get an error. In azure I have created: 2 web application - one used for cliend, and the other one for server. 1 Azure SignalR service (i tested it online and it worked) 1 Azure SQL Database
So when i try to invoke Method it now working and show me this error. Someone know how to solve this problem?
Upvotes: 2
Views: 2150
Reputation: 1904
If you have logical issues in your code you can get this error. For instance my case was unrelated to SignalR and still getting this error. I was throwing exception if my photoUrl
was null
and it caused the error you mentioned.
If the cloud provided logger doesn't help (Azure logger didn't provide much info),
ILogger
in YourHub
and for each line that a value or object is created store it in your DB along with the line number so you know which line does what and find the exact line which the code fails.If you have an ordinary .NET Core ExceptionMiddleware
implemented, be aware that none of your HubException
goes through that. SignalR
handles its exceptions itself and they do NOT go through normal .NET Exception pipeline. (This one wasted days of me expecting to see any exception logs using my ExceptionMiddleware
and there was none.). You have to either use try
catch
in YourHub
or implement an exception filter to handle all your hubs' exceptions in one place (if code is needed create a new post, notify me and I'll provide the solution there).
I hope this info helps. Good luck.
Upvotes: 0
Reputation: 41
So the problem was that my Database was empty... the migration did not upload, Update the database solved it.
Upvotes: 1
Reputation: 10839
So If it is the cause try to change the URL on the client side from
"http" to "https". like >.withUrl("https://xxx/HubName")
Also please go through c# - Could not connect to Azure SignalR Hub - Stack Overflow And check if the signalR url endpoint for client is correctly given
var signalrUrl = "https://myazuresignalr.service.signalr.net/client/?hub=yourHubName"
Please note that sending the exception this way to the client is
insecure .So try to either throw a HubException
or set
EnableDetailedErrors on the server.See HandleErrors when :Use
hubs in ASP.NET Core SignalR | Microsoft Docs
Reference:
Upvotes: 0