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

BitstampPollingMarketDataService.getFullOrderBook hang #66

Closed
pabx06 opened this issue Mar 31, 2013 · 13 comments
Closed

BitstampPollingMarketDataService.getFullOrderBook hang #66

pabx06 opened this issue Mar 31, 2013 · 13 comments
Assignees

Comments

@pabx06
Copy link

pabx06 commented Mar 31, 2013

i have noticed that getFullOrderBook () at least for BitstampPollingMarketDataService implementation can hangs forever.

Any idea to introduce a timeout ? and make it return or retry ?

@timmolter
Copy link
Member

That's a good question. I'll look into it...

@timmolter
Copy link
Member

@mmazi will ResCU include a feature for setting a timeout and returning some kind of error code to indicate this? I though they XChange needs this feature a while ago, but I put it off...

@mmazi
Copy link
Contributor

mmazi commented Apr 2, 2013

Yes, I noticed this need when using XChange in a project of mine recently
too. I guess it could be included.

@mmazi
Copy link
Contributor

mmazi commented Apr 12, 2013

See mmazi/rescu#1

@pabx06
Copy link
Author

pabx06 commented Apr 12, 2013

Lovely because since so badly DDOS every where and so poorly Bandwidth Bitcoin exchange get flooded easily. And peoples sell OFF at least that what the MTGOX says. but men i cant believe what i have saw it the order book.

over 2000k Volume ask all at the same 225$ and same volume all at the same 100.000$ and slowly getting the whole market down on the order book of clack moody

@ghost ghost assigned mmazi Apr 15, 2013
@mmazi
Copy link
Contributor

mmazi commented May 11, 2013

Rescu (develop branch) now supports seting HTTP request timeout. Put this into a rescu.properties file on classpath:

rescu.http.readTimeoutMillis = 5000

@mmazi mmazi closed this as completed May 11, 2013
@mmazi
Copy link
Contributor

mmazi commented May 11, 2013

A java.net.SocketTimeoutException will be thrown on timeout.

@timmolter
Copy link
Member

Should we wrap this into an IOException as well, and add a nice little message to it to say how to increase the timeout??

@mmazi
Copy link
Contributor

mmazi commented Oct 15, 2013

SocketTimeoutException is an IOException, so this is already taken care of :)

@timmolter
Copy link
Member

That's strange then because I'm catching IOException, but a SocketTimeoutException snuck through.

Here's the stacktrace:

! si.mazi.rescu.HttpException: Problem GETing (IO)
! at si.mazi.rescu.HttpTemplate.executeRequest(HttpTemplate.java:140) ~[bitcoinium.jar:na]
! at si.mazi.rescu.RestInvocationHandler.invokeHttp(RestInvocationHandler.java:64) ~[bitcoinium.jar:na]
! at si.mazi.rescu.RestInvocationHandler.invoke(RestInvocationHandler.java:50) ~[bitcoinium.jar:na]
! at com.sun.proxy.$Proxy42.getTrades(Unknown Source) ~[na:na]
! at com.xeiam.xchange.mtgox.v2.service.polling.MtGoxPollingMarketDataService.getTrades(MtGoxPollingMarketDataService.java:154) ~[bitcoinium.jar:na]
! at com.xeiam.bitcoinium.jobs.MtGoxPollingTradesJob.doRun(MtGoxPollingTradesJob.java:80) ~[bitcoinium.jar:na]
! at com.xeiam.sundial.Job.execute(Job.java:56) ~[bitcoinium.jar:na]
! at org.quartz.core.JobRunShell.run(JobRunShell.java:176) [bitcoinium.jar:na]
! at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520) [bitcoinium.jar:na]
Caused by: ! java.net.SocketTimeoutException: Read timed out
! at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.6.0_51]
! at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) ~[na:1.6.0_51]
! at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) ~[na:1.6.0_51]
! at java.lang.reflect.Constructor.newInstance(Constructor.java:513) ~[na:1.6.0_51]
! at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1491) ~[na:1.6.0_51]
! at java.security.AccessController.doPrivileged(Native Method) ~[na:1.6.0_51]
! at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1485) ~[na:1.6.0_51]
! at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1139) ~[na:1.6.0_51]
! at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:379) ~[na:1.6.0_51]
! at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:318) ~[na:1.6]
! at si.mazi.rescu.HttpTemplate.executeRequest(HttpTemplate.java:116) ~[bitcoinium.jar:na]
!... 8 common frames omitted
Caused by: ! java.net.SocketTimeoutException: Read timed out
! at java.net.SocketInputStream.socketRead0(Native Method) ~[na:1.6.0_51]
! at java.net.SocketInputStream.read(SocketInputStream.java:129) ~[na:1.6.0_51]
! at com.sun.net.ssl.internal.ssl.InputRecord.readFully(InputRecord.java:422) ~[na:1.6]
! at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:460) ~[na:1.6]
! at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:863) ~[na:1.6]
! at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:820) ~[na:1.6]
! at com.sun.net.ssl.internal.ssl.AppInputStream.read(AppInputStream.java:75) ~[na:1.6]
! at java.io.BufferedInputStream.fill(BufferedInputStream.java:218) ~[na:1.6.0_51]
! at java.io.BufferedInputStream.read1(BufferedInputStream.java:258) ~[na:1.6.0_51]
! at java.io.BufferedInputStream.read(BufferedInputStream.java:317) ~[na:1.6.0_51]
! at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:690) ~[na:1.6.0_51]
! at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:633) ~[na:1.6.0_51]
! at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1195) ~[na:1.6.0_51]
! at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:2300) ~[na:1.6.0_51]
! at sun.net.www.protocol.https.HttpsURLConnectionImpl.getHeaderField(HttpsURLConnectionImpl.java:271) ~[na:1.6]
! at si.mazi.rescu.HttpTemplate.getResponseEncoding(HttpTemplate.java:259) ~[bitcoinium.jar:na]
! at si.mazi.rescu.HttpTemplate.executeRequest(HttpTemplate.java:114) ~[bitcoinium.jar:na]
!... 8 common frames omitted

