websocket - 信号器在 WebSocket 握手期间不使用 https 错误:意外的响应代码:200
问题描述
我有后端,我将信号器用于 websocket。当客户端和后端在 http 上时,一切正常。
然后我切换到https。现在我在浏览器中看到这个错误:
WebSocket connection to 'wss://example.com/chatHub?id=mKk-uj0P0_7WsLFXjXhskA' failed: Error during WebSocket handshake: Unexpected response code: 200
POST https://example.com/chatHub?id=HSwLlWtJGpBP0Dib6sHobQ 404 (Not Found)
奇怪的是,即使我看到这个错误,Edge 聊天也能正常工作(在 chrome 和 firefox 上没有)。
这里发生了什么,我该如何解决?客户端是 angular 6 (@aspnet/signalr 用于集线器连接) 后端是 dotnet
编辑:我忘了提,我有后端和客户端使用 nginx 代理。
解决方案
原来是nginx的问题。
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
在服务器 nginx.conf 上修复了问题
推荐阅读
- javascript - 在 React Native 中使用 React-Native-Router-Flux 将标签栏添加到具有自己的导航堆栈的子场景
- java - 致命例外:使用 Firebase 的令牌刷新器
- c# - C# Winform - 当我将面板背景颜色放在其他人的右下角时,我的面板背景颜色一直消失
- android - 如何清理 AOSP 中的模块?
- .net - Dapper 和 SQL 注入
- java - Java 优先级 - 强制转换和位运算符
- excel - IF else 语句在 vba 代码中无法正常工作
- c# - ASPXRichedit 无法将 byte[] 隐式转换为 System.IO.Stream
- mysql - 如何在windows中使用cmd启动和停止mysql服务器
- xcode - Xcode 9:无法使用钛中的新(默认)构建系统构建应用程序