Why is EventSource connection closed every 30-60 sec when no data transported, while WebSocket's one is kept open?
问题 I would like to push data to users every 2 min. Using EventSource requires additional pushing null-byte every 29 sec to keep the connection open. WebSocket doesn't require such ping. Why is the EventSource connection regularly closed and reopened? Is it because there is no good built-in way in HTTP to check if the connection is still open or other reason? 回答1: The Server-Sent Events (Eventsource) API is layered on HTTP. WebSocket is layered on TCP (but has an HTTP compatible handshake). Both