To install all of your dependencies:
npm install
You will need to provide an .env
file containing all of your MongoDB connection string information. The following is an example:
In order to run your sever locally, you can execute the following command:
node server.js
or
npm run start
You can also use a tool like Postman to test as well. it supports both socket.io and websocets
http://127.0.0.1:8080/apiSIO/hello-socketio
Could not connect to http://127.0.0.1:8080/apiSIO/hello-socketio Error: Unexpected server response: 404
// error on client GET http://localhost:8080/socket.io/?EIO=4&transport=polling&t=OzzR0IF 404 (Not Found) index.js:74 message xhr poll error index.js:76 description 404 index.js:78 context XMLHttpRequest...
{"level":30,"time":1715895572624,"pid":35768,"hostname":"BGR-LT-37BG3Y2","reqId":"req-1","req":{"method":"GET","url":"/socket.io/?EIO=4&transport=websocket","hostname":"127.0.0.1:8080","remoteAddress":"127.0.0.1","remotePort":61309},"msg":"incoming request"} {"level":30,"time":1715895572625,"pid":35768,"hostname":"BGR-LT-37BG3Y2","reqId":"req-1","msg":"Route GET:/socket.io/?EIO=4&transport=websocket not found"}
ws://127.0.0.1:8080/apiWS/hello-ws
ws://127.0.0.1:8080/apiWS/hello-ws2
ws://127.0.0.1:8080/apiWS/ws-room/r101
socket.io works with fastify 3 "fastify": "^3.29.0", "@guivic/fastify-socket.io": "^0.1.3"