使用请求api(node.js)时出现未知协议错误

时间:2013-12-21 12:40:46

标签: node.js

这是我的代码。我正在运行0.10.24版本。有人可以看一下吗?出现错误“错误:6304:错误:140770FC:SSL例程:SSL23_GET_SERVER_HELLO:未知协议:openssl \ ssl \ s23_clnt.c:766:”。

var url = require('url'),
    request = require('request'),
    loginLink = "https://foo";

var params = {
    maxRedirects: 10,
    followRedirect: true,
    followAllRedirects: true,
    timeout: 10000,
    url: url.parse(loginLink),
    method: "POST",
    jar: true,
    strictSSL: false,
    form: {
        'userid': 'userid',
        'pwd': 'pass',
        'timezoneOffset': -330  
    },
    headers: {
        'User-Agent': 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1753.0 Safari/537.36',
        'Connection': 'keep-alive',
        'Origin': 'https://foo'
    }
}

request(params,function(error,response,body){
    if(!error && response.statusCode == 200){
        console.log(body);
    }else{
        console.log(response);
        console.log(error);
    }
});

1 个答案:

答案 0 :(得分:1)

更改SSL版本(?)

options = {
    ....
    strictSSL: false,
    secureProtocol: 'SSLv3_client_method',
    ....
}