错误:使用https

时间:2017-08-21 19:26:58

标签: javascript node.js sockets

我的应用程序在一段时间后因此错误而崩溃:

  

{错误:连接ETIMEDOUT 31.13.92.51:443       at Object.exports._errnoException(util.js:1018:11)       at exports._exceptionWithHostPort(util.js:1041:20)       在TCPConnectWrap.afterConnect [as oncomplete](net.js:1086:14)代码:'ETIMEDOUT',错误:'ETIMEDOUT',系统调用:'connect',
  地址:'31 .13.92.51',端口:443}

     

{错误:套接字挂断       在createHangUpError(_http_client.js:253:15)       在TLSSocket.socketCloseListener(_http_client.js:285:23)       在emitOne(events.js:101:20)       在TLSSocket.emit(events.js:188:7)       at _handle.close(net.js:497:12)       在TCP.done [as _onclose](_tls_wrap.js:332:7)代码:'ECONNRESET'}

我的代码中没有看到任何错误,我该如何处理此错误?

try {
    https.get('https://www.instagram.com/'+username+'/?__a=1', function(resp){
        var body = '';
        resp.setEncoding('utf8');
        resp.on('data', function (chunk) {
            body += chunk;
        });
        resp.on('end', function () {
            try {
                var json = JSON.parse(body);
            } catch (error) {
                callback('Unable to fetch user info from Instagram.', null);
                return;
            }
            callback(null, json.user);
        });
    });
}catch (error){
    callback("Connection to Instagram failed.", null);
}

1 个答案:

答案 0 :(得分:1)

我和this.setScrollPage = function (element) { function execScroll() { return browser.executeScript('arguments[0].scrollIntoView()', element.getWebElement()) } browser.wait(execScroll, 5000); }; 模块尝试过相同的问题,我遇到了同样的问题,所以我决定使用另一个https模块的模块,它似乎运行正常。我不知道为什么但是request无法从https获得响应,因为我已经尝试过了。这是你可以尝试的,因为它对我有用。安装instagram.com模块

request
相关问题