SignalR Connection failure on azure ubuntu vm

Rasmus Østergaard 1 Reputation point
2022-03-07T12:20:38.753+00:00

Anyone have any experience with azure linux VM running nginx? I have that setup and websockets are failing to connect:

WebSocket connection to 'wss://app.imendo.dk/hub?id=OD98sU782B4dSnrE51qkjA&access_token=...' failed: 

Error: Failed to start the transport 'WebSockets': Error: WebSocket failed to connect. The connection could not be found on the server, either the endpoint may not be a SignalR endpoint, the connection ID is not present on the server, or there is a proxy blocking WebSockets. If you have multiple servers check that sticky sessions are enabled.

Error: Server returned handshake error: Handshake was canceled.

Error: Connection disconnected with error 'Error: Server returned handshake error: Handshake was canceled.'.

Kinda scratching my head here.. is it some port i have to open or whats blocking it.. in my nginx settings i have forwarded the /hub to my .net 6 instance running on port 5100.

location /hub {
            proxy_pass         http://127.0.0.1:5100/hub;
            proxy_http_version 1.1;
            proxy_set_header   Upgrade $http_upgrade;
            proxy_set_header   Connection keep-alive;
            proxy_set_header   Host $host;
            proxy_cache_bypass $http_upgrade;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header   X-Forwarded-Proto $scheme;
        }

This same setup have worked on a server i got on a barebone server hosting platform (e.g. dedicated server) - so gotta be something in azure im missing :/

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 30,326 Reputation points Microsoft Employee Moderator
    2022-03-08T23:24:16.92+00:00

    Taking a look at the Linux with Nginx settings; and assuming you're that as the proxy, perhaps the proxy_pass is incorrectly configured. Maybe you don't need that extra /hub on the end.

       location /hubroute {  
             # App server url  
             proxy_pass http://localhost:5000;  
    

    I did retag your question so that a better audience can see your question and may have a better idea.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.