Skip to content

Allow passing in a custom createConnection function #1944

@connor4312

Description

@connor4312

  • I've searched for any related issues and avoided creating a duplicate issue.

Description

We have a kind of exotic use case where we want to instantiate a websocket off an existing stream that's not from an HTTP or unix socket source. Currently the createConnection method is hardcoded to either create a TLS or standard net connection:

opts.createConnection = isSecure ? tlsConnect : netConnect;

I suggest allowing a custom createConnection function to be passed in the websocket options and, if present, it should take precedence over the existing default logic.

I'm happy to put together a PR for this if it's something you'd accept 🙂

ws version

8.2.2

Node.js Version

v16.6.1

System

System:
OS: Windows 10 10.0.19043
CPU: (24) x64 AMD Ryzen 9 5900X 12-Core Processor
Memory: 23.22 GB / 63.89 GB

Expected result

N/A

Actual result

N/A

Attachments

No response

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