Replies: 2 comments 4 replies
-
I had the same problem and found that this issue is actually documented in the README, it just didn't occur to me that it applied to my situation. https://github.com/chimurai/http-proxy-middleware#external-websocket-upgrade The To make matters worse (in my case), all of my sub apps are defined in separate files as separate express apps, which means they don't have access to server.js const server = app.listen(process.env.HTTP_PORT || 80, () => {
app.emit("LISTENING", server)
}) sub_app.js const app = express()
const proxy = createProxyMiddleware(options);
app.use('/subapp/', proxy)
app.on("mount", parent => {
parent.on("LISTENING", server => {
server.on("upgrade", proxy.upgrade)
})
}) |
Beta Was this translation helpful? Give feedback.
-
I was able to get access to the server and listen to the upgrade event but I agree that the docs aren't clear as to when to use the code from the |
Beta Was this translation helpful? Give feedback.
-
The initial websocket http request to the proxy never gets upgraded and is left hanging. However, any subsequent requests are upgraded properly. Why does listening to the
upgrade
event and handling it on the proxy side fix this issue? Is there a way to fix this issue without listening to that event because in my actual scenario, I don't have access to the server.Steps to reproduce
Described in the demo section below.
Expected behavior
The initial request should get upgraded. However, if the initial one is failing, all subsequent ones should also fail.
Actual behavior
The initial request does not get upgraded but any subsequent ones get upgraded.
Setup
createProxyMiddleware({ target: 'http://localhost:8844', logLevel: 'debug', ws: true })
client info
Issue occurring on Windows 10, Ubuntu 16.04 and RHEL 7
target server info
Basic http server with websocket support
Reproducible Demo
https://github.com/Hamza141/websocket-proxy-test
node server.js
node proxy.js
node client.js
. Proxy will not upgrade request.Beta Was this translation helpful? Give feedback.
All reactions