从 http 切换 https 后 Websocket 不工作

Websocket not working after switching https from http

我最近将我的应用程序切换到 https,除了 websockets 之外一切正常。如果我尝试使用地址 ws://ws.myserver.com:8080/ 连接到我的服务器,我现在收到以下错误:

SecurityError:操作不安全。

如果我正在使用 wss://ws.myserver.com:8080/,我会遇到以下错误

Firefox 无法与位于 wss://ws.myserver.com:8080/

的服务器建立连接

我正在使用 Apache 服务器,我的 Ratchet Websocket 服务器在其中 运行。

根据评论,该站点在安全站点 (https://) 中使用了不安全的 ws://。这种混合内容被多个浏览器阻止,例如 Firefox 和 Chrome,这导致 "SecurityError: The operation is insecure." 消息。

如果您的服务器同时提供安全和不安全的内容,您将不得不从不同的端口提供这些内容。

例如:

如果您在端口 8080 上提供非安全内容,则必须通过 443(wss/https 的默认设置)或任何其他端口(例如 8443 等)提供安全内容。