Web3j: SocketTimeoutException on transactionObservable with Parity

Created on 20 Oct 2017  路  7Comments  路  Source: web3j/web3j

Hello, i'm testing master branch on 3.0.0-alpha2, and i've got regulary socketTimeoutException.
I'm connecting to a parity node by HTTP RPC (IPC doesnt seem to work) on localhost:8545

It works for 5, perhaps 10 minutes, then i've got an exception

the code to reproduce :

this.subscriptionTx = web3j.transactionObservable()
                .subscribe(tx -> processTx(tx),
                        e -> {
                            LOG.error("exception dans la souscription aux tx", e);
                        },
                        () -> LOG.info("subscribe completed"));

here the stacktrace :

java.net.SocketTimeoutException: timeout
        at okio.Okio$4.newTimeoutException(Okio.java:230) ~[okio-1.13.0.jar!/:na]
        at okio.AsyncTimeout.exit(AsyncTimeout.java:285) ~[okio-1.13.0.jar!/:na]
        at okio.AsyncTimeout$2.read(AsyncTimeout.java:241) ~[okio-1.13.0.jar!/:na]
        at okio.RealBufferedSource.indexOf(RealBufferedSource.java:345) ~[okio-1.13.0.jar!/:na]
        at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:217) ~[okio-1.13.0.jar!/:na]
        at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:211) ~[okio-1.13.0.jar!/:na]
        at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:189) ~[okhttp-3.8.1.jar!/:na]
        at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:75) ~[okhttp-3.8.1.jar!/:na]
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) ~[okhttp-3.8.1.jar!/:na]
        at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45) ~[okhttp-3.8.1.jar!/:na]
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) ~[okhttp-3.8.1.jar!/:na]
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) ~[okhttp-3.8.1.jar!/:na]
        at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93) ~[okhttp-3.8.1.jar!/:na]
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) ~[okhttp-3.8.1.jar!/:na]
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) ~[okhttp-3.8.1.jar!/:na]
        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93) ~[okhttp-3.8.1.jar!/:na]
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) ~[okhttp-3.8.1.jar!/:na]
        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120) ~[okhttp-3.8.1.jar!/:na]
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) ~[okhttp-3.8.1.jar!/:na]
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) ~[okhttp-3.8.1.jar!/:na]
        at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:185) ~[okhttp-3.8.1.jar!/:na]
        at okhttp3.RealCall.execute(RealCall.java:69) ~[okhttp-3.8.1.jar!/:na]
        at org.web3j.protocol.http.HttpService.performIO(HttpService.java:104) ~[core-3.0.0-alpha2.jar!/:na]
        at org.web3j.protocol.Service.send(Service.java:30) ~[core-3.0.0-alpha2.jar!/:na]
        at org.web3j.protocol.core.Request.send(Request.java:68) ~[core-3.0.0-alpha2.jar!/:na]
        at org.web3j.protocol.core.RemoteCall.send(RemoteCall.java:30) ~[core-3.0.0-alpha2.jar!/:na]
        at org.web3j.protocol.core.RemoteCall.lambda$observable$11(RemoteCall.java:51) ~[core-3.0.0-alpha2.jar!/:na]
        at rx.Observable.unsafeSubscribe(Observable.java:10142) ~[rxjava-1.2.4.jar!/:1.2.4]
        at rx.internal.operators.OperatorMerge$MergeSubscriber.onNext(OperatorMerge.java:248) ~[rxjava-1.2.4.jar!/:1.2.4]
        at rx.internal.operators.OperatorMerge$MergeSubscriber.onNext(OperatorMerge.java:148) ~[rxjava-1.2.4.jar!/:1.2.4]
        at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:77) ~[rxjava-1.2.4.jar!/:1.2.4]
        at org.web3j.protocol.core.filters.BlockFilter.process(BlockFilter.java:32) ~[core-3.0.0-alpha2.jar!/:na]
        at org.web3j.protocol.core.filters.Filter.pollFilter(Filter.java:84) ~[core-3.0.0-alpha2.jar!/:na]
        at org.web3j.protocol.core.filters.Filter.lambda$run$10(Filter.java:50) ~[core-3.0.0-alpha2.jar!/:na]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[na:1.8.0_131]
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) ~[na:1.8.0_131]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) ~[na:1.8.0_131]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) ~[na:1.8.0_131]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_131]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_131]
        at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_131]
