TakahikoKawasaki / nv-websocket-client

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

can't connect #166

Closed five-lei closed 5 years ago

five-lei commented 6 years ago

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 403 Forbidden

matthewkalantar commented 5 years ago

i meet this problem too just adding: ws.addHeader("Origin","app:myapp"); solve my problem

TakahikoKawasaki commented 5 years ago

@five-lei There are many possible reasons that can cause 403 Forbidden. As @mehran22k showed an example, that kind of issues can be solved by adding some HTTP headers in most cases. Otherwise, the configuration of the server is wrong. If "101 Switching Protocols" is not returned, it means that the server does not accept a WebSocket connection for some reasons.