How can I use the Tornado parameters websocket_ping_interval and websocket_ping_timeout?


i have a question regarding the Tornado parameters websocket_ping_interval and websocket_ping_timeout. I would like to set these parameters the easiest way possible.
I have a Bokeh application which I start from a different python program with

self._bokeh_process = subprocess.Popen(['/usr/bin/python', '-m', 'bokeh', 'serve', self._bokeh_directory,
                                   '--unused-session-lifetime', '99999999999',
                                    '-log-level' , 'trace'],

For a special problem I need to set the tornado parameters websocket_ping_interval and websocket_ping_timeout because I have to check if a websocket is still active/valid. If I set these parameters manually in the code of Tornado (in the class Application in I can solve my problem. So could you please help me and tell me if there is a easy way to set these two parameters while using “bokeh serve”?

If there is no easy way would you think that it would be good idea to implement these parameters like websocket_max_message_size? I am thinking about contributing to the Bokeh project and I think it is a good way to start. Nonetheless it would be great if there is a solution for my problem which I can use right now.

Thank you very much in advance.

With best regards

@mabo These parameters are not currently exposed to the CLI, so the only solution (as I think you have discovered) is to use the Bokeh server programmatically, as a library. I think the interest and use case for manipulating these values is fairly narrow. However if you wanted to submit a PR to expose --websocket-ping-timeout and --websocket-ping-interval at the CLI level in a similar fashion to --websocket-max-message-size, we could definitely consider it.

I will say that as Bokeh drops support for Python <=3.5 in the near future, there is some possibility that we eventually move away from depending on Tornado, and just use asyncio directly. At least, there are some core devs who have expressed interest in investigating that. So a risk with adding these options is that they are coupled very specifically to an assumption that Tornado is being used, and that may change at some point.

1 Like