问题
So I think I am getting crazy.
I use javaScript to make a WebSocket connection on port 443.
The problem is that the WebSocket declaration is throwing a SyntaxError only on edge and internet explorer browsers, on other browsers like Chrome and Firefox it works perfectly.
The code that I use:
var Connection;
Connection = new WebSocket("ws:/127.0.0.1:443");
Does someone knows what am I doing wrong?
回答1:
change it to:
var connection = new WebSocket("ws://127.0.0.1:443");
回答2:
This issue comes from the webpackHotDevClient.js file (line 60)
./node_modules/react-dev-utils/webpackHotDevClient.js:60
Add slashes: true, to the format object to solve it, your update should look like the following snippet:
// Connect to WebpackDevServer via a socket.
var connection = new WebSocket(
url.format({
protocol: window.location.protocol === 'https:' ? 'wss' : 'ws',
hostname: window.location.hostname,
port: window.location.port,
// Hardcoded in WebpackDevServer
pathname: '/sockjs-node',
slashes: true,
})
);
来源:https://stackoverflow.com/questions/36667587/syntax-error-on-new-websocket-in-edge-internet-explorer