@@ -69,24 +69,7 @@ However, a JavaScript wrapper library can make a developer's life easier by
6969implementing graceful degradation (often falling back to long-polling when
7070WebSockets are not supported) and by providing a wrapper around
7171browser-specific WebSocket quirks. Examples of JavaScript client libraries
72- and Python implementations are found below.
73-
74-
75- ## JavaScript client libraries
76- * [ Socket.io] ( http://socket.io/ ) 's client side JavaScript library can be
77- used to connect to a server side WebSockets implementation.
78-
79- * [ web-socket-js] ( https://github.com/gimite/web-socket-js ) is a Flash-based
80- client-side WebSockets implementation.
81-
82-
83- ## Python implementations
84- * [ Autobahn] ( http://autobahn.ws/python/ ) uses Twisted or asyncio to implement
85- the WebSockets protocol.
86-
87- * [ Crossbar.io] ( http://crossbar.io/ ) builds upon Autobahn and includes a
88- separate server for handling the WebSockets connections if desired by
89- the web app developer.
72+ and Python implementations are shown in a section below.
9073
9174
9275## Nginx WebSocket proxying
@@ -141,7 +124,7 @@ properly.
141124 shows how to proxy with Socket.io.
142125
143126
144- ## Open source Python WebSockets projects
127+ ## Python WebSockets implementations
145128The following projects either implement WebSockets in Python or provide
146129example code you can follow to use WebSockets in your own projects.
147130
@@ -150,57 +133,57 @@ example code you can follow to use WebSockets in your own projects.
150133 [ AutobahnJS] ( https://github.com/crossbario/autobahn-js ) assists on the
151134 client web browser side.
152135
153- * The Flask-SocketIO project has a
154- [ chat web application] ( https://github.com/miguelgrinberg/Flask-SocketIO/tree/master/example )
155- that demos sending server generated events as well as input from users
156- via a text box input on a form.
136+ * [ Django Channels] ( https://channels.readthedocs.io/en/stable/ ) is built
137+ on top of WebSockets and is easy to integrate with existing or new
138+ [ Django] ( /django.html ) projects.
157139
158- * The
159- [ python-websockets-example] ( https://github.com/mattmakai/python-websockets-example )
160- contains code to create a simple web application that provides WebSockets
161- using Flask, Flask-SocketIO and gevent.
140+ * [ Flask-SocketIO] ( https://flask-socketio.readthedocs.io/en/latest/ ) is
141+ a [ Flask] ( /flask.html ) extension that relies upon eventlet or gevent to
142+ create server-side WebSockets connections.
162143
144+ * [ websocket-client] ( https://github.com/websocket-client/websocket-client )
145+ provides low level APIs for WebSockets and works with both
146+ [ Python 2 and 3] ( /python-2-or-3.html ) .
163147
164- ## General WebSockets resources
165- WebSockets have wide browser support and therefore many
166- [ web frameworks] ( /web-frameworks.html ) across all major programming languages
167- have libraries to make creating WebSockets connections easier. The following
168- resources are general guides and tutorials that provide context for the
169- protocol without getting into the weeds of how to use WebSockets in
170- Python.
148+ * [ Crossbar.io] ( http://crossbar.io/ ) builds upon Autobahn and includes a
149+ separate server for handling the WebSockets connections if desired by
150+ the web app developer.
171151
172- * The official W3C
173- [ candidate draft for WebSockets API] ( http://www.w3.org/TR/websockets/ )
174- and the
175- [ working draft for WebSockets] ( http://dev.w3.org/html5/websockets/ ) are
176- good reference material but can be tough for those new to the WebSockets
177- concepts. I recommend reading the working draft after looking through some
178- of the more beginner-friendly resources list below.
179152
180- * [ WebSockets 101] ( http://lucumr.pocoo.org/2012/9/24/websockets-101/ ) by
181- Armin Ronacher provides a detailed assessment of the subpar state of HTTP
182- proxying in regards to WebSockets. He also discusses the complexities of
183- the WebSockets protocol including the packet implementation.
153+ ## JavaScript client libraries
154+ JavaScript is used to create the client side of the WebSocket connection
155+ because the client is typically a web browser. While you do not need one
156+ of these client-side libraries to use WebSockets, they are useful for
157+ minimizing the amount of boilerplate code to establish and handle your
158+ connections.
184159
185- * The "Can I Use?" website has a
186- [ handy WebSockets reference chart] ( http://caniuse.com/#feat=websockets )
187- for which web browsers and specific versions support WebSockets.
160+ * [ Socket.io] ( http://socket.io/ ) 's client side JavaScript library can be
161+ used to connect to a server side WebSockets implementation.
188162
189- * Mozilla's
190- [ Developer Resources for WebSockets] ( https://developer.mozilla.org/en-US/docs/WebSockets )
191- is a good place to find documentation and tools for developing with
192- WebSockets.
163+ * [ web-socket-js] ( https://github.com/gimite/web-socket-js ) is a Flash-based
164+ client-side WebSockets implementation.
165+
166+ * [ AutobahnJS] ( https://github.com/crossbario/autobahn-js ) assists on the
167+ client web browser side.
193168
194- * [ WebSockets from Scratch] ( https://blog.pusher.com/websockets-from-scratch/ )
195- gives a nice overview of the protocol then shows how the lower-level pieces
196- work with WebSockets, which are often a black box to developers who only
197- use libraries like Socket.IO.
198169
199- * [ websocketd] ( http://websocketd.com/ ) is a WebSockets server aiming to be
200- the "CGI of WebSockets". Worth a look.
170+ ### Example code for WebSockets in Python
171+ There are numerous Python-based implementations for WebSockets so sometimes
172+ it's just easiest to examine an example so you can build something for your
173+ own project.
174+
175+ * The Flask-SocketIO project has a
176+ [ chat web application] ( https://github.com/miguelgrinberg/Flask-SocketIO/tree/master/example )
177+ that demos sending server generated events as well as input from users
178+ via a text box input on a form.
179+
180+ * The
181+ [ python-websockets-example] ( https://github.com/mattmakai/python-websockets-example )
182+ contains code to create a simple web application that provides WebSockets
183+ using Flask, Flask-SocketIO and gevent.
201184
202185
203- ## Python-specific WebSockets resources
186+ ### Python-specific WebSockets resources
204187* The
205188 "[ Async Python Web Apps with WebSockets & gevent] ( https://youtu.be/L5YQbNrFfyw ) "
206189 talk I gave at San Francisco Python in January 2015 is a live-coded example
@@ -247,6 +230,51 @@ Python.
247230 and Socket.IO to update values between web browser clients when changes
248231 occur.
249232
233+
234+ ## General WebSockets resources
235+ WebSockets have wide browser support and therefore many
236+ [ web frameworks] ( /web-frameworks.html ) across all major programming languages
237+ have libraries to make creating WebSockets connections easier. The following
238+ resources are general guides and tutorials that provide context for the
239+ protocol without getting into the weeds of how to use WebSockets in
240+ Python.
241+
242+ * The official W3C
243+ [ candidate draft for WebSockets API] ( http://www.w3.org/TR/websockets/ )
244+ and the
245+ [ working draft for WebSockets] ( http://dev.w3.org/html5/websockets/ ) are
246+ good reference material but can be tough for those new to the WebSockets
247+ concepts. I recommend reading the working draft after looking through some
248+ of the more beginner-friendly resources list below.
249+
250+ * [ WebSockets 101] ( http://lucumr.pocoo.org/2012/9/24/websockets-101/ ) by
251+ Armin Ronacher provides a detailed assessment of the subpar state of HTTP
252+ proxying in regards to WebSockets. He also discusses the complexities of
253+ the WebSockets protocol including the packet implementation.
254+
255+ * The "Can I Use?" website has a
256+ [ handy WebSockets reference chart] ( http://caniuse.com/#feat=websockets )
257+ for which web browsers and specific versions support WebSockets.
258+
259+ * Mozilla's
260+ [ Developer Resources for WebSockets] ( https://developer.mozilla.org/en-US/docs/WebSockets )
261+ is a good place to find documentation and tools for developing with
262+ WebSockets.
263+
264+ * [ WebSockets from Scratch] ( https://blog.pusher.com/websockets-from-scratch/ )
265+ gives a nice overview of the protocol then shows how the lower-level pieces
266+ work with WebSockets, which are often a black box to developers who only
267+ use libraries like Socket.IO.
268+
269+ * [ websocketd] ( http://websocketd.com/ ) is a WebSockets server aiming to be
270+ the "CGI of WebSockets". Worth a look.
271+
272+ * [ How WebSockets Work – With Socket.io Demo] ( https://thesocietea.org/2016/04/how-websockets-work-with-socket-io-demo/ )
273+ walks through the HTTP-to-WebSocket upgrade handshake and explains a
274+ bit about how WebSockets work. The provided code is NodeJS on the backend
275+ but the SocketIO client side JavaScript is the same as you would implement
276+ in a Python-backed web application.
277+
250278* [ Can WebSockets and HTTP/2 Co-exist?] ( http://www.infoq.com/articles/websocket-and-http2-coexist )
251279 compares and contrasts the two protocols and shows how they have
252280 differences which will likely lead to WebSockets sticking around for
@@ -256,3 +284,8 @@ Python.
256284 is a video on WebSockets basics and using the
257285 [ Socket.io] ( https://github.com/socketio/socket.io ) JavaScript library
258286 to wrap WebSockets functionality in web browsers.
287+
288+ * [ Benchmarking and Scaling WebSockets: Handling 60000 concurrent connections] ( http://kemalcr.com/blog/2016/11/13/benchmarking-and-scaling-websockets-handling-60000-concurrent-connections/ )
289+ is a detailed examination of how WebSockets connections can scale to tens
290+ of thousands of users.
291+
0 commit comments