Comments (11)
RFC 6455 says "Any status code other than 101 indicates that the WebSocket handshake has not completed". In other words, other HTTP status codes than 101 indicate that the server rejected to talk WebSocket protocol.
Supporting other HTTP status codes than 101 is not a task for a WebSocket client library but a task for a generic HTTP client library. nv-websocket-client is not aiming at becoming a generic HTTP client library.
What behaviors do you expect when an HTTP status code other than 101 is returned from a WebSocket server?
from nv-websocket-client.
I'm sorry I cannot understand your question. What do you mean by "implement '101 Switching Protocols'" ?
from nv-websocket-client.
Hi sorry my question was not clear.
when trying to connect to my server I have this error "The status code of the opening handshake response is not '101 Switching Protocols".
On your home page it is said : "HTTP response codes other than "101 Switching Protocols" from a WebSocket endpoint are not supported",
will you support other response code in the future ? My previous library could connect properly so I guess that this 'error' depends on the way you handle connection.
from nv-websocket-client.
though curently I have just tried my app thats using the library and its not connecting to my webserver "The status code of the opening handshake response is not '101 Switching Protocols'" I dont know if the issue is from client or server
from nv-websocket-client.
In most cases, a client application is to blame for other HTTP status codes than 101. For example, 404 (Not Found) is returned when a client application specified a wrong URL. A server is to blame only when a 5xx status code is returned.
For other status codes than 101, "the semantics of HTTP still apply" (RFC 6455, 1.3. Opening Handshake). If you receive a status code other than 101, it's not a WebSocket problem but a normal HTTP problem.
from nv-websocket-client.
Thanks for your reply !
Problem is : my previous socket library connects successfully to my SSL websocket server but yours can't connect to the server, am I missing something ?
Here is my code :
String host = "wss://myserver.com";
mWebSocketFactory = new WebSocketFactory();
websocket = mWebSocketFactory.createSocket(host, 5000);
websocket.setPingInterval(30 * 1000);
websocket.setAutoFlush(true);
websocket.addListener(...);
websocket.connectAsynchronously();
from nv-websocket-client.
I found my error !
I missed the url port now it works. Strange because there were no need my with previous library, sounds like a redirection problem.
Thanks for your time ! I will test your library now !
from nv-websocket-client.
Sorry, redirection (3xx) is not supported although I think it would be better to support it.
from nv-websocket-client.
Released a new version, 1.19.
Since the new version, connect()
method throws OpeningHandshakeException
(a subclass of WebSocketException
) when a violation against the WebSocket protocol is detected during an opening handshake. For example, when a status code other than 101 is returned from a server.
OpeningHandshakeException
provides additional methods such as getStatusLine()
, getHeaders()
and getBody()
to access the response from a server.
You can retrieve the redirection URL like the following.
try
{
// Perform the WebSocket opening handshake.
ws.connect();
}
catch (OpeningHandshakeException e)
{
// Get the status code.
int statusCode = e.getStatusLine().getStatusCode();
// If the status code is in the range of 300 to 399.
if (300 <= statusCode && statusCode <= 399)
{
// Location header should hold the redirection URL.
String location = e.getHeaders().get("Location").get(0);
}
}
catch (WebSocketException e)
{
}
from nv-websocket-client.
What of the 200 OK code how does one fix that, cos my URL is correct and the server person is saying they implemented a websocket, what can I do?!?
from nv-websocket-client.
hello, I'm really stuck. I have a strange problem. I get a (not 101) moved permanently 301 error when not using my VPN - but using the VPN I don't have these problems. I use OkHTTP but the only discussions related to this error I could find was the neovisionaries github site.
Could anyone tell me what might be going on? What I should google? would using an actual IP addresses instead of text url help?
from nv-websocket-client.
Related Issues (20)
- getting below when i try subscribe my payload from Server sometimes
- getting below errors after socket opened and when i try to subscribe my payload from Server sometimes HOT 3
- why getListenerManager() getStateManager() and others are private ? HOT 1
- Denied app upload to PlayStore HOT 3
- How can I have a listener for each sendText Method? HOT 1
- Very misleading error message if jdk.crypto.ec module is missing
- NV WebSocket Client & Quarkus & GraalVM Native Image Problems HOT 1
- Race between WebSocketAdapter.onConnected() and .onTextMessage().
- websocket client send performance
- While multiple send, download is blocked
- -
- Crashes on API < 24 with new AGP that is needed for API 33 HOT 8
- Websocket disconnects automatically after 30 seconds HOT 3
- Handshake failure with basic Authorization
- Websocket makes two connections HOT 1
- how to get session id to send messages
- Throws Exception even if the url is valid
- Does the library use some Tracking link?
- Upgrade SHA-1 to SHA-256 in HandshakeReader
- Ability to replace threads
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nv-websocket-client.