two-way communication. Once the client scans the QR code, the server can immediately notify the client of the authentication result. • Low latency: Since the connection is always open, responses are instantaneous. • E ffi cient: After the initial handshake, WebSockets use less overhead compared to HTTP polling. Disadvantage • Complexity: Requires more setup and resources to manage open connections. • Not ideal for simple use cases: For scenarios where continuous bi-directional communication isn’t needed, WebSockets may be overkill.
to implement than WebSockets since it's built on top of HTTP. • E ffi cient for server-to-client updates: Only the server sends data, so it uses fewer resources compared to WebSockets for unidirectional updates. • Automatic reconnection: SSE has built-in support for reconnection if the connection is interrupted. Disadvantage • Unidirectional: The client can’t send messages to the server once the connection is established (the initial connection is an HTTP request). • Not suitable for older browsers: SSE might not be supported on very old browsers (but modern browsers support it).
need two-way communication. For example, once the QR code is scanned on the client side, the server can push an authentication result. Example : Live Score app, streaming app, etc
work in theory, they are less suited for real-time login processes like QR code login. You’d have to manage the complexities of waiting for the server to complete its task and calling back to the client after authentication, which introduces latency and complexity. • Not real-time: Callbacks are asynchronous and event-driven, meaning they don't provide real-time updates like WebSockets or SSE. • Extra complexity: The client must expose an endpoint and the server has to make a separate HTTP request to that endpoint, which adds unnecessary steps.