jimmoores / quandl4j

Java wrapper for Quandl REST API
quandl4j.org
Apache License 2.0
78 stars 22 forks source link

Any where I can set READ_TIMEOUT Property? #19

Closed zhangyz189 closed 8 years ago

zhangyz189 commented 8 years ago

Hi,I am using your package to access data from Quandl VERSION: compile group: 'com.jimmoores', name: 'quandl', version: '1.3.0' I will access data every 10 minutes,but i found the thread waited for a long time,how can i set the timeout value?

I dump the jvm thread.

at com.jimmoores.quandl.QuandlSession.getDataSet(QuandlSession.java:159)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:228)
at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:652)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:424)
at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:655)
at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:652)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.client.HttpUrlConnector.apply(HttpUrlConnector.java:227)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
at org.glassfish.jersey.client.HttpUrlConnector._apply(HttpUrlConnector.java:321)
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:224)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:338)
- locked <0x00000000cd9c91a0> (a sun.net.www.protocol.https.DelegateHttpsURLConnection)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1513)
- locked <0x00000000cd9c91a0> (a sun.net.www.protocol.https.DelegateHttpsURLConnection)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387)
- locked <0x00000000cd9c8098> (a java.lang.Object)
- locked <0x00000000cd9c80d8> (a java.lang.Object)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
at sun.security.ssl.InputRecord.read(InputRecord.java:532)
at sun.security.ssl.InputRecord.readV3Record(InputRecord.java:593)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:973)
at sun.security.ssl.InputRecord.readFully(InputRecord.java:465)
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at java.net.SocketInputStream.read(SocketInputStream.java:170)
at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
jimmoores commented 8 years ago

There isn't currently a way of setting the TCP timeout, but I'd like you to try something before we declare that the problem - the possible delay might be the retry policy, which kicks in when the library catches a timeout exception internally. By default it will back-off and retry periodically. This is usually what people want, to avoid writing lots of manual retry code, but sometimes it's better to skip.

Try looking at the RetryPolicy property on SessionOptions as covered in the tutorial https://github.com/jimmoores/quandl4j#quandl-api-key-and-session-options.

You might want to try:

SessionOptions options = SessionOptions.Builder
    .withAuthToken(yourToken)
    .withRetryPolicy(RetryPolicy.createNoRetryPolicy())
    .build();
QuandlSession session = QuandlSession.create(options);

If that doesn't work, let me know and I'll investigate making a change to expose the underlying socket timeout.

Jim

On 2 August 2016 at 04:38, zhangyz189 notifications@github.com wrote:

Hi,I am using your package to access data from Quandl VERSION: compile group: 'com.jimmoores', name: 'quandl', version: '1.3.0' I will access data every 10 minutes,but i found the thread waited for a long time,how can i set the timeout value?

I dump the jvm thread.

at com.jimmoores.quandl.QuandlSession.getDataSet(QuandlSession.java:159) at org.glassfish.jersey.internal.Errors.process(Errors.java:297) at org.glassfish.jersey.internal.Errors.process(Errors.java:228) at org.glassfish.jersey.client.JerseyInvocation.invoke(JerseyInvocation.java:652) at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:424) at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:655) at org.glassfish.jersey.client.JerseyInvocation$1.call(JerseyInvocation.java:652) at org.glassfish.jersey.internal.Errors.process(Errors.java:315) at org.glassfish.jersey.client.HttpUrlConnector.apply(HttpUrlConnector.java:227) at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480) at org.glassfish.jersey.client.HttpUrlConnector._apply(HttpUrlConnector.java:321) at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:224) at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:338)

  • locked <0x00000000cd9c91a0> (a sun.net.www.protocol.https.DelegateHttpsURLConnection) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441) at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1513)
  • locked <0x00000000cd9c91a0> (a sun.net.www.protocol.https.DelegateHttpsURLConnection) at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559) at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387)
  • locked <0x00000000cd9c8098> (a java.lang.Object)
  • locked <0x00000000cd9c80d8> (a java.lang.Object) at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375) at sun.security.ssl.InputRecord.read(InputRecord.java:532) at sun.security.ssl.InputRecord.readV3Record(InputRecord.java:593) at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:973) at sun.security.ssl.InputRecord.readFully(InputRecord.java:465) at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(SocketInputStream.java:141) at java.net.SocketInputStream.read(SocketInputStream.java:170) at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jimmoores/quandl4j/issues/19, or mute the thread https://github.com/notifications/unsubscribe-auth/AADG-yrQFHsreGl5AMZgrpigDO4jNTxMks5qbruqgaJpZM4JaNi5 .

jimmoores commented 8 years ago

Is this still ticket still open?

jimmoores commented 8 years ago

Closing thread as no reply