Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Websocket Errors #12212


User avatar
0
mmorales created

Need assistance fixing a websocket error I keep getting. I am running nginx as a proxy.


1 Answer(s)
  • User Avatar
    0
    oguzhanagir created
    Support Team

    Hi

    • Nginx cannot proxy WebSocket connections by default. For this, you need to configure your Nginx to act as a WebSocket proxy.
    server {
        location /signalr {
            proxy_pass https://localhost:44302;  # or https://localhost:443021;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
        }
    }
    

    Related document

    Related document


    • If you are using a load balancer in the background, you may need to enable sticky sessions in a stateful application such as SignalR. The load balancer must redirect to the same server throughout the session.

    • The error message warns that ServerSentEvents and LongPolling are disabled. If WebSockets is not supported, SignalR automatically switches to other transport methods. You can enable these if you want.
    const connection = new signalR.HubConnectionBuilder()
        .withUrl("/your-hub-endpoint", {
            transport: signalR.HttpTransportType.WebSockets | signalR.HttpTransportType.ServerSentEvents | signalR.HttpTransportType.LongPolling
        })
        .build();
    

    These steps may help you resolve your error. If these do not solve your problem, you can give us details.