
测试 google cse 的 api ,在 chrome 和 postman 中都能在 1s 左右获取到返回的 json (网络畅通,未科学上网),可是在 Node 中使用 https 的代码请求就一直是超时状态,请问下有可能哪里出了问题?新人不太懂,谢谢!
Node 中的代码, key 和 id 替换掉了:
var optiOns= { hostname: 'www.googleapis.com', port: null, path: '/customsearch/v1?key=我的 key&cx=我的 id&num=10&q=python', method: 'GET' }; var req = https.request(options, (res) => { console.log('statusCode:', res.statusCode); console.log('headers:', res.headers); res.on('data', (d) => { process.stdout.write(d); }); }); req.end(); req.on('error', (e) => { console.error(e); }); 报错 log :
{ [Error: connect ETIMEDOUT 172.217.26.106:443] code: 'ETIMEDOUT', errno: 'ETIMEDOUT', syscall: 'connect', address: '172.217.26.106', port: 443 } 1 justrun OP 写了几句 python 试了下也能正常得到响应数据。。 |
2 xxxyyy 2016-11-02 00:40:54 +08:00 via Android 是否在 hosts 里绑定了 www.googleapis.com ? 自己 ping 172.217.26.106 可以 ping 的通吗? |