1

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://?

2
  • Don't you do the same thing? Commented Oct 19, 2013 at 18:26
  • No, wscat doesn't connect with Error: socket hang up. Commented Oct 19, 2013 at 18:29

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.