Error during WebSocket handshake: Unexpected response code: 400
解决方案
问题出现在nginx的配置文件,需要修改nginx.conf文件。在linux终端中敲入vim /etc/nginx/nginx.conf,找到location
这个位置,配置文件如下所示:
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
第一行是告诉nginx使用HTTP/1.1通信协议,这是websoket必须要使用的协议。
第二行和第三行告诉nginx,当它想要使用WebSocket时,响应http升级请求。
最终如下图:
本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。
评论已关闭