I've built a simple Node.js WebSocket chat server.
I can run it on localhost
in a terminal tab.
In another terminal tab, I can connect to it with wscat
, using ws://
.
How do I connect to it on localhost
with wss://
?
I've built a simple Node.js WebSocket chat server.
I can run it on localhost
in a terminal tab.
In another terminal tab, I can connect to it with wscat
, using ws://
.
How do I connect to it on localhost
with wss://
?
Look at this example code for how to establish an HTTPS server which will handle the TCP and TLS layers and then the ws
module can handle the websocket aspects integrating with that server. You'll need a TLS certificate. For development you can generate your own and sign it yourself. A web search for "self-signed certificate" should lead you to the info you need for that part.