D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
ikatson
Full window
Github gist
uwsgi + harakiri + websockets bug
<html> <head> <script> var polling = (function () { var poll_error_timeout = 1; var default_error_timeout = poll_error_timeout + 0; var poll_error_max_timeout = 15; function pollForEventsWebsockets() { var s = new WebSocket('ws://localhost:8000/ws'); var retry = function () { console.log( 'retrying websocket connection in ' + poll_error_timeout); setTimeout(pollForEventsWebsockets, poll_error_timeout * 1000); poll_error_timeout = Math.min( poll_error_max_timeout, poll_error_timeout * 2); }; s.onopen = function() { console.log("Websocket connected"); poll_error_timeout = default_error_timeout; }; s.onmessage = function(e) { console.log('Received message', e.data); poll_error_timeout = default_error_timeout; }; s.onerror = function(e) { console.error(e); }; s.onclose = function(e) { console.log('ws connection closed'); retry(); }; } pollForEventsWebsockets(); return {} }()); </script> </head> <body> </body> </html>