【问题标题】:Error: ETIMEDOUT on NPM usage in Meteor错误:在 Meteor 中使用 NPM 时出现 ETIMEDOUT
【发布时间】:2016-05-15 18:06:51
【问题描述】:

我尝试在 Meteor 1.3.2.4 中使用 this NPM 包。它在函数中使用事件发射器并具有异步回调。我尝试根据this guide article 将其转换为与Meteor.bindEnvironment 同步的外观,如下所示:

Meteor.methods({
    proxyFetcher() {
        console.log("OK run");
        var options = {
            protocols: ['http'],
            anonymityLevels: ['elite'],
            sourcesBlackList: ['bitproxies', 'kingproxies']
        };

    var gettingProxies = ProxyLists.getProxies(options);
    Proxies.remove({});

    gettingProxies.on('data', Meteor.bindEnvironment(function(proxies) {
        console.log(proxies.length);
        proxies.forEach((proxy) => {
            Proxies.insert({proxy: proxy.ipAddress + ":" + proxy.port});
        });
        // Received some proxies.
    }));
}
}

但这是我的输出:

I20160515-12:08:02.579(4.5)? OK run
I20160515-12:08:03.250(4.5)? 44
I20160515-12:08:03.645(4.5)? 29
I20160515-12:08:03.963(4.5)? 35
I20160515-12:08:04.376(4.5)? 349
I20160515-12:08:04.711(4.5)? 337
I20160515-12:08:05.071(4.5)? 350
I20160515-12:08:05.853(4.5)? 330
I20160515-12:08:06.149(4.5)? 323
I20160515-12:08:06.443(4.5)? 331
I20160515-12:08:06.737(4.5)? 324
I20160515-12:08:07.039(4.5)? 334
W20160515-12:08:08.083(4.5)? (STDERR) 
W20160515-12:08:08.084(4.5)? (STDERR) Error: ETIMEDOUT
W20160515-12:08:08.085(4.5)? (STDERR)     at [object Object]._onTimeout (/home/cyc/Programming/Projects/proxyCheck/Sources/node_modules/proxy-lists/node_modules/request/request.js:762:15)
W20160515-12:08:08.085(4.5)? (STDERR)     at Timer.listOnTimeout [as ontimeout] (timers.js:121:15)
=> Exited with code: 8
=> Meteor server restarted

正如您所见,服务器重新启动并且我的代码在一些迭代后返回错误。 有什么问题,以及在 Meteor 中使用这个包的正确方法是什么。

【问题讨论】:

    标签: javascript node.js meteor npm eventemitter


    【解决方案1】:

    可能是代理列表发出的一个 http 请求失败了,而这个错误未被捕获,所以它冒泡导致整个 Node 进程崩溃。

    如果你处理了错误,那应该可以防止它导致进程崩溃:

    gettingProxies.on('error', function(error) {
        // Some error has occurred.
        console.error(error);
    });
    

    【讨论】:

      猜你喜欢
      • 2013-07-28
      • 1970-01-01
      • 2022-10-23
      • 2015-04-27
      • 2021-04-03
      • 2020-01-19
      • 1970-01-01
      • 1970-01-01
      • 2021-07-13
      相关资源
      最近更新 更多