V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Exceptions
V2EX  ›  Node.js

node.js 做爬虫时,试用 request 模块去请求数据,使用了代理,添加 timeout 超时参数无效大家有遇到过么

  •  
  •   Exceptions · 2018-06-19 17:41:43 +08:00 · 4709 次点击
    这是一个创建于 2108 天前的主题,其中的信息可能已经有所发展或是发生改变。
    爬虫有时候会卡在 request 上,回调不执行
    1 条回复    2018-06-20 02:07:05 +08:00
    joaner
        1
    joaner  
       2018-06-20 02:07:05 +08:00   ❤️ 1
    request 模块的 timeout 只针对建立连接后的超时,可以用 setTimeout(reject..., 3000) 手动关闭超时的请求。
    文档上也特意说了:Note that if the underlying TCP connection cannot be established, the OS-wide TCP connection timeout will overrule the timeout option (the default in Linux can be anywhere from 20-120 seconds).
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5506 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 07:58 · PVG 15:58 · LAX 00:58 · JFK 03:58
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.