0
我正在用electron.js做一个应用程序,并且我已经达到了需要发出http请求来调用php的程度。开始时的响应时间很短,应用程序在接收数据之前失败。然后,我给HTTP路径放了一段时间,以便服务器响应的等待时间增加。问题就像是timeOut不是,不等待指定的那个。对http请求的响应超时
你知道解决这个问题的方法吗?
var http = require('http');
var options = {
timeout: 50000,
host: localStorage.getItem('server'),
port: localStorage.getItem('port'),
path: localStorage.getItem('directori') + '?nosession=1&call=ciberFiSessio&numSerie='+ localStorage.getItem("pc")
};
http.get(options, function(res) {
alert("hola");
if (res.statusCode == 200){
//reinicia();
res.on('data', function (chunk) {
str = chunk;
alert(str);
var myJSON = JSON.parse(str);
//alert(myJSON.fi);
if(parseInt(myJSON.fi)==0){
alert("Hi ha hagut un problema!");
}else{
reinicia();
}
});
}else{
alert("El lloc ha caigut!");
alert(res.statusCode);
}
}).on('error', function(e) {
alert("Hi ha un error: " + e.message);
});