Ofek Ben Atar
Ofek Ben Atar

Reputation: 41

Can't invoke server's method from client - Error: An unexpected error occurred invoking 'SignIn' on the server

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?

enter image description here

Upvotes: 2

Views: 2150

Answers (3)

Reza Taba
Reza Taba

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.

SOLUTION on localhost

  1. Using debugger go through your code line by line and check where can be the possible culprit. Check all possible manually set exceptions or bad returns.
  2. Modify the code by simplifying the objects or methods and try again.
  3. Do step 2 again and again with patience until the culprit line is found.

SOLUTION on Azure (or any cloud)

If the cloud provided logger doesn't help (Azure logger didn't provide much info),

  1. Inject 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.
  2. Deploy and try again until you find the logical bug.

VERY IMPORTANT NOTE:

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

Ofek Ben Atar
Ofek Ben Atar

Reputation: 41

So the problem was that my Database was empty... the migration did not upload, Update the database solved it.

Upvotes: 1

kavya Saraboju
kavya Saraboju

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")

Reference:

Upvotes: 0

Related Questions