WebSocket
How does a chat room receive new messages in real time?
How does a chat room receive new messages in real time?
Any new messages?ReplyNoAskAny new messages?Reply1 new messageAsk again each time; messages arriving within the interval wait for the next roundMessages arriving within the polling interval are delayed; shorter intervals cost more requests.
Polling waits for the next check: A new message may wait for the next check; shorter intervals mean more requests.
WebSocket can send proactively: An open connection lets the server send proactively, but actual delay also depends on server work, queues, network, and client rendering.
Both sides can send: It is not just server push: the client can send anytime over the same connection.
The chat room currently polls for new messages every second. Switch to WebSocket: keep the connection open after it is established and push messages as they arrive. Auto-reconnect on disconnection; afterward confirm it is a persistent connection in the Network panel and test that messages resume after a network recovery.