【问题标题】:Asp.Net Core 2 SignalR Ubuntu Xamarin AndroidAsp.Net Core 2 SignalR Ubuntu Xamarin Android
【发布时间】:2018-07-23 20:26:40
【问题描述】:

我已经在 ubuntu 上部署了 Asp.Net Core 2 网站,并使用 Nginx 作为反向代理。该网站有效,但 SignalR 无效。相同的构建在 IIS-Express 本地工作。在日志中出现以下错误, 通过发送 204 响应终止长轮询连接。

按照我正在使用的 nginx 配置,

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

我正在从 Xamarin Android 访问服务器。 可能是什么问题?任何帮助都会很棒。提前致谢。

【问题讨论】:

  • 试试proxy_set_header Connection "Upgrade";
  • 谢谢。如果我这样做,我的 POST-API 将不起作用。不过我会再试一次。
  • 您可能需要在特定的 URL 位置而不是整个 /
  • 好的。是的。会试试谢谢。
  • 通过为特定位置添加“升级”来工作。谢谢。

标签: nginx asp.net-core signalr asp.net-core-2.0


【解决方案1】:

您应该更改配置以添加需要升级标头的其他路径

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-09-20
    • 2019-06-15
    • 2018-12-07
    • 1970-01-01
    • 2019-11-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多