0
votes

We are using Service Fabric for hosting our messaging service ASP.NET Core web API (leveraging signalr) and React web application as a client. Everything works exactly as expected on local machines but not on Azure. We have configured CORS policies for cross-origin handling since the service and the web app are hosted on different servers. Configured sticky sessions in load balancer. This CORS Policy works in local machine with the service and client hosted on different ports.

Post hosting the application on Azure, I get an Error in the browser console as

Error during WebSocket handshake: Unexpected response code: 500

1
The fact you are getting an HTTP 500 means there is an likely an unhandled exception happening in your code at the server level. Check the logs if you have any or just run the app in debug and try to see what is going on - Micah_MSFT

1 Answers

0
votes

The issue is very likely to be happening because of CORS.

Looking the screenshot you provided, it is possible to see the CORS exception and, as you are aware, the front-end application calling the SignalR service are hosted on different locations(The domain is the same but different ports).

The CORS settings you applied probably didn't work.

You have two solutions:

  • Configure CORS in the ASP.NET CORE, so SignalR can accept the call from other domains.
  • Host both on same domain + port to avoid CORS