Get 404 during websocket handshake with Azure SignalR Service

ZHANG Hao.h 25 Reputation points
2023-05-11T10:51:49.6433333+00:00

I am using APIM as a reverse proxy in front of Azure SignalR service.

Everything looks good. The negotiate is successful and when it goes to the wss: API to build the connection it failed sometimes due to the handshake API return a 404 on signalR side. I can see that request on the SignalR live trace tool, it means the APIM does forward the handshake to signalR service, however sometimes it returns 404 instead of 101. Sometimes it works sometimes it doesn't. Any ideal why? The access_token is the same since I am using the same user to test it.
User's image

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
1,805 questions
Azure SignalR Service
Azure SignalR Service
An Azure service that is used for adding real-time communications to web applications.
122 questions
{count} votes

1 answer

Sort by: Most helpful
  1. ajkuma 22,851 Reputation points Microsoft Employee
    2023-05-12T21:41:48.4166667+00:00

    Apologies you are experiencing this issue. Kindly share more details about your app framework.

    1. You may leverage Azure SignalR Services diagnostics from Azure Portal> Navigate to your ASignalR app in the Azure Portal. (screenshot below)
    2. In the left navigation, click on Diagnose and solve problems - Review - “Resources Usage" and “Availability and Performance”  options.

    Typically, on ASP.net core, when using WebSockets and skipNegotiation = true

    Please check these to isolate the issue:

    • When using multiple servers without sticky sessions, the connection can start on one server and then switch to another server. The other server is not aware of the previous connection.
    • Verify the client is connecting to the correct endpoint. For example, the server is hosted at http://127.0.0.1:5000/hub/myHub and client is trying to connect to http://127.0.0.1:5000/myHub.
    • If the connection uses the ID and takes too long to send a request to the server after the negotiate, the server:
      - Deletes the ID.
      
      - Returns a 404.
      

    If the issue still persist, please check the logs to fetch more info

    Logging and diagnostics in ASP.NET Core SignalR -- This article provides guidance for gathering diagnostics from your ASP.NET Core SignalR app to help troubleshoot issues.

    Kindly let us know, I'll follow-up with you further.