SignalR transport mechanisms

SignalR connects through WebSockets, Server-Sent Events, Forever Frames, and long polling. The following is a short description of each of these transport mechanisms:

  • WebSockets: WebSockets is an advanced computer communication protocol that enables you to open an interactive communication session between the user's browser and a server with a lower overhead. With the advent of HTML5, WebSockets is supported by the latest version of all major browsers, such as Microsoft Edge, Microsoft Internet Explorer, Google Chrome, Firefox, Safari, and Opera. With WebSockets, we can send messages to a server and receive event-driven responses without having to poll the server for a reply. This is full-duplex communication.
  • Server-Sent Eevents: Server-Sent Events are a technology that enables web pages to receive automatic updates from the server through a HTTP connection. The server can initiate the data transmission toward a client after an initial connection has been established. This is not supported by the current version of Microsoft Edge and Microsoft Internet Explorer, but is available in Google Chrome, Mozilla Firefox, Safari, Opera, and others. This is simplex communication, as the server pushes the data to the client. This is part of the HTML5 specification.
  • Forever Frame: Forever Frame is a Microsoft Internet Explorer concept and is not supported by any other browser. When a connection is established between a client web page and a server through Forever Frame, it creates a hidden IFrame in the client page. This IFrame makes a request to the server endpoint, which never completes; that is, it keeps the connection alive forever (hence the name, Forever Frame). Since the connection remains open, the server can use this connection to push scripts to the client, which are loaded and executed immediately in the client page, thus providing a real-time one-way communication from the server to the client. This is supported in old SignalR but removed from SignalR Core.
  • Long pollingLong polling is something that most web developers do in their regular web development without realizing it is actually long polling. Long polling does not create a persistent connection, but instead polls the server with a request that stays open until the server responds. This may introduce some latency while the connection resets. Long polling is basically an approach used for backward compatibility with old browsers and is definitely not a preferred method for client-server communication for the modern web.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset