Axios not respecting the value I set for "timeout"
See original GitHub issueSummary
Hi there,
I’ve been using axios a lot in my web application. Everything has been working just fine in most cases. Today, I’ve got a new demand in my application using axios, but I can’t get it working.
I am creating the possibility to import data to my application. The user uploads a .csv file to my server, and with axios I am calling a method in my controller to process data.
The issue I am facing is related to the timeout parameter set when using axios.
I have a large amount of data to import, so it will take more than 2 minutes to process all the data. Whatever value bigger than 2 minutes won’t be considered by axios. It only waits for 2 minutes, and them returns an error.
Am I missing something here? I checked the documentation and made sure I was using what is recommended in “Config order of precedence”, but I still can’t make it work.
Would someone help me out?
Context
- axios version: e.g.: v0.17.1
- Environment: e.g.: node v6.9.4, chrome 54, windows 7, react JS, C#, .net Core
My implementation
axios({
method: 'post',
url: '/user',
timeout: 180000, // Let's say you want to wait at least 180 seconds
data: {
id: '1234',
}
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
Issue Analytics
- State:
- Created 5 years ago
- Comments:10
Top GitHub Comments
timeout depends on both client side and server side, do you want to check your server side config first? e.g., tomcat timeout configs? or sth like that?
in short, while client is still waiting, the server shouldn’t close that connection.
you could verify this by running a dummy nodejs server which wait, the timeout actually works: server.js
client.js
Adding timeout in the config won’t work. Use the following instead:
axios.defaults.timeout = 180000;