-
-
Notifications
You must be signed in to change notification settings - Fork 11k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question : How to force IPv4 #444
Comments
axios does not support the var http = require('http');
var agent = new http.Agent({ family: 4 });
axios.get('http://www.google.com/', { httpAgent: agent }); // Note: use httpsAgent for HTTPS You can also set the var instance = axios.create({ httpAgent: agent });
instance.get('http://www.google.com/'); or at the global level: axios.defaults.httpAgent = agent; Hope this helps! |
Mind that |
@rubennorte Thank you! I've updated my comment. |
Thank you for the suggestions. It worked with 0.12.0 (agent=agent) version but for 0.14.0 (httpAgent=agent) I'm getting ETIMEDOUT error. My test case involves making a http call to one of our micro service deployed on AWS EC2. Just wondering why it doesn't work with 0.14.0 version |
Core "Http" module has a way to force IPv4 by specifying "family" option. See example below. How would I achieve this with "axios"?
var http = require('http');
var options = {
family: 4,
host: 'www.google.com',
path: '/index.html'
}
http.get(options, (res) => {
console.log(
Got response: ${res.statusCode}
);// consume response body
res.resume();
}).on('error', (e) => {
console.log(
Got error: ${e.message}
);});
The text was updated successfully, but these errors were encountered: