.Net Signalr 建立连接时提示WebSocket failed to connect

一、问题来源

  在初次使用signalr时,遇到了以下问题,提示WebSocket连接失败。

 

 

 二、解决方法 

  1.检查iis是否安装了websocket服务

  打开服务器管理器,点击添加角色和功能,在服务器角色这一步中找到Web服务器(IIS)——Web服务器——应用程序开发——WebSocket协议,如果没有安装,则勾选后进行安装,安装完后重启IIS

  

 

 

   

  2.如果使用到nginx进行代理,检查对应代理端口的配置:proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "upgrade";完成后重启nginx

location / {
   proxy_pass http://127.0.0.1:8080;
   proxy_http_version 1.1;
   proxy_set_header Upgrade $http_upgrade;
   proxy_set_header Connection "upgrade";
}

  

posted @ 2023-02-06 02:00  Zeng。  阅读(718)  评论(0编辑  收藏  举报