我没有在此网页上使用 Web Sockets,但是 -
我试图理解为什么 Chrome 控制台会打印以下“错误”(我使用引号,因为它不会产生任何影响)。仅当我在 HTTPS 站点上托管时才会出现该错误,而不是 HTTP(正在使用与我的计算机本地相同的 IIS 服务器)。
(并且有有效的 TLS/SSL 证书)m,我不知道为什么端口 61396 正在被查看..
hmr-runtime.js:29 WebSocket connection to 'wss://ysg4206.draper.com:61396/' failed: Error in connection establishment: net::ERR_SSL_PROTOCOL_ERROR
parcelRequire.../../../node_modules/parcel-bundler/src/builtins/hmr-runtime.js @ hmr-runtime.js:29
最佳答案
来自https://parceljs.org/hmr.html
Hot Module Replacement (HMR) improves the development experience by automatically updating modules in the browser at runtime without needing a whole page refresh. This means that application state can be retained as you change small things. Parcel's HMR implementation supports both JavaScript and CSS assets.
为此,它使用WebSockets。
你可以做三件事:
要使其消失,只需禁用 hmr:
parcel entry.js --no-hmr
要使用 HMR,您可以将解决方案作为非 https 网站运行,或者...
您可以生成自签名证书并将其与 IIS 和 Parcel 一起使用:
包裹入口.js --cert 证书.cert --key private.key
关于google-chrome - 本地托管的 HTTPS 站点在 Chrome 中出现有关 websocket 的错误(使用 ParcelJS bundle 时),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57275685/