chimurai / http-proxy-middleware

:zap: The one-liner node.js http-proxy middleware for connect, express, next.js and more
MIT License
10.7k stars 834 forks source link

Proxying Websockets Error "Invalid WebSocket frame: RSV1 must be clear" #799

Closed jira-zz closed 2 years ago

jira-zz commented 2 years ago

Checks

Describe the bug (be clear and concise)

In console infinite line of

[HPM] Upgrading to WebSocket
[HPM] Client disconnected

is displayed.

Connecting to the ws url I'm getting Error: Invalid WebSocket frame: RSV1 must be clear

Step-by-step reproduction instructions

1)Create simple Websocket server - https://gist.github.com/jira-zz/ebefc82d0f683a11695bcfa5415ff5ba
2) Create stock create-react-app
3) Add setupProxy.js to src - https://gist.github.com/jira-zz/ebefc82d0f683a11695bcfa5415ff5ba
4) start sever created in 1)
5) start react app using npm start

Expected behavior (be clear and concise)

It should proxy Websockets

How is http-proxy-middleware used in your project?

├── http-proxy-middleware@2.0.6
└─┬ react-scripts@5.0.1
  └─┬ webpack-dev-server@4.9.3
    └── http-proxy-middleware@2.0.6 deduped

What http-proxy-middleware configuration are you using?

const { createProxyMiddleware } = require('http-proxy-middleware');

module.exports = function (app) {
    const appProxy = createProxyMiddleware('/ws', {
        target: 'http://localhost:5000',
        ws: true
    });

    app.use(appProxy);
};

What OS/version and node/version are you seeing the problem?

Ubuntu 22.04 LTS in WSL2
node v18.5.0

Additional context (optional)

No response

chimurai commented 2 years ago

dupe of #209

To keep the issue/discussion central.