yuyuyu
V2EX  ›  Node.js

http.request 老是连接不上

  •  
  •   yuyuyu · Jan 26, 2017 · 3255 views
    This topic created in 3591 days ago, the information mentioned may be changed or developed.
    let connectTimeOut = setTimeout(function () { req.abort(); }, 10*1000);
    let req = http.request({
            hostname: reqUrl.hostname,
            path: reqUrl.path,
            method: req.method,
            headers: headers,
            }, function (res) {
            	clearTimeout(connectTimeOut);
                ...
            });
    

    经常连接不上直到 10 秒超时,网络都是正常的, wget 也能正常连接 reqUrl ,这是什么问题?

    Supplement 1  ·  Feb 15, 2017
    我发现把程序放 docker 里面就很慢,直接在外面运行则没问题……很奇怪
    4 replies  •  2017-02-15 00:01:42 +08:00
    linbiaye
    linbiaye
    Jan 26, 2017
    1
    查你 header 不让你连。
    yuyuyu
    yuyuyu
    OP
    Jan 26, 2017
    2
    @linbiaye 不是这种原因
    erictaoy
    erictaoy
    Feb 6, 2017
    3
    把 http.request 参数打印出来看看
    yuyuyu
    yuyuyu
    OP
    Feb 15, 2017
    4
    @erictaoy 不太明白你的意思,就是上面的代码呀
    请求各种网站都会超时
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4374 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 07:01 · PVG 15:01 · LAX 23:01 · JFK 02:01
    ♥ Do have faith in what you're doing.