Caused by: java.net.SocketTimeoutException: Read timed out
        at java.net.SocketInputStream.socketRead0(Native Method) ~[na:1.8.0_131]
        at java.net.SocketInputStream.socketRead(SocketInputStream.java:116) ~[na:1.8.0_131]
        at java.net.SocketInputStream.read(SocketInputStream.java:171) ~[na:1.8.0_131]
        at java.net.SocketInputStream.read(SocketInputStream.java:141) ~[na:1.8.0_131]
        at okio.Okio$2.read(Okio.java:139) ~[okio-1.13.0.jar!/:na]
        at okio.AsyncTimeout$2.read(AsyncTimeout.java:237) ~[okio-1.13.0.jar!/:na]
        ... 38 common frames omitted

Most helpful comment

I'm trying with new version of web3j (3.1.1) and last parity in light mode, and there are still issues.
Http RPC still getting time out time to time. And IPC still get the issue "Unexpected end-of-input in VALUE_STRING"
Am I the only who have these issues ?

All 7 comments

Hi, I've not been able to reproduce this issue running against a local instance of Parity (v1.7.2-beta-9f47909-20170918). It ran for 15 minutes over HTTP without any problems.

The test I used was ObservableIT.testTransactionObservable()

I was also able to connect over IPC without any issues.

What's sitting between you and your node, and what OS are you running?

I can reproduce it on several different device.
The first one, on my local desktop (core i7, 32G RAM) with a full parity node, i've try with HTTP localhost:8545, and i've got the problem. so i've try my laptop
Second one, on my laptop, (16G RAM, core i7) with a parity on my desktop, and my java program on the laptop, same problem.
So i was thinking my network was the issue. So i've tried on a remote server, a distant VPS at ovh.com
But with a light parity node, because i've got only 10GB ssd on VPS, so i can't have the pending transaction, i've tried only the observable on mined transaction, and same issue on the vps. So my personal network isn't in charge.

I've try sometimes with IPC, but i've never seen it worked. In 10 minutes, i've always got an error like 'end-of-stream VALUE_STRING' (but it's another issue)

For all tests, i'll have to say, that it's working for 5, 10 minutes, then it crash errors, sometimes it's working again, and recrash.

Is this on Windows?

Hello @conor10 :)
I'm on Linux Ubuntu
Sorry, i've just see than in the issue #144 i've paste the debug log with my socketTimeout issue, but the #144 is not exactly the same but "java.util.NoSuchElementException: No value present at java.util.Optional.get(Optional.java:135"

I'm trying with new version of web3j (3.1.1) and last parity in light mode, and there are still issues.
Http RPC still getting time out time to time. And IPC still get the issue "Unexpected end-of-input in VALUE_STRING"
Am I the only who have these issues ?

You might not be. I am getting SocketTimeoutExcpetions when trying to unlock my an account with web3j 3.1.1 and a geth 1.7.0 client. Not the same thing but the same error.

I am following the instructions on docs.web3j.io/management_apis.html. The geth client has every rpcapi enabled and the address is prefixed with '0x'. Everything else appears to be working just fine.

stack trace:
java.net.SocketTimeoutException: timeout at okio.Okio$4.newTimeoutException(Okio.java:230) at okio.AsyncTimeout.exit(AsyncTimeout.java:285) at okio.AsyncTimeout$2.read(AsyncTimeout.java:241) at okio.RealBufferedSource.indexOf(RealBufferedSource.java:345) at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:217) at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:211) at okhttp3.internal.http1.Http1Codec.readResponseHeaders(Http1Codec.java:189) at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:75) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67) at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:185) at okhttp3.RealCall.execute(RealCall.java:69) at org.web3j.protocol.http.HttpService.performIO(HttpService.java:106) at org.web3j.protocol.Service.send(Service.java:31) at org.web3j.protocol.core.Request.send(Request.java:71) ... Caused by: java.net.SocketTimeoutException: Read timed out at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.socketRead(SocketInputStream.java:116) at java.net.SocketInputStream.read(SocketInputStream.java:170) at java.net.SocketInputStream.read(SocketInputStream.java:141) at okio.Okio$2.read(Okio.java:139) at okio.AsyncTimeout$2.read(AsyncTimeout.java:237) ... 51 more

This should be fixed with https://github.com/web3j/web3j/releases/tag/v3.2.0. Please can you test and reopen if this is still an issue.

Was this page helpful?
0 / 5 - 0 ratings