You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<ahref="https://tools.ietf.org/html/draft-ietf-rtcweb-data-channel-12">WebRTC data channels</a>,
4840
+
are important is that HTTP is not meant for keeping open a connection for
4841
+
the server to frequently push data to a web browser. Previously, most web
4842
+
applications would implement long polling via frequent
4843
+
Asynchronous JavaScript and XML (AJAX) requests as shown in the below diagram. </p>
4844
+
<p><imgsrc="theme/img/ajax-long-polling.png" width="100%" alt="Long polling via AJAX is incredibly inefficient for some applications." class="technical-diagram" /></p>
4845
+
<p>Server push, as shown in the below diagram, is more efficient and scalable
4846
+
than long polling because the web browser does not have to constantly ask for
4847
+
updates through a stream of AJAX requests.</p>
4848
+
<p><imgsrc="theme/img/websockets-flow.png" width="100%" alt="WebSockets are more efficient than long polling for server sent updates." class="technical-diagram" /></p>
4849
+
<p>The WebSockets approach for server pushed updates works well for certain
4850
+
categories of web applications such as chat room, which is why that's often
4851
+
the example application for a WebSocket library.</p>
4852
+
<p>Both a JavaScript library on the web browser and a WebSockets
4853
+
implementation on the server are necessary to establish and maintain the
4854
+
connection between the client and server. Examples of JavaScript client
4855
+
libraries and WSGI implementations can be found below.</p>
[WebRTC data channels](https://tools.ietf.org/html/draft-ietf-rtcweb-data-channel-12),
34
+
are important is that HTTP is not meant for keeping open a connection for
35
+
the server to frequently push data to a web browser. Previously, most web
36
+
applications would implement long polling via frequent
37
+
Asynchronous JavaScript and XML (AJAX) requests as shown in the below diagram.
32
38
33
-
Previous approaches for for keeping a connection alive between client and
34
-
server over HTTP, such as
35
-
[Comet](http://en.wikipedia.org/wiki/Comet_(programming), have either used
36
-
long polling or were not implemented by all browsers.
39
+
<imgsrc="theme/img/ajax-long-polling.png"width="100%"alt="Long polling via AJAX is incredibly inefficient for some applications."class="technical-diagram" />
40
+
41
+
Server push, as shown in the below diagram, is more efficient and scalable
42
+
than long polling because the web browser does not have to constantly ask for
43
+
updates through a stream of AJAX requests.
44
+
45
+
<imgsrc="theme/img/websockets-flow.png"width="100%"alt="WebSockets are more efficient than long polling for server sent updates."class="technical-diagram" />
46
+
47
+
The WebSockets approach for server pushed updates works well for certain
48
+
categories of web applications such as chat room, which is why that's often
49
+
the example application for a WebSocket library.
50
+
51
+
Both a JavaScript library on the web browser and a WebSockets
52
+
implementation on the server are necessary to establish and maintain the
53
+
connection between the client and server. Examples of JavaScript client
54
+
libraries and WSGI implementations can be found below.
37
55
38
56
39
57
## JavaScript client libraries
@@ -44,13 +62,39 @@ long polling or were not implemented by all browsers.
44
62
client-side WebSockets implementation.
45
63
46
64
47
-
## Websockets with Nginx
65
+
## Nginx WebSocket proxying
48
66
Nginx officially supports WebSocket proxying as of
49
67
[version 1.3](http://nginx.com/blog/websocket-nginx/). However, you have
50
68
to configure the Upgrade and Connection headers to ensure requests are
51
69
passed through Nginx to your WSGI server. It can be tricky to set this up
52
-
the first time. The following resources are helpful for setting up the
53
-
configuration properly.
70
+
the first time.
71
+
72
+
Here are the configuration settings I use in my Nginx file as part of my
0 commit comments