Secure Websocket Server with uWebsockets.js


I’ve tried using express-ws as a Websocket handler, to allow SSL (wss://) but I am unsure how I could integrate it with uWebsockets.js

Any help would be appreciated.

With glitch you automatically get ssl, you just need to write wss:// in front of your connection uri

In the following example, you can see to initate a SSL application you need access to the correct authorisation files. In a similar post, I found using express-ws was a way to bypass this (for normal WebsocketServer npm module) by getting the app and exporting it. Not sure if I could parse the app/https server in to a UWS initiation.

/* Non-SSL is simply App() */

  /* There are more SSL options, cut for brevity */
  key_file_name: 'misc/key.pem',
  cert_file_name: 'misc/cert.pem',

That is not going to work with Glitch sadly, because of how the reverse proxy works.

Your connections will be sent securely to the reverse-proxy and then send insecurely to your project container. I have also previously made a post about something similar a long time ago.

You simply cannot use your own certificates with Glitch.

I wasn’t saying to use my own certificate, but perhaps access read-only of Glitch’s. I’ll stick to ws and maybe email support.

That still is not going to work, the reverse-proxy sends incoming requests insecurely to your project, meaning that it sends either http or ws, it just doesn’t have the ability to send as https or wss. This is limitations you’re gonna have to live with.


Alright, thanks for the help.

No worries, always happy to help.

1 Like

it works.

  1. just use .App
  2. ssl enabled by default.
  3. connect with wss://LIVE_APP_URL
  4. profit fast socket is yours.