-
Notifications
You must be signed in to change notification settings - Fork 982
Is it possible to connect to a server that does not have the websocket transport? #660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks, I could indeed reproduce the behavior. I guess this is a bug, because a failure to upgrade to WebSocket should not close the connection. |
darrachequesne
added a commit
to socketio/engine.io-client-java
that referenced
this issue
Jul 3, 2022
With the previous value (10 seconds by default), a connection established with HTTP long-polling was closed if the server did not send any packet for 10 seconds (the HTTP request would timeout from the client side). It will now default to 1 minute, which is above the `pingInterval + pingTimeout` value from the server. Note: the connectTimeout and writeTimeout options are left as is (10 seconds), but you may need to increase them depending on your use case: ``` OkHttpClient client = new OkHttpClient.Builder() .connectTimeout(20, TimeUnit.SECONDS) .readTimeout(1, TimeUnit.MINUTES) .writeTimeout(1, TimeUnit.MINUTES) .build(); ``` Related: - socketio/socket.io-client-java#491 - socketio/socket.io-client-java#660
darrachequesne
added a commit
to socketio/engine.io-client-java
that referenced
this issue
Jul 10, 2022
With the previous value (10 seconds by default), a connection established with HTTP long-polling was closed if the server did not send any packet for 10 seconds (the HTTP request would timeout from the client side). It will now default to 1 minute, which is above the `pingInterval + pingTimeout` value from the server. Note: the connectTimeout and writeTimeout options are left as is (10 seconds), but you may need to increase them depending on your use case: ``` OkHttpClient client = new OkHttpClient.Builder() .connectTimeout(20, TimeUnit.SECONDS) .readTimeout(1, TimeUnit.MINUTES) .writeTimeout(1, TimeUnit.MINUTES) .build(); ``` Related: - socketio/socket.io-client-java#491 - socketio/socket.io-client-java#660 Backported from fb531fa
For future readers: I think this was due to the default readTimeout value of the OkHttp client (10 seconds). It must be increased: OkHttpClient okHttpClient = new OkHttpClient.Builder()
.readTimeout(1, TimeUnit.MINUTES) // important for HTTP long-polling
.build();
IO.Options options = new IO.Options();
options.callFactory = okHttpClient;
options.webSocketFactory = okHttpClient;
Socket socket = IO.socket(URI.create("https://example.com"), options); See also: socketio/engine.io-client-java@fb531fa Please reopen if needed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
I have a Socket.io server that works very well, I can connect with different libraries (python, js etc ...).
But with this library I can't connect. The special thing about my server is that it does not implement the WebSocket transport.
I can connect and exchange messages for about 5 seconds, then I am disconnected.
Here is the error I am getting:
The last part of the stack trace is not always the same, sometimes I have:
or
The text was updated successfully, but these errors were encountered: