Asp.Net Core 2 SignalR Ubuntu Xamarin Android

2019-08-18 22:13发布

I have deployed Asp.Net Core 2 website on ubuntu with Nginx as a reverse proxy. The website works but SignalR doesn't. Same build work locally in IIS-Express. Getting following error in logs, Terminating Long Polling connection by sending 204 response.

Following nginx configuration I am using,

server {
    listen 80;
    location / {
        proxy_pass http://localhost:5000;
        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;
    }
}

I am accessing the server from Xamarin Android. What can be the issue? Any help would be great. Thanks in advance.

1条回答
smile是对你的礼貌
2楼-- · 2019-08-18 22:27

You should change you config to add additional path which needs the Upgrade header

server {
    listen 80;
    location / {
        proxy_pass http://localhost:5000;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }

    location /socket/path/ {
        proxy_pass http://localhost:5000;
        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;
    }
}
查看更多
登录 后发表回答