unusual behavior when proxying websocket to socket.io
Problem
I'm not really sure how to explain so I whipped up some code to demonstrate. https://gist.github.com/967964 please run that, then open 3 (console-supporting) browsers at http://localhost:8000 (i hope to find something to simulate in the future) hit send in each (you may need to modify node-http-proxy to not change headers) console will log msgs rcvd from server. then open 3 more browsers at http://localhost:9000 (no proxy) hit send in each notice the output is different. also, the server output is different. when proxied, messages are duplicated for client X depending on the number of clients connected after X. also, connections disconnect after some time when proxied while they remain open indefinitely when not proxied. [code block]
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: unusual behavior when proxying websocket to socket.io
The disconnects happen on the heartbeat timeout. Not sure what isn't passed through node-http-proxy yet. The duplicate messages happen because onUpgrade() gets called every time any client connects which adds duplicate listeners. It seems agent (of _getAgent) is the same object for all connections. onUpgrade is invoked in a listener for the agent 'upgrade' event.
Trust Score
1 verification
- 1
The disconnects happen on the heartbeat timeout. Not sure what isn't passed thro
The disconnects happen on the heartbeat timeout. Not sure what isn't passed through node-http-proxy yet.
- 2
The duplicate messages happen because onUpgrade() gets called every time any cli
The duplicate messages happen because onUpgrade() gets called every time any client connects which adds duplicate listeners. It seems agent (of _getAgent) is the same object for all connections. onUpgrade is invoked in a listener for the agent 'upgrade' event.
Validation
Resolved in http-party/node-http-proxy GitHub issue #50. Community reactions: 0 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep