問題描述
WebSocket 連接到“wss://...”失敗:連接建立錯誤:net::ERR_CONNECTION_CLOSED (WebSocket connection to 'wss://...' failed: Error in connection establishment: net::ERR_CONNECTION_CLOSED)
我有一個非常奇怪的錯誤:
我試圖測試在 websockets 上進行的實時聊天,但是當腳本加載時,我在開發人員工具窗口中收到此消息:“WebSocket connection to 'wss: //chat.mywebsite.com:80/testuser@wr94@34@0: 連接建立錯誤:net::ERR_CONNECTION_CLOSED"
開發者工具中的錯誤信息將我發送到這行代碼:wrc_socket = new WebSocket(_wsServerUrl+'/'+login+'@wr94@'+_id+'@'+_userType);
我試圖與聊天開發者一起解決這個問題,我們發現這個問題僅在我正在工作的計算機上發生。
相同的瀏覽器、相同的網絡、相同的操作系統 ‑ 我有問題,其他人都沒有。顯然,我的計算機上安裝了阻止 wss 連接的東西。但我無法弄清楚究竟是什麼。嘗試禁用殺毒軟件和windows防火牆,沒有結果。
我已經用chrome、firefox和opera(所有letest版本)進行了測試。當安裝在我的電腦上時 ‑ 他們重現了這個錯誤,當安裝在同事的電腦上時(他就坐在我旁邊,在同一個辦公室)錯誤沒有發生。
另外,我在我的家用電腦上試過這個並且得到了更奇怪的結果:Opera 和 Firefox 重現了這個問題,而 Chrome 工作正常。
你能給我一個提示或方向來調查這個嗎?我認為這與證書有關,但不知道從哪裡開始。
嘗試禁用殺毒軟件和windows防火牆,沒有結果。我已經用chrome、firefox和opera(所有letest版本)進行了測試。當安裝在我的電腦上時 ‑ 他們重現了這個錯誤,當安裝在同事的電腦上時(他就坐在我旁邊,在同一個辦公室)錯誤沒有發生。
另外,我已經在我的家用電腦上試過這個並且得到了更奇怪的結果:Opera 和 Firefox 重現了這個問題,而 Chrome 工作正常。
你能給我一個提示或方向來調查這個嗎?我認為這與證書有關,但不知道從哪裡開始。
嘗試禁用殺毒軟件和windows防火牆,沒有結果。我已經用chrome、firefox和opera(所有letest版本)進行了測試。當安裝在我的電腦上時 ‑ 他們重現了這個錯誤,當安裝在同事的電腦上時(他就坐在我旁邊,在同一個辦公室)錯誤沒有發生。
另外,我在我的家用電腦上試過這個並且得到了更奇怪的結果:Opera 和 Firefox 重現了這個問題,而 Chrome 工作正常。
你能給我一個提示或方向來調查這個嗎?我認為這與證書有關,但不知道從哪裡開始。
s 電腦(他就坐在我旁邊,在同一個辦公室)錯誤沒有發生。另外,我在家裡的電腦上試過這個,得到了更奇怪的結果:Opera 和 Firefox 重現了這個問題, Chrome 工作正常。
你能給我一個提示或方向來調查這個嗎?我認為這與證書有關,但不知道從哪裡開始。
s 電腦(他就坐在我旁邊,在同一個辦公室)錯誤沒有發生。另外,我在家裡的電腦上試過這個,得到了更奇怪的結果:Opera 和 Firefox 重現了這個問題, Chrome 工作正常。
你能給我一個提示或方向來調查這個嗎?我認為這與證書有關,但不知道從哪裡開始。
參考解法
方法 1:
wss://chat.mywebsite.com:80/
I'm pretty sure that you don't have wss://
configured on port 80. Port 80 is used by default for plain HTTP, i.e. http://
and ws://
and not https://
and wss://
. If the latter is available at all depends on your server configuration but simply trying wss://
on a port configured only for ws://
will not work.
If this works for other maybe they do it differently, that is they either use ws://chat.example.com
or wss://chat.example.com
but not wss://chat.example.com:80
.
方法 2:
I don't know about Opera, but Firefox has its own certificate store and won't trust a certificate because the OS trusts.
(by JackHammer、Steffen Ullrich、Lucas Duarte)