NodeJS (+ ExpressJS) secure WebSockets (wss
) and http/2 (h2
, which is https
by default) example. This example uses µWS
on the sever
side and native JavaScript implementation on the client side.
- Run
npm ci
to install all packages. - Generate certificates and place them in the
certs
folder (./server/certs
) for local development. If you don't know how to generate.pem
and.key
files, you can search the internet or run this in your terminalopenssl req -x509 -newkey rsa:4096 -keyout miro.key -out miro.pem -days 365
. If you set up a password for your certs, you will need to provide it when you start the server with the environment variableCERTPHRASE
. (Note: Make sure the name of the certs you create matches the names insideserver/server.js
. If necessary, please update either the cert names orserver.js
so both match.) - Create an
.env
file to match the.env.example
one and populate it to match your settings and preferences. - If you want to enable
debug
mode to see more verbose output in the console, please setAPP_DEBUG="true"
when you start the server - Start the servers with
node server/server.js
. If you use the default port configuration, the url will behttps://localhost:8443
for the web server andwss://localhost:9000
for the WebSocket server. If you are using a different port(s) (by setting the environment variable(s)PORT
and/orWS_PORT
), update the URL(s) accordingly.
The WebSocket server expects connections on /api/v1/stream
(wss://localhost:9000/api/v1/stream
).