Websocket connection failed, Invalid frame header
Version
3.0.0-rc.3
Reproduction link
Steps to reproduce
npm run serve
What is expected?
no error
What is actually happening?
when i run dev serve, brower console print socket error.

You seem to be messing with the proxy with this proxyfile? But you don't share it.
We can't investigate you report without a proper, run able reproduction (as a guy repository)
Please provide one or we have to close this issue.

proxyFile content.
That's not a run able reproduction. I won't type the code from your screenshot to run it.
I am running into this issue too. Basically, when the / path exist, HMR websocket requests are not ignored and will be somehow proxied. This can be disabled by adding ws: false to the options, however, this will disable all websocket requests.
I am running into this issue too
+1
proxytable key 'ws' set false, this will disable all websocket requests.
In my case, I use the following configuration to proxy websocket for my site:
proxys: {
'/websocket': {
target: my_ws_server,
ws: true,
changeOrigin: true
}
}
It will cause the same problem like the issue said.
All what I do to resolve is to add a '^' :
proxys: {
'^/websocket': {
target: my_ws_server,
ws: true,
changeOrigin: true
}
}
@ChrisShen93 Cool, in which package does the ^ actually took effect?
@rayax86
Sorry for late reply.
That's for the http-proxy-middleware.
ws改为false
Why set it to ws: false, it works?
running vue-cli itself will run a websocket service on /ws route, e.g. ws://127.0.0.1:8080/ws to do live reload and other vue-cli internal services.
if you use same route for your app and try to proxy it, there will be a conflict. you can simply try to use another route to avoid this conflict. I couldn't fix it with ^/ws or ws: true/false, but rename the route to something else simply solved the issue.
'/websock': {
target: 'http://127.0.0.1:8000',
changeOrigin: true,
ws: true,
},
The reason is that the path of webSocketServer conflicts with the path of proxy in the project. It can be solved by modifying the path of webSocketServer.
devServer: {
webSocketServer: {
options: {
path: "/yourCustomPath"
}
}
}
In my case , I am using http-proxy-middleware, I updated the proxy configuration from:
app.use(
'/hubs',
createProxyMiddleware({
target: 'your target url',
changeOrigin: true,
ws: true
})
);
to
app.use(
createProxyMiddleware('/hubs', {
target: 'your target url',
changeOrigin: true,
ws: true
})
);
Then the issue is fixed.
based on @liangguangming solution but for the people that are still using webpack 4.x :-)
devServer: {
sockPath: '/webpack-dev',
}
https://v4.webpack.js.org/configuration/dev-server/#devserversockpath