TakahikoKawasaki / nv-websocket-client

High-quality WebSocket client implementation in Java.
Apache License 2.0
2.03k stars 292 forks source link

Bad request error #119

Open Itach1Uchixa opened 7 years ago

Itach1Uchixa commented 7 years ago

Hi there! I wanted to use this library for my new project and started testing simple echo client implementation that I got from gist. But it give 400 error when I try to connect to server ws://echo.websocket.org. I tested other servers they give 400 too. Logs:

W/System.err: com.neovisionaries.ws.client.OpeningHandshakeException: The status code of the opening handshake response is not '101 Switching Protocols'. The status line is: HTTP/1.1 400 WebSocket Upgrade Failure
07-07 15:04:05.567 2588-2588/? W/System.err:     at com.neovisionaries.ws.client.HandshakeReader.validateStatusLine(HandshakeReader.java:232)
07-07 15:04:05.567 2588-2588/? W/System.err:     at com.neovisionaries.ws.client.HandshakeReader.readHandshake(HandshakeReader.java:54)
07-07 15:04:05.567 2588-2588/? W/System.err:     at com.neovisionaries.ws.client.WebSocket.readHandshake(WebSocket.java:3244)
07-07 15:04:05.567 2588-2588/? W/System.err:     at com.neovisionaries.ws.client.WebSocket.shakeHands(WebSocket.java:3123)
07-07 15:04:05.567 2588-2588/? W/System.err:     at com.neovisionaries.ws.client.WebSocket.connect(WebSocket.java:2155)

P.S: Sorry for my hurry and previous version of this issue thou

TakahikoKawasaki commented 7 years ago

This issue is closed due to its mannerlessness.

TakahikoKawasaki commented 7 years ago

From my environment, ws://echo.websocket.org responds as expected.

If not only echo.websocket.org but also other WebSocket servers return 400, one of possible reasons is that one or more proxy servers between your WebSocket client application and the WebSocket servers cannot handle WebSocket-related HTTP headers properly. That is, it may be a network issue.

Itach1Uchixa commented 7 years ago

I also tested ws servers with Simple WebSocket Firefox plugin they all working as expected

TakahikoKawasaki commented 7 years ago

Web browsers are special software which can detect proxy settings automatically (of course depending on the configuration). Therefore, tests using a browser plugin are sometimes meaningless.

Why don't you try other WebSocket client libraries or tools such as wscat?

Itach1Uchixa commented 7 years ago

I directly connected to internet there aren't any proxies

TakahikoKawasaki commented 7 years ago

Try wss (not ws). This is worth trying.

Itach1Uchixa commented 7 years ago

I tried already including (http and https)

Itach1Uchixa commented 7 years ago

I tested other libraries like TooTallNate/Java-WebSocket and koush/AndroidAsync they working as expected