Closed Chenmingwang closed 1 year ago
Do you have some example code?
var url = require('url');
var https = require('https');
var HttpsProxyAgent = require('https-proxy-agent');
var proxy = 'http://10.64.79.141:3128';
console.log('using proxy server %j', proxy);
//var endpoint = 'https://www.tmall.com';
var endpoint = 'https://10.64.79.121/restaurants'
console.log('attempting to GET %j', endpoint);
var opts = url.parse(endpoint);
var agent = new HttpsProxyAgent(proxy);
opts.agent = agent;
opts.rejectUnauthorized=false;
opts.method = 'POST';
opts.headers = {'Content-Type': 'application/json'}
console.log(opts);
var req = https.request(opts, function (res) {
console.log('"response" event!', res.headers);
console.log(res.statusCode);
res.pipe(process.stdout);
});
req.on('socket', function (socket) {
socket.on('connect', function () {
console.log('capture connection event'); //can not triggered
});
});
req.write(JSON.stringify({'username':'mingwang'}));
req.end();
This module has gone through a large refactor and modernization. I am closing this issue as a bit of house cleaning. If you feel that this issue still exists in the latest release, feel free to open a new issue.
When the connection of client---proxy---server is established successfully, socket connection event is not emitted.
I should register callback on this connection event. But the event can not be triggered. However, node-http-proxy-agent is OK for connection event.