Skip to content
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

How to make the connect time out parameter work when connect socket #1194

Open
4Mi opened this issue Nov 9, 2021 · 2 comments
Open

How to make the connect time out parameter work when connect socket #1194

4Mi opened this issue Nov 9, 2021 · 2 comments

Comments

@4Mi
Copy link

4Mi commented Nov 9, 2021

Describe what you would like to know or do
Precondition:

  1. the network signal is not good.
  2. the url like "wss://..."

when i create socket with a connect timeout value 5 seconds as following:
super(serverUri, new Draft_6455(), null, 5000);

after calling sockect.connect(), the onOpen() is not called, but after 15 minutes,
the onError is called with following stack:
11-09 13:44:41.378 D/MssSocket( 6934): onError e: javax.net.ssl.SSLHandshakeException: SSL handshake aborted: ssl=0x8f209c80: I/O error during system call, Connection timed out
11-09 13:44:41.378 D/MssSocket( 6934): at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
11-09 13:44:41.378 D/MssSocket( 6934): at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:324)
11-09 13:44:41.378 D/MssSocket( 6934): at com.android.org.conscrypt.OpenSSLSocketImpl.waitForHandshake(OpenSSLSocketImpl.java:629)
11-09 13:44:41.378 D/MssSocket( 6934): at com.android.org.conscrypt.OpenSSLSocketImpl.getInputStream(OpenSSLSocketImpl.java:591)
11-09 13:44:41.378 D/MssSocket( 6934): at org.java_websocket.client.WebSocketClient.run(WebSocketClient.java:407)

It seems like that the connect timeout value which is set by constructor does not work.

Also, during the 15 minutes, i try closing the opening socket, but onClose() is not called.
How can I set the connect timeout correctly? THANKS

@marci4
Copy link
Collaborator

marci4 commented Nov 9, 2021

Hey,

looking at the code I would say that the timeout is set and used.

Best regards,
Marcel

@sirhcel
Copy link

sirhcel commented Aug 10, 2023

Could it be the case that the timeout is "just" set at the socket but the connectLatch which gets awaited in connectBlocking does not get notified?

I'm experiencing the problem when the service I'm trying to connecting to is down. The application sets a timeout via the JSON configuration but WebSocketClient.connectBlocking does not return. Shouldn't a timeout from the socket connection also notify connectLatch so that connectBlocking() can actually return as advertised?

Using connectBlocking(long, TimeUnit) with the same timeout instead of connectBlocking() returns and allows my application to retry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants