WebSocket 連接到“wss://...”失敗:連接建立錯誤:net::ERR_CONNECTION_CLOSED (WebSocket connection to 'wss://...' failed: Error in connection establishment: net::ERR_CONNECTION_CLOSED)


問題描述

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 JackHammerSteffen UllrichLucas Duarte)

參考文件

  1. WebSocket connection to 'wss://...' failed: Error in connection establishment: net::ERR_CONNECTION_CLOSED (CC BY‑SA 2.5/3.0/4.0)

#SSL #websocket






相關問題

使用自簽名證書在 android 中創建安全的客戶端-服務器連接 (Using a self-signed certificate to create a secure client-server connection in android)

壁壘中是否不可能同時具有傳輸級安全性和消息級安全性?為什麼? (Is it impossible to have both transport level security and message level security in rampart? Why?)

如何等到服務器上線才能訪問 REST API (How to wait till a server goes online to access a REST API)

HTTPS 客戶端/服務器通信錯誤:底層連接已關閉:發送時發生意外錯誤 (HTTPS Client/Server Communication Error: The underlying connection was closed: An unexpected error occurred on a send)

.net 添加了客戶端證書,但仍收到無效證書 (.net added client certificate but still recieve an invalid certificate)

PHP:通過代理加載圖像的最快方式 (PHP : Fastest way to load images through a proxy)

htaccess 強制 https 和 www 到非 www,但子域僅 https (htaccess force https & www to non-www, but subdomain only https)

使用 sha256_password 時如何使用 PHP 的 mysqli 連接到 MySQL(訪問被拒絕) (How do you connect to MySQL using PHP's mysqli when using sha256_password (access denied))

C#:強制 TLS1.2 但 Https 服務器仍然給出常見算法錯誤 (C#: Forcing TLS1.2 but Https server still giving common algorithm error)

“httpd.service 的作業失敗,因為控制進程以錯誤代碼退出。” 我該如何解決? ("Job for httpd.service failed because the control process exited with error code." How do I fix this?)

如何為通過 Kestrel 服務器託管 PWA 的 UWP 桌面橋應用配置 https (How to configure https for a UWP Desktop Bridge app hosting a PWA via a Kestrel Server)

從其他機器訪問 webpack DevServer 子 URL 時出現 ERR_SSL_PROTOCOL_ERROR (ERR_SSL_PROTOCOL_ERROR when accessing webpack DevServer sub-URLs from a different machine)







留言討論