How to run functions outside websocket loop in python (tornado)

You could call a IOLoop.add_timeout(deadline, callback) that calls the callback at specified deadline timeout (one shot, but you can reschedule), or use the tornado.ioloop.PeriodicCallback if you have a more periodic task. See: http://www.tornadoweb.org/en/stable/ioloop.html#tornado.ioloop.IOLoop.add_timeout Update: some example import datetime def test(): print “scheduled event fired” … if __name__ == “__main__”: http_server = tornado.httpserver.HTTPServer(application) http_server.listen(8888) main_loop = … Read more

Best approach to get RTSP streaming into web browser from IP Camera?

Here is a blog entry, or tutorial if you will, that achieves something very similar. Their setup slightly different, but this is the summary: use ffmpeg to convert your input into mpeg1video: ffmpeg -i rtsp://whatever -f mpeg1video -b 800k -r 30 http://localhost:8082/yourpassword/640/480/ Install node.js with stream-server.js script from jsmpeg and ws ws WebSocket package. To … Read more

Must websockets have heartbeats?

The RFC 6455, the current reference for the WebSocket protocol, defines some control frames to communicate state about the WebSocket: Close: 0x8 Ping: 0x9 Pong: 0xA Ping and Pong are used for heartbeat and allows you to check if the client is still responsive. See the quote below: A Ping frame may serve either as … Read more

How to debug websocket connection error with “Unknown reason”

Looks like someone just filed this as a Chromium (v77) bug. See issue tracking it here. Update 1: As noted in the issue tracker and comments below, this should now be fixed in the latest stable release, which is being rolled out now (2019/10/11). Update 2: Despite the bug being marked as fixed/closed in monorail, … Read more

WebSockets authentication

If you’re already doing authentication for the non-websocket part of your app, just pass the session cookie along as the first message after connecting and check the cookie as you normally would. WARNING: It’s been pointed out that the following doesn’t work when flashsockets are used: If you’re using socket.io, it’s even easier—the cookies are … Read more