@timmolter
Copy link
Member

Perhaps the si.mazi.rescu.HttpException needs to get out of the way. Didn't we say we wanted to replace all those with IOException?

@timmolter
Copy link
Member

Oh wait, that was the wrong one. Here's the one I saw at first...

! java.lang.reflect.UndeclaredThrowableException: null
! at com.sun.proxy.$Proxy44.getTransactions(Unknown Source) ~[na:na]
! at com.xeiam.xchange.bitstamp.service.polling.BitstampPollingMarketDataService.getTrades(BitstampPollingMarketDataService.java:105) ~[bitcoinium.jar:na]
! at com.xeiam.bitcoinium.jobs.BitstampPollingTradesJob.fetch(BitstampPollingTradesJob.java:61) ~[bitcoinium.jar:na]
! at com.xeiam.bitcoinium.jobs.BitstampPollingTradesJob.doRun(BitstampPollingTradesJob.java:37) ~[bitcoinium.jar:na]
! at com.xeiam.sundial.Job.execute(Job.java:56) ~[bitcoinium.jar:na]
! at org.quartz.core.JobRunShell.run(JobRunShell.java:176) [bitcoinium.jar:na]
! at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520) [bitcoinium.jar:na]
Caused by: ! java.net.SocketTimeoutException: Read timed out
! at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.6.0_51]
! at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) ~[na:1.6.0_51]
! at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) ~[na:1.6.0_51]
! at java.lang.reflect.Constructor.newInstance(Constructor.java:513) ~[na:1.6.0_51]
! at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1491) ~[na:1.6.0_51]
! at java.security.AccessController.doPrivileged(Native Method) ~[na:1.6.0_51]
! at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1485) ~[na:1.6.0_51]
! at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1139) ~[na:1.6.0_51]
! at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:379) ~[na:1.6.0_51]
! at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:318) ~[na:1.6]
! at si.mazi.rescu.HttpTemplate.executeRequest(HttpTemplate.java:116) ~[bitcoinium.jar:na]
! at si.mazi.rescu.RestInvocationHandler.invokeHttp(RestInvocationHandler.java:65) ~[bitcoinium.jar:na]
! at si.mazi.rescu.RestInvocationHandler.invoke(RestInvocationHandler.java:51) ~[bitcoinium.jar:na]
!... 7 common frames omitted
Caused by: ! java.net.SocketTimeoutException: Read timed out
! at java.net.SocketInputStream.socketRead0(Native Method) ~[na:1.6.0_51]
! at java.net.SocketInputStream.read(SocketInputStream.java:129) ~[na:1.6.0_51]
! at com.sun.net.ssl.internal.ssl.InputRecord.readFully(InputRecord.java:422) ~[na:1.6]
! at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:460) ~[na:1.6]
! at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:863) ~[na:1.6]
! at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:820) ~[na:1.6]
! at com.sun.net.ssl.internal.ssl.AppInputStream.read(AppInputStream.java:75) ~[na:1.6]
! at java.io.BufferedInputStream.fill(BufferedInputStream.java:218) ~[na:1.6.0_51]
! at java.io.BufferedInputStream.read1(BufferedInputStream.java:258) ~[na:1.6.0_51]
! at java.io.BufferedInputStream.read(BufferedInputStream.java:317) ~[na:1.6.0_51]
! at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:690) ~[na:1.6.0_51]
! at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:633) ~[na:1.6.0_51]
! at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1195) ~[na:1.6.0_51]
! at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:2300) ~[na:1.6.0_51]
! at sun.net.www.protocol.https.HttpsURLConnectionImpl.getHeaderField(HttpsURLConnectionImpl.java:271) ~[na:1.6]
! at si.mazi.rescu.HttpTemplate.getResponseEncoding(HttpTemplate.java:253) ~[bitcoinium.jar:na]
! at si.mazi.rescu.HttpTemplate.executeRequest(HttpTemplate.java:114) ~[bitcoinium.jar:na]
!... 9 common frames omitted

@mmazi
Copy link
Contributor

mmazi commented Oct 16, 2013

You're getting a SocketTimeoutException that's wrapped in UndeclaredThrowableException. That happens because the JAX-RS-annotated interface method (in this case Bitstamp.getTransactions()) doesn't declare throws IOException (I remember I explained this somewhere but I can't find it now). It's impossible to get a checked exception when calling a method that doesn't declare it, that's why Java's proxies will wrap the checked IOException this way.

throws IOException should be declared on all methods of the interface (Bitstamp), then handled properly where they are called.

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

No branches or pull requests

3 participants