NullReferenceException from Azure SignalR Hub during WebSocket handshake

Viewed 147

I'm trying to use the Azure SignalR service. I've already got SignalR working locally, but when I upgrade it to use the Azure service I see the following:

  1. Client connects to (local, .NET) hub server configured to use Azure SignalR service and is 'redirected' to our hosted SignalR service on Azure.
  2. Client connects with https to SignalR service at https://blabla.service.signalr.net and (after a preflight request) gets a 200 response with a json payload containing list of available transports etc.
  3. Client opens a WebSocket to the wss://blabla.service.signalr.net host. First upstream message is {"protocol":"json","version":1}.
  4. Server responds immediately with the following response: {"error":"An unexpected error occurred during connection handshake. NullReferenceException: Object reference not set to an instance of an object."}

What's puzzling me is that

  • There is no code of ours running in the SignalR service which could be causing this.
  • Our Hub server shows no errors related to calls from the SignalR service.
  • I've successfully run a chat hub on the same SignalR service using the same hub server.

How do I debug this? I can't see any activity logs on the Azure portal, and nothing is showing up locally on the hub server.

1 Answers

I managed to find the source of the problem by adding debugging entries to my app settings.json as follows:

      "Microsoft.AspNetCore.SignalR": "Debug",
      "Microsoft.AspNetCore.Http.Connections": "Debug"

This revealed that the problem was related to a call made from the SignalR service to my local hub server (via a WebSocket connection presumably)

Related