Asp.Net Core 2 SignalR Ubuntu Xamarin Android

大兔子大兔子 提交于 2019-12-11 17:28:55

问题


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:


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;
    }
}


来源:https://stackoverflow.com/questions/46663475/asp-net-core-2-signalr-ubuntu-xamarin-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!