http-proxy-middleware icon indicating copy to clipboard operation
http-proxy-middleware copied to clipboard

Https (wss) error Invalid frame header

Open learygilbert opened this issue 6 years ago • 3 comments

Expected behavior

Actual behavior

Setup

  • http-proxy-middleware: _version_0.18.0
  • server: express_version_4.16.0
  • other relevant modules

proxy middleware configuration

var wsProxy = proxyMiddleware('ws://localhost:1337/socket.io', {
  changeOrigin:true, 
  secure: false,
  protocolRewrite: 'http'
});```
#### server mounting
```javascript
var app = express();

app.use(wsProxy );
var server = https.createServer({
  key: privateKey,
  cert: certificate,
  passphrase: 'splus'
}, app).listen(8443);

const WebSocket = require('ws')
const wss = new WebSocket.Server({ server });
server.on('upgrade', wsProxy2.upgrade);

What can I do to make it work!

learygilbert avatar Mar 25 '18 10:03 learygilbert

what is the error that you're getting?

manjeet13 avatar Jul 11 '18 11:07 manjeet13

index.js:1 WebSocket connection to 'ws://xenui.ctest2.0su.kr/api/' failed: Invalid frame header (anonymous) @ index.js:1 index.js:1 Uncaught Error: Unhandled "error" event. ([object Event]) at t.i.emit (index.js:1) at WebSocket. (index.js:1) i.emit @ index.js:1 (anonymous) @ index.js:1 error (async) (anonymous) @ index.js:1 Promise.then (async) (anonymous) @ index.js:1 Promise.then (async) value @ index.js:1 e @ index.js:1 value @ index.js:1 n.connect @ index.js:1 1832.../fetch @ index.js:1 o @ index.js:1 (anonymous) @ index.js:1 1787.../xo @ index.js:1 o @ index.js:1 (anonymous) @ index.js:1 1843../patch-react @ index.js:1 o @ index.js:1 e @ index.js:1 (anonymous) @ index.js:1 index.js:1 Uncaught t {message: "invalid status connecting, expected open", name: "t", stack: "t: invalid status connecting, expected open↵ at…n (http://xenui.ctest2.0su.kr/index.js:1:2061677)"}

U-siro avatar Nov 15 '18 10:11 U-siro

Same issue. Any luck resolving it?

{
        devServer: {

            headers: { "Access-Control-Allow-Origin": "*" },
            hot: true,
            compress: false,
            historyApiFallback: true,
            allowedHosts: "all",
            devMiddleware: {
                publicPath: "/",
                stats: {
                    colors: true,
                }
            },
            static: {
                directory: path.join(__dirname, 'dist'),
                publicPath: "/"
            },
            client: {
                logging: "verbose",
                progress: true
            },

            host: options.host || "0.0.0.0", // makes server available to all hosts, not just localhost
            port: options.port || 8080,
            proxy: {
                "/ws": {
                    target: "ws://localhost:5000",
                    logLevel: "debug", // debug
                    secure: false,
                    ws: true,
                    changeOrigin: true
                }
            },
        }
    }

dcworldwide avatar Aug 12 '22 01:08 dcworldwide