I Can use signalR on local server , but I can't use it on real server , I receive proxy error

Viewed 89

I Can use signalR on local server , but I can't use it on real server , I receive proxy error .
Tools are :(nginx version 1.20 - ubuntu - .Netcore)

Error Message on console :

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. at WebSocket.webSocket.onclose (WebSocketTransport.ts:129) Conf file :

  • location /signalR { proxy_pass http://127.0.0.1:81;

    proxy_http_version 1.1;

    proxy_set_header Upgrade $http_upgrade;

    proxy_set_header Connection $http_connection;

    proxy_set_header Host $host;

    proxy_cache_bypass $http_upgrade;

    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    }

    location /api/v1/ { proxy_pass http://127.0.0.1:81; }

    location /swagger { proxy_pass http://127.0.0.1:81; }

1 Answers

The error we receive says either there is no such a endpoint or a proxy that disable access to server. We tried to use signalR websocket after a lot of research we found the problem. The problem is our nginx version is 1.2 but websocket feature comes with version 1.3+ .Now alternative awesome solution to this is , using LongPolling instead of WebSockets. Hope this can help whoever facing with this issue.

Related