Skip to content

createConnection option not work for https module #24543

Closed
@yibopi

Description

@yibopi

Version: v10.13.0
Platform: Linux 4.15.0-39-generic x86_64

I am trying to use the createConnection option in the https module to set the client local port (localPort=34567 in the example below), but this only works when port = 80, not when port = 443. Following is the code I used to test. Does it mean that https module cannot set a custom socket for https in this way? Thanks.

const https = require('https');
const url = require('url');

var req = https.get({
    host: 'google.com',
    pathname: '/',
    port: 443,   // works when equal to 80, but not 443
    family: 4,
    localPort: 34567,
    createConnection: require('net').createConnection
}, function(res) {
    console.log('localPort:', req.socket.localPort, "remotePort:", req.socket.remotePort);
});

req.on('error', console.error);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions