Open ZweiEuro opened 2 years ago
For me this is what is printed afterwards.
Hi @ZweiEuro, I think we forgot to update the documentation when #404 was implemented. Would you please try to set the values for connectTimeout
and readTimeout
in your options object instead of timeout
? I guess this should fix your problem. I'd appreciate your feedback, so we can fix the documentation.
Hi @silkimen, Currently i am doing this:
this.http.setRequestTimeout(custom_timeout ? custom_timeout : this.timeout); // This has an effect
this.http
.sendRequest("http://" + (ip ? ip : this.device.getIP()) + ":" + this.hostPort + "/api/v1/command", {
method: "post",
data: body,
timeout: this.timeout, // this has no effect
headers: { "Content-Type": "application/json" },
serializer: "json",
responseType: "json",
})
You mean i should be doing this ?
//this.http.setRequestTimeout(custom_timeout ? custom_timeout : this.timeout); // This has an effect
this.http
.sendRequest("http://" + (ip ? ip : this.device.getIP()) + ":" + this.hostPort + "/api/v1/command", {
method: "post",
data: body,
connectTimeout: this.timeout, // <------
headers: { "Content-Type": "application/json" },
serializer: "json",
responseType: "json",
})
I had the same issue and came here to find this already reported... I tried adding additional properties to the options object connectTimeout
and readTimeout
and can confirm that fixed the problem.
I think it fixed my issue as well @bluwduch I am just asking for docs and confirmation
I have had the same problem, it would be nice if the documentation could be updated.
Describe the bug My app makes 2 kinds of http calls: To a local device which needs 1s timeout in order to quickly detect if it is down. To a server which needs 10s timeout to work reliably since that can take longer than 1s.
I wanted to avoid setting the timeout globally with
this.http.setRequestTimeout(...);
But when I set it only via the argumetns of:.sendRequest(...,{... timeout:1});
Its ignored. If a timeout occurs it's always exactly after 60 seconds which is the default.Setting the global default will overwrite it for all requests.
This makes me think that the argument of the sendrequest timeout is ignored in general and only the global argument is taken.
System info
Are you using ionic-native-wrapper? No, at least i can't find it anywhere in package.json or in config.xml of the app.
Minimum viable code to reproduce