matrix-org / matrix-org/matrix-spec

Replace long polling to receive events with Server Sent Events (SSE)

Open
#475 12 comments 16 reactions 0 assignees View on GitHub
A-Client-Server feature
Dominant language
HTML
Stars
330
Forks
150
Avg merge
2h 21m
Merged PRs (30d)
3

Description

**Description:**

[Server Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events)(SSE) is better than long polling because it creates only 1 persisted connection to server and keeps it open "forever". This technology was specifically designed to overcome challenges related to short/long polling.
SSE is built on top of HTTP protocol, so also can be used in communication between servers. Also SSE is more compliant with existing IT infrastructure like (Load Balancer, Firewall, etc), unlike WebSockets which can be blocked by some firewall.

Currently all major web browsers supports SSE (for those which don't support it's easy to do fallback to long/short polling). There are some cool features which browsers support out of the box:
* automatic reconnection
* remember lastEventId and send it automatically on reconnection.

Check this for reference:
* https://www.html5rocks.com/en/tutorials/eventsource/basics/
* https://stackoverflow.com/questions/9397528/server-sent-events-vs-polling
* https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events
* supported browsers: https://caniuse.com/#feat=eventsource

Contributor guide

Open the contributing guide

Research direction

No files or tests are named. Start by reviewing the linked SSE references and the specification's current long-polling event flow; define the protocol changes and compatibility or fallback behavior needed to replace it, then document the resulting design.

Written by the indexing model from the issue text.

Assessment

Domain
networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.