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.
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
orsetReadTimeout
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: