使用 Expo 的錯誤 WebSocket connection to 'ws://localhost:19002/debugger-proxy?role=debugger&name=Chrome' failed: Error during WebSocket handshake: Unexpected response code: 400


Expo 調試

前提是在使用以下環境

名稱 版本 icon
React native debugger V0.10
React devTools latest
Expo ~37.0.3 => 37.0.8

錯誤:


WebSocket connection to 'ws://localhost:19002/debugger-proxy?role=debugger&name=Chrome' failed: Error during WebSocket handshake: Unexpected response code: 400

接照本次的錯誤,是因為React native debugger無法成功訪問ws://localhost:19002。

而很多開發將它定義為 WebSocket 的問題或是代理的問題。

答案連接了錯誤的端口導致。(但是如果並非這個問題,解決方案建議 expo diagnostics 診斷環境並重新安裝來測試錯誤的重現。 )

下面我簡單的描述端口的使用。

首先,運行 yarn start :

  • Metro Bundler on port 19001 —— 綁定React native debugger 的端口

  • Expo DevTools is running at http://localhost:19002 —— 瀏覽器 可視化DevTools

  • exp://127.0.0.1:19000 in iOS simulator —— 虛擬器使用的端口

有些問題可能很小,但它就是欺負末懂者,它會糾纏很久。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM