简体   繁体   中英

node-request ip addres different from remote ip address

I have a app that uses node and request. It was working well until today, I dont know why but it stoped to work. I'm trying to do a simple request.get() to a specific page and it is sending me a timed out error, but the address the lib tried to access is different from remote adddress. It seems that node-request is not converting the url to proper ip for some reason.

request call:

request.get({
    url: 'http://www.website.to.request.com:8000/login.aspx',
    headers: headers,
}

Node error message:

address:"200.200.00.00"
code:"ETIMEDOUT"
 errno:"ETIMEDOUT"
message:"connect ETIMEDOUT 200.200.00.00:8000"
port:8000
stack:"Error: connect ETIMEDOUT 200.200.00.00:8000
    at Object.exports._errnoException (util.js:1022:11)
    at exports._exceptionWithHostPort (util.js:1045:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)" syscall:"connect"

request in chrome debug:

Request URL:http://www.website.to.request.com:8000/login.aspx
Request Method:GET
Status Code:200 OK
Remote Address:201.11.11.111:8000
Referrer Policy:no-referrer-when-downgrade

Note: If I try to access: 201.11.11.111:8000/login.aspx it works, but with 200.200.00.00:8000 not works.

if i try to get the page content using https://www.hurl.it/ and passing the url and content-type works too;

Someone has any idea what this request is wrong??

You can try to hardcode a DNS request, before the requestjs call, and then you can set the request url with the ip you got back.

This is the api you can use to execute the DNS lookup: https://nodejs.org/api/dns.html

Remember that you can use dns.setServers to hardcode some dns servers (['8.8.8.8', '8.8.4.4'] for google DNS)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM