Websockets and Server Sent Events

Today, I would like to share about WebSockets and Server Sent Event (SSE). Both WebSockets and Server Sent Events are realtime push-based communication methods. Let’s explore at them.

WebSockets

WebSockets is a technology that enables bidirectional real-time interactive communication between a client and a server. WebSockets use the WebSocket protocol for communication.

Advantages

– WebSockets allow realtime bidirectional communication.

– WebSockets are supported in most of the latest browsers today.

– WebSockets don’t use XMLHttpRequest. So unnecessary data loads to the server are reduced.

– Binary data and UTF-8 text formats can be sent with WebSockets.

Disadvantages

WebSockets need TCP connection to work and don’t entirely need HTTP. They just need HTTP to initiate the connection for establishing standalone TCP connection that is used with WebSocket protocol. So some of HTTP functionality cannot be taken in WebSockets. The following are disadvantages of Websockets.

– No compression support

– Not support HTTP/2 mutiplexing

– WebSockets are not supported in old version browsers

– Setting up WebSockets is not simple and takes some time.

– May be issues for some firewalls with packet monitoring

Server Sent Events

SSE (Server-Sent Events) is a technology that allows a client browser to receive automatic updates from a server over a standard HTTP connection but not bidirectional. SSE use the JavaScript EventSource API.

Advantages

– Since SSE uses HTTP, it takes some advantages of HTTP functionality.

– SSE is easy to use and faster to setup.

– SSE will not cause problems with packet monitoring.

Disadvantages

– SSE does not allow bidirectional communication or data transmission.

– SSE can only send UTF-8 data and not binary data.

– SSE has restrictions about maximum number of open conenctions.

These are advantages and disadvantages of WebSockets and Server Sent Event. The case of choosing one of them depends on which solutions you want to solve and what your system needs.

This is all for now. Hope you enjoy that.

By Asahi



アプリ関連ニュース

お問い合わせはこちら

お問い合わせ・ご相談はお電話、またはお問い合わせフォームよりお受け付けいたしております。

tel. 06-6454-8833(平日 10:00~17:00)

お問い合わせフォーム