gusavila92 / java-android-websocket-client

Java/Android WebSocket Client
Apache License 2.0
148 stars 38 forks source link

Instant disconnect when using a websocket proxy (node-http-proxy) #28

Closed vanesca88 closed 1 year ago

vanesca88 commented 1 year ago

If you use the popular node-http-proxy (https://github.com/http-party/node-http-proxy) to proxy a websocket connection, then all the headers that it gives back to connected clients are in lower-case. I noticed that this library explicitly expects and checks for: 'Upgrade', 'Connection' and 'Sec-WebSocket-Accept'. While a webserver might also send those out in lowercase: 'upgrade', 'connection' and 'sec-websocket-accept'. Possibility that other proxy server might do the same thing, and only send out lowercase headers.

I downloaded your library and added the fix to check for both variants. See below. Wanted to contribute back, even though I don't have time to do a pull request right now. Hope it can be merged / help others out as well.

Other than that, great library that's very easy to use and better than most libraries out there! ^_^ Thumbs up :)

See the attachment for the (edited) lines only. part.txt

Starts at line 915: https://github.com/gusavila92/java-android-websocket-client/blob/master/src/main/java/dev/gustavoavila/websocketclient/WebSocketClient.java#L915

gusavila92 commented 1 year ago

Thanks for the feedback. I will test it out very soon and then publish a new version

gusavila92 commented 1 year ago

Version 2.0.2 is out with this fix!