What is the difference between web sockets, long polling, server-sent events and forever frame?

后端 未结 1 1196
情深已故
情深已故 2020-12-31 07:01

I\'m currently exploring SignalR, this technology supports transports (web wockets, long polling ,server-sent events and forever frame).

I have understood the termin

相关标签:
1条回答
  • 2020-12-31 07:37

    Transports and fallbacks of SignalR:

    WebSocket Full-duplex

    Websocket is a full-duplex communication channels over a single TCP connection. When both server and browser support, it is the only transport that establishes a true persistent, two-way connection between client and server.

    Server Sent Events Simplex

    also known as EventSource is a technology where a browser receives automatic updates from a server via HTTP connection. The Server-Sent Events EventSource API is standardized as part of HTML5 by the W3C.

    Forever Frame One request -> One infinite response

    Forever Frame creates a hidden IFrame which makes a request to an endpoint on the server that does not complete. The server then continually sends script to the client which is immediately executed, providing a one-way realtime connection from server to client. The connection from client to server uses a separate connection from the server to client connection, and like a standard HTTP request, a new connection is created for each piece of data that needs to be sent.

    Ajax long polling (One Request -> One Response [but delayed]) repeated

    Long polling does not create a persistent connection, but instead polls the server with a request that stays open until the server responds, at which point the connection closes, and a new connection is requested immediately. This may introduce some latency while the connection resets.

    More info:

    https://docs.microsoft.com/en-us/aspnet/signalr/overview/getting-started/introduction-to-signalr https://en.wikipedia.org/wiki/Server-sent_events

    0 讨论(0)
提交回复
热议问题