This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
Adding a timeout to the http connections to avoid indefinite hangs on socket.read0 #29
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've been getting timeouts like these:
"Thread-14" #26347 prio=5 os_prio=0 tid=0x0000009f0277e000 nid=0x1338 runnable [0x0000009f0857e000]
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0([email protected]/Native Method)
at java.net.SocketInputStream.socketRead([email protected]/Unknown Source)
at java.net.SocketInputStream.read([email protected]/Unknown Source)
at java.net.SocketInputStream.read([email protected]/Unknown Source)
at sun.security.ssl.SSLSocketInputRecord.read([email protected]/Unknown Source)
at sun.security.ssl.SSLSocketInputRecord.decode([email protected]/Unknown Source)
at sun.security.ssl.SSLSocketImpl.readRecord([email protected]/Unknown Source)
- locked <0x00000006c3343350> (a java.lang.Object)
at sun.security.ssl.SSLSocketImpl.readRecord([email protected]/Unknown Source)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake([email protected]/Unknown Source)
- locked <0x00000006c3343448> (a java.lang.Object)
at sun.security.ssl.SSLSocketImpl.startHandshake([email protected]/Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake([email protected]/Unknown Source)
at sun.net.www.protocol.https.HttpsClient.afterConnect([email protected]/Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect([email protected]/Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0([email protected]/Unknown Source)
- locked <0x00000006c33434c0> (a sun.net.www.protocol.https.DelegateHttpsURLConnection)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream([email protected]/Unknown Source)
- locked <0x00000006c33434c0> (a sun.net.www.protocol.https.DelegateHttpsURLConnection)
at java.net.HttpURLConnection.getResponseCode([email protected]/Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode([email protected]/Unknown Source)
at com.webcerebrium.binance.api.BinanceRequest.read(BinanceRequest.java:244)
at com.webcerebrium.binance.api.BinanceApi.account(BinanceApi.java:369)
at com.webcerebrium.binance.api.BinanceApi.balances(BinanceApi.java:378)
...
From my research this seems to be caused by a lack of timeout configuration on the http connection. I have added this setting to the where connections are created, with a very large timeout of 2 minutes, to avoid these hangs which go on indefinitely and can't be resolved without restarting the app.
I tested it here and the hangs are gone.
Thanks!