2

I'm using LWP::UserAgent to communicate with webservices on several servers; the servers are contacted one at a time. Each response might take up to 30 minutes to finish, so I set the LWP timeout to 30 minutes.

Unfortunately the same timeout also applies, if the server is not reachable at all (e.g. the webserver is down). So my application waits 30 minutes for a server, which is not running.

Is it feasable to set two seperate timeouts?

  1. a short one, which waits for the connection to be established.
  2. a longer one, which waits for the response, once the connection has been established.
Mat
  • 202,337
  • 40
  • 393
  • 406
spuelrich
  • 194
  • 7

1 Answers1

0

The same timeout doesn't "also apply" if the server is not reachable. The timeout option works in a very specific way:

The request is aborted if no activity on the connection to the server is observed for timeout seconds. This means that the time it takes for the complete transaction and the request() method to actually return might be longer.

As long as data is being passed, the timeout won't be triggered. You can use callback functions (see the REQUEST METHODS section of the docs) to check how long data transfer has been going on, and to exit entirely if desired.

Richard Simões
  • 12,401
  • 6
  • 41
  • 50