We are using the http plugin to interface to a RFID system. For http post requests, what is the best way to handle timeouts? That is, how do we detect that the RFID system has not responded in a given amount of time. Also, we discovered that the .setTimeout() function for the http plugin has been deprecated, so how is the timeout value set? There is very limited information in the wiki for the http plugin. Help, please!
Doing some emprical testing with the http plugin, we discovered that the timeout default is approximately 20 seconds. How do we change the default timeout setting? Can it be changed, or is it fixed at 20 seconds? Anyone know?
To help others…
When the far end server does not respond to a plugin http post request and a timeout condition occurs, the http plugin response object returns a http status code of zero.
e.g. httpResponse.getStatusCode()
Although a http status code of zero is not defined in the IETF/IANA registry/specification, it can be used to detect when the far end server is ‘unreachable’.
@Servoy: Please consider putting this information in the wiki.
Thanks, Scott. I tried setting the http timeout again today, and, now I am not getting the deprecated method message and the .setTimeout() does not have the strike-through. I should have taken a screen shot when it happened.
I think at one point, it used to be under plugins.http.setTimeout, and that was deprecated, so now its in the HttpClient object that you get back from plugins.http.createNewHttpClient. so they probably just moved it.
Thank you, Scott, for the explanation. You are correct…I was using the old style of code. And, the move makes sense as you can set the timeout for individual clients, not just the for plugin.