HTTP Request - timeout

Discussions about RaZberry - Z-Wave board for Raspberry computer
Post Reply
pko
Posts: 4
Joined: 15 Feb 2017 14:00

HTTP Request - timeout

Post by pko »

Hello,

I just started developing modules for Z-Way Server.

As the first module should provide some notification functionality, it is necessary to send a POST request via HTTP (using http.request()). Unfortunately, http.request() function seems to have only 5000 ms timeout, which is not enough for my purpose (response time from server is about 7 s). I already tried using timeout parameter (ajax syntax) without any success. Is there a way to set longer timeout?

Thank you :)
User avatar
PoltoS
Posts: 7579
Joined: 26 Jan 2011 19:36

Re: HTTP Request - timeout

Post by PoltoS »

Please use timeout key in the object passed to http.request(). BTW, 20000 ms is the default in the code
pko
Posts: 4
Joined: 15 Feb 2017 14:00

Re: HTTP Request - timeout

Post by pko »

Thank you for your response. I already tried using timeout key without any success. The request still returns an error after 5 seconds with status text "Timeout was reached". If the default timeout is 20000 ms, is there any other reason why I am getting that error?

Thank you in advance
pko
Posts: 4
Joined: 15 Feb 2017 14:00

Re: HTTP Request - timeout

Post by pko »

Problem solved after upgrading firmware from v2.2.4 to v2.3.0.
nico_syspert
Posts: 1
Joined: 28 Feb 2017 17:43

Re: HTTP Request - timeout

Post by nico_syspert »

I'm using V2.3.0 but still I get a timeout after 5 seconds.

If I use
timeout : 20 or
timeout : 4000

they all work

But specifying a timeout over 5000 keeps coming back after 5 seconds.

http.request({
url: 'sip/ps/alertzwave.php?device=' + encodeURI(devName) + '&level=' + lvl + '&message=alarm',
async: true,
timeout: 3000,
error: function(response) {
console.log("Can not make request: " + response.statusText); // don't add it to notifications, since it will fill all the notifcations on error
self.controller.addNotification('device-info sensor', msg , msgType, devId);
},
auth: {
login: config.user,
password: config.password
}
});
User avatar
PoltoS
Posts: 7579
Joined: 26 Jan 2011 19:36

Re: HTTP Request - timeout

Post by PoltoS »

you mean you specify timeout > 5000 seconds? What is the reason for that?
Post Reply