Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[email protected] and proxy with https over http combination is not working #14

Open
masakura opened this issue Aug 6, 2015 · 1 comment

Comments

@masakura
Copy link

masakura commented Aug 6, 2015

Node.js v0.12.7 and proxy with https over http combination is not working. Error occurs.

I test my ta.js script. http://www.nasa.gov is 200 OK, but, https://travis-ci.org is failed.

$ nvm use v0.12.7 && node ta.js https://travis-ci.org   
Now using node v0.12.7
{ [Error: write EPROTO 140128450471808:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:../deps/openssl/openssl/ssl/s23_clnt.c:782:
] code: 'EPROTO', errno: 'EPROTO', syscall: 'write' }

$ nvm use v0.12.7 && node ta.js http://www.nasa.gov
Now using node v0.12.7
200 (http://www.nasa.gov)

$ nvm use v0.10.40 && node ta.js https://travis-ci.org
Now using node v0.10.40
200 (https://travis-ci.org)

$ nvm use v0.10.40 && node ta.js http://www.nasa.gov
Now using node v0.10.40
200 (http://www.nasa.gov)

ta.js is here.

'use strict';

var url = process.argv[2];
var options = require('url').parse(url);
var protocol = options.protocol.replace(':', '');
var tunnel = require('tunnel-agent')[protocol + 'OverHttp'];
options.agent = tunnel({
    proxy: {
        host: '{proxyhost}',
        port: 8080,
        proxyAuth: '{userid}:{password}'
    }
});
options.headers = {
    'Connection': 'close'
};

var func = protocol === 'http' ? require('http') : require('https');

var req = func.request(options, function (res) {
    console.log(res.statusCode + ' (' + url + ')');
});
req.on('error', function (error) {
    console.log(error);
})
req.end();
@cluehr
Copy link

cluehr commented Nov 25, 2015

This should be fixed by pull request #15.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants