2

I know that the socket timeout for fetching URLs is fixed on 60 seconds.

I use java.util.logging and before I call the https function I log this:

2012-03-27 14:46:15.445 TelenorClient changeSimStatus: attempt 1 ....

And the exception occurs 5 seconds later

2012-03-27 14:46:20.197 TelenorClient changeSimStatus: exception java.net.SocketTimeoutException: Timeout while fetching: https://serviceportal...

I am using a JAX-WS based webservice client, and setting the timeout using the BindingProviderProperties and RequestContext is not allowed, according to this message:

com.sun.xml.internal.ws.client.BindingProviderProperties is not supported by Google App Engine's Java runtime environment

Which corresponds with the first statement that Google App Engine has its own way of setting the timeout. But again, to me, it seems much shorter than 60 seconds.

I am looking for tips on how to address this.

Anthony
  • 12,177
  • 9
  • 69
  • 105
mpjjonker
  • 917
  • 1
  • 6
  • 28

2 Answers2

3

The URL Fetch service (used by your JAX-WS client) is limited to 5 seconds timeout. You can extend it to max 60 seconds via setConnectTimeout(). For more (up to 10 min) you must execute it via Task Queue or Cron.

Update:

If youR JAX-WS client does not give you access to connection, than you can try executing the whole JAX-WS call on the task queue. This is easiest done via DeferredTask.

Community
  • 1
  • 1
Peter Knego
  • 79,991
  • 11
  • 123
  • 154
  • Thanks Peter for the answer, can you maybe show where in the jax-ws framework I can call setConnectTimeout() ? – mpjjonker Jun 21 '12 at 10:35
  • Hi peter, I am facing issue with connection timeout. I have configured 10 sec ,but its still taking more than 1 mins. Can you please advise something here? I have configured using spring XML context. – JDGuide Oct 26 '15 at 06:47
2

I got this tip from Mitch Rudominer; just use the text values of the constants.

Map<String, Object> context = ((BindingProvider) service).getRequestContext();
context.put("com.sun.xml.ws.request.timeout", 60*1000);
context.put("com.sun.xml.ws.connect.timeout", 10*1000);

It looks like it is working:

2012-07-03 14:26:45.604 com.simservices.bus.kpndata.DataDetailsServlet getDetailData: 2012-04-01 - 8931084711061420005

2012-07-03 14:26:56.183 com.simservices.bus.kpndata.DataDetailsServlet getDataUsage: getting the response for data from KPN

2012-07-03 14:27:33.619 com.simservices.bus.kpndata.DataDetailsServlet getDataUsage: detailsList has 4612 elements

2012-07-03 14:27:36.540 com.simservices.bus.kpndata.DataDetailsServlet getDataUsage: added 4612 data elements

mpjjonker
  • 917
  • 1
  • 6
  • 28
  • For the development server, the keys appear to be "com.sun.xml.internal.ws.request.timeout" and "com.sun.xml.internal.ws.connect.timeout". (Source: https://code.google.com/p/google-api-ads-java/source/diff?spec=svn8cc64e117a4317801cefadfdb0f8457c2d9b47d6&r=8cc64e117a4317801cefadfdb0f8457c2d9b47d6&format=side&path=/modules/ads_lib_appengine/src/main/java/com/google/api/ads/common/lib/soap/jaxws/JaxWsHandler.java) – vaughandroid May 13 '13 at 15:31