WebSockets in 100 Seconds & Beyond with Socket.io
Why Stack Overflow recommends it
Stack Overflow users link it when asker needs live or real-time updates without page refreshes and need a quick introduction to WebSockets and Socket.io.
Recommended by 3 people across 3 different months, 2021 to 2023.
What it is
A short Fireship video that explains what WebSockets are in about 100 seconds, then builds a minimal group chat app with Socket.io in Node.js. It is presented by Jeff Delaney of Fireship and comes with a public source code repo.
What people said
Recommends coderman1234 · 2021-07 · Stack Overflow · on “Open a web page and let it refresh automatically in python”
These websites use this thing called websockets, which allows you to easily send live data back and forth from client to server. They keep a normal request open so that the server can send data back whenever it needs. If you need websockets, there are some resources listed below: MDN Web docs [LINK] 100 seconds of code [this video]
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: [this video] Official socket.io documentation: [LINK] Useful resources: [LINK] [LINK] Hope th
Recommends Paddycrack · 2023-01 · Stack Overflow · on “I want to show live output of my discord bot on a website”
Instead of using express json for api I would use websockets with sockets.io there are some good videos about it like from fireship [this video] in conjunction with the discord js api to send the discord messages to the site in real time
Cites Akash · 2021-06 · Stack Overflow · on “Node server with socket.io wont establish connection”
Cross Origin Resource Sharing is used so that a website cannot access resources of another website until it is allowed through server to by adding headers Access-Control-Allow-Origin: <Site Name> or Wild Card (*) As I think either you are directly opening HTML file or accessing it by another server so domains are going to differ, For ex. HTML File is opening at port [LINK] and WebSocket Server is running at port 3000 so that's why you are facing CORS. Solutions: CORS can be handled with in the socket.io refer this [LINK] or below code: const io = require("socket.io")(httpServer, { cors: { origin: "*", methods: ["GET", "POST"], credentials:true } }); Use npm cors [LINK] library in web server
Cites Joosep Parts · 2022-04 · Stack Overflow · on “How to create system that database notifies server, and then server pushes updated data to client application?”
Betting, financial whatever transactions if they are heavily time dependant (which sounds like your case is) will most likely end up using websockets in one form or the other. There are many messaging libraries out there to help you implement this where queues, load management, transactions are already integrated. With WS were talking about ms precision. [LINK] [this video]