Learn Socket.io In 30 Minutes
Why Stack Overflow recommends it
Stack Overflow users link it when answering or asking about Socket.io, especially as a worked demonstration of namespaces and as the tutorial learners follow when setting up client and server.
Recommended by 2 people across 2 different months, 2021 to 2023.
What it is
A 27-minute tutorial from Web Dev Simplified that walks through Socket.io's main features: basic client/server setup, sending events both ways, rooms, emit callbacks, the admin dashboard, namespaces, middleware and offline mode. It builds on a starting code base and is presented as a single-presenter screencast.
What people said
Recommends Alvin Cheng · 2022-05 · Stack Overflow · on “Change data on UI without refresh”
You do not have any code here, so I can't give you the exact answer for your situation. And You have not told me how you want it to not 'refresh' e.g a button click or something like that. In your case my best tip would be to check out Socket.io, socket.io is a framework in Nodejs that can help you interact with WebSockets. A WebSocket is a direct connection between the client and server and does not require a trigger on the client. Instead of working around it by fetching data every couple of seconds in the app. Jeff from fireship has done a better explanation of this topic you can watch his video here: [LINK] Official socket.io documentation: [LINK] Useful resources: [this video] [LINK] Hope th
Recommends Edward · 2023-11 · Stack Overflow · on “Run 2 node js socket.io projects in a single url”
You can use namespaces for that. Basically you will start socket.io server on same url but different routes(socket.io calls it namespace). Here you can read more: [LINK] And this particular video also showcases namespace implementation in action: [this video] .
Cites prajwal tulawe · 2021-09 · Stack Overflow · on “Socket.io + Node.js Cross-Origin Request Blocked”
So, basically in v2, the Socket.IO server automatically added the necessary headers to allow Cross-Origin Resource Sharing (CORS) therefor there was no problem for connection between client and server. But this behavior, while convenient, was not great in terms of security, because it meant that all domains were allowed to reach your Socket.IO server. In v3 and above versions the CORS is disabled by default. Therefor you need to explicitly enable them on your server side script. Example of my code: In v2 of socket.io the server script looked like : const io = require('socket.io')(8000); But in v3 and above versions this code becomes to : const io = require('socket.io')(8000, { cors: { origin
Cites Asim Koirala · 2022-05 · Stack Overflow · on “How do I get rid of this error while using npm package in client side JS?”
I was learning socket.io and when I reached the client side part, I installed a package called socket.io-client as per my instructor. When I tried to use it in my client side JS, it threw me an error. My socket.io is configured to run in the port 3000. This is my first time trying to use npm packages in the client side JS. My instructor was this video: [this video] The error reads out like this:- Uncaught TypeError: Failed to resolve module specifier "socket.io-client". Relative references must start with either "/", "./", or "../". Here is my code: import { io } from "socket.io-client"; const socket = io(" [LINK] "); Can anyone help me with this error?