简体   繁体   English

node-request ip addres与远程ip地址不同

[英]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. 我正在尝试对特定页面执行一个简单的request.get(),它向我发送一个超时错误,但是lib尝试访问的地址与远程地址不同。 It seems that node-request is not converting the url to proper ip for some reason. 由于某种原因,似乎节点请求没有将url转换为正确的ip。

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: chrome调试中的请求:

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. 注意:如果我尝试访问: 201.11.11.111:8000/login.aspx201.11.11.111:8000/login.aspx它可以工作,但200.200.00.00:8000不起作用。

if i try to get the page content using https://www.hurl.it/ and passing the url and content-type works too; 如果我尝试使用https://www.hurl.it/获取页面内容并传递url和content-type也可以;

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. 您可以在requestjs调用之前尝试对DNS请求进行硬编码,然后您可以使用您获得的IP设置请求URL。

This is the api you can use to execute the DNS lookup: https://nodejs.org/api/dns.html 这是您可以用来执行DNS查找的API: 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) 请记住,你可以使用dns.setServers来硬编码一些dns服务器(谷歌DNS的['8.8.8.8','8.8.4.4'])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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