3

We have two AppEngine (Java) apps. One of them uses URLFetch to the other to create an appointment. In the receiver, we've added a feature where we use the Channel API to see if there are any open channels and let them know about the new data.

The URLFetch call is failing with a SocketTimeoutException. All the code in the receiver is executed (including all open channels being notified) but the calling app still gets a SocketTimeoutException. When I comment out the channel notification line, no error.

This happens only in the deployed app, not in dev mode. Also, the call doesn't come close to reaching the 60-second (or even the old 10-second) timeout allowed by URLFetch.

Nick Johnson
  • 100,655
  • 16
  • 128
  • 198
Kyle Baley
  • 580
  • 1
  • 5
  • 16
  • We can't possibly help without seeing the code and the stacktrace. – Nick Johnson Jan 13 '12 at 03:52
  • I'd put together a sample but we've worked around it. Instead of notifying channels directly, we're sending the request to a task queue. This queue does the same thing but doesn't return the SocketTimeoutException. In any case, the original was just a standard servlet with a call to ChannelServiceFactory.getChannelService( ).sendMessage at the end. – Kyle Baley Apr 29 '12 at 12:57
  • It has to be something specific to your app - it's definitely not the case that it's impossible to make a urlfetch from one app to another! – Nick Johnson Apr 30 '12 at 05:16
  • Agreed. And we're doing it regularly. The error occurs only if we make a Channel API call in the receiving app. – Kyle Baley Apr 30 '12 at 13:17

1 Answers1

0

The default deadline for urlfetch is 5s, so if your application take more than 5s to load and execute the handler it will return a SocketTimeoutException.

As described in the documentation, you can set a longer deadline for your urlfetch call using setConnectTimeout or setReadTimeout

In addition, it is a good idea to move the api call that can be deferred (i.e not necessary to build the http response) to a task queue:

  • the deadline for task queue request is longer (10 minutes, instead of 60s)
  • the task will be retried if failing
  • urlfetch timeout is longer too (10 minutes)
proppy
  • 10,495
  • 5
  • 37
  • 66