Bokeh serve session but no connection?

I’m trying to launch a bokeh serve application myapp.py from here on a remote machine. It’s the same Ubuntu 22.04 OS as my local machine with the most recent python 3.10.6 and bokeh 3.2.1 and chrome.

bokeh serve apps run correctly locally but not remotely. there are no errors displayed, even with debug log level on the bokeh serve command line:

bokeh serve --allow-websocket-origin='*' --log-level=debug myapp.py

It’s somehow able to create a bokeh serve session but without a connection. Here is the debug output:

2023-07-21 15:31:39,058 [pid 13578] 0 clients connected
2023-07-21 15:31:39,058 [pid 13578]   /myapp has 1 sessions with 1 unused

How can bokeh serve create a session without a connection???

I’m ssh’ed in to run the bokeh serve command but am not using the ssh tunnels. I don’t want tunnels. Bokeh serve presents a web page so the standard http interface should work:

http://remoteIpAddress:5006/myapp

Something isn’t working correctly here. What’s going on or how can this be debugged?

There is no firewall on the remote machine. It’s a droplet machine from digitalocean.com

Please provide more information, i.e. the entire console log, as well as any information from the browser JavaScript console log. “1 session with 1 unused” generally means there was a connection, but it is not longer active, and its session is slated to be destroyed on the next run of the cleanup task.

Confirmed.

There had to be a connection at some point but it got destroyed within a second or so. There’s no extended delay between the session count increasing from 0-to-1 and the number of client counts (that remained at zero).

test output was from filename myapp2.py but have since renamed to myapp.py

Here’s an attempt at the debugging console output. I pressed return a few times to space out startup output from the timed debug output:

    comperem@ubuntu-s-1vcpu-512mb-10gb-nyc1-01:~/bokeh$ 
    comperem@ubuntu-s-1vcpu-512mb-10gb-nyc1-01:~/bokeh$ bokeh serve --allow-websocket-origin='*' --log-level=debug myapp2.py 
    2023-07-21 15:30:23,584 Starting Bokeh server version 3.2.1 (running on Tornado 6.3.2)
    2023-07-21 15:30:24,043 Host wildcard '*' will allow connections originating from multiple (or possibly all) hostnames or IPs. Use non-wildcard values to restrict access explicitly
    2023-07-21 15:30:24,044 User authentication hooks NOT provided (default user enabled)
    2023-07-21 15:30:24,045 These host origins can connect to the websocket: ['*']
    2023-07-21 15:30:24,045 Patterns are:
    2023-07-21 15:30:24,046   [('/favicon.ico',
    2023-07-21 15:30:24,046     <class 'bokeh.server.views.ico_handler.IcoHandler'>,
    2023-07-21 15:30:24,046     {'app': <bokeh.server.tornado.BokehTornado object at 0x7f1b01088880>}),
    2023-07-21 15:30:24,046    ('/myapp2/?',
    2023-07-21 15:30:24,047     <class 'bokeh.server.views.doc_handler.DocHandler'>,
    2023-07-21 15:30:24,047     {'application_context': <bokeh.server.contexts.ApplicationContext object at 0x7f1b01088d30>,
    2023-07-21 15:30:24,047      'bokeh_websocket_path': '/myapp2/ws'}),
    2023-07-21 15:30:24,047    ('/myapp2/ws',
    2023-07-21 15:30:24,047     <class 'bokeh.server.views.ws.WSHandler'>,
    2023-07-21 15:30:24,047     {'application_context': <bokeh.server.contexts.ApplicationContext object at 0x7f1b01088d30>,
    2023-07-21 15:30:24,047      'bokeh_websocket_path': '/myapp2/ws',
    2023-07-21 15:30:24,047      'compression_level': None,
    2023-07-21 15:30:24,047      'mem_level': None}),
    2023-07-21 15:30:24,047    ('/myapp2/metadata',
    2023-07-21 15:30:24,047     <class 'bokeh.server.views.metadata_handler.MetadataHandler'>,
    2023-07-21 15:30:24,048     {'application_context': <bokeh.server.contexts.ApplicationContext object at 0x7f1b01088d30>,
    2023-07-21 15:30:24,048      'bokeh_websocket_path': '/myapp2/ws'}),
    2023-07-21 15:30:24,048    ('/myapp2/autoload.js',
    2023-07-21 15:30:24,048     <class 'bokeh.server.views.autoload_js_handler.AutoloadJsHandler'>,
    2023-07-21 15:30:24,048     {'application_context': <bokeh.server.contexts.ApplicationContext object at 0x7f1b01088d30>,
    2023-07-21 15:30:24,048      'bokeh_websocket_path': '/myapp2/ws'}),
    2023-07-21 15:30:24,048    ('/myapp2/static/(.*)',
    2023-07-21 15:30:24,048     <class 'bokeh.server.views.static_handler.StaticHandler'>,
    2023-07-21 15:30:24,048     {}),
    2023-07-21 15:30:24,048    ('/?',
    2023-07-21 15:30:24,048     <class 'bokeh.server.views.root_handler.RootHandler'>,
    2023-07-21 15:30:24,049     {'applications': {'/myapp2': <bokeh.server.contexts.ApplicationContext object at 0x7f1b01088d30>},
    2023-07-21 15:30:24,049      'index': None,
    2023-07-21 15:30:24,049      'prefix': '',
    2023-07-21 15:30:24,049      'use_redirect': True}),
    2023-07-21 15:30:24,049    ('/static/extensions/(.*)',
    2023-07-21 15:30:24,049     <class 'bokeh.server.views.multi_root_static_handler.MultiRootStaticHandler'>,
    2023-07-21 15:30:24,049     {'root': {}}),
    2023-07-21 15:30:24,049    ('/static/(.*)',
    2023-07-21 15:30:24,049     <class 'bokeh.server.views.static_handler.StaticHandler'>)]
    2023-07-21 15:30:24,055 Bokeh app running at: http://localhost:5006/myapp2
    2023-07-21 15:30:24,056 Starting Bokeh server with process id: 13578




    2023-07-21 15:30:39,059 [pid 13578] 0 clients connected
    2023-07-21 15:30:39,059 [pid 13578]   /myapp2 has 0 sessions with 0 unused
    2023-07-21 15:30:54,070 [pid 13578] 0 clients connected
    2023-07-21 15:30:54,070 [pid 13578]   /myapp2 has 0 sessions with 0 unused
    2023-07-21 15:31:09,065 [pid 13578] 0 clients connected
    2023-07-21 15:31:09,065 [pid 13578]   /myapp2 has 0 sessions with 0 unused
    2023-07-21 15:31:24,066 [pid 13578] 0 clients connected
    2023-07-21 15:31:24,066 [pid 13578]   /myapp2 has 0 sessions with 0 unused
    2023-07-21 15:31:39,058 [pid 13578] 0 clients connected
    2023-07-21 15:31:39,058 [pid 13578]   /myapp2 has 1 sessions with 1 unused
    2023-07-21 15:31:49,068 Scheduling 1 sessions to discard
    2023-07-21 15:31:49,068 Discarding session 'f5sPXcHno36hj76N8w8I7Ft8NVZwnjSj9g1hs53WY47N' last in use 22934.424352005124 milliseconds ago
    2023-07-21 15:31:49,068 Deleting 1 modules for document <bokeh.document.document.Document object at 0x7f1afef40be0>
    2023-07-21 15:31:54,061 [pid 13578] 0 clients connected
    2023-07-21 15:31:54,061 [pid 13578]   /myapp2 has 0 sessions with 0 unused
    2023-07-21 15:32:09,060 [pid 13578] 0 clients connected
    2023-07-21 15:32:09,060 [pid 13578]   /myapp2 has 0 sessions with 0 unused
    ^C
    Interrupted, shutting down
    2023-07-21 15:32:15,743 Shutdown: cleaning up
    comperem@ubuntu-s-1vcpu-512mb-10gb-nyc1-01:~/bokeh$ 
    comperem@ubuntu-s-1vcpu-512mb-10gb-nyc1-01:~/bokeh$ 

@comperem It is still unclear: are you navigating to the server URL (and it is failing)? Or not navigating there at all? If the former, what is shown in the browser console?

Yes, I’m accessing the server ip address with the correct port and application name in a chrome browser and nothing is being displayed. Blank white empty chrome page with that previous output at the console on the machine running.

The same app and same bokeh serve command works fine on the local machine with similar output except the page renders and the connection count changes from 0 to 1, as expected.

Can you please provide the JS console output from the browser?

Yes, certainly.

Here’s what I’ve found. I’ve never debugged via the browser console before.

The browser bar has the ip address in it but the error messages all have localhost in their messages.

It looks like a connection error. Bokeh can see something happen enough to create a session, but the connection is refused, which means it cannot continue.

This is a different view of the same instance.

singlefile.js seems to be involved

This was a recent bug. It is fixed in version 3.2.1 released a few days ago. Alternatively, you can specify BOKEH_RESOURCES=cdn to load BokehJS from cdn.bokeh.org which I would recommend for “production” usage in any case (assuming your users are not on an air-gapped network).

Hm, well, ok. These results are all using Bokeh 3.2.1.

I’ll try the BOKEH_RESOURCES option you mentioned.

Thank you @Bryan.

The app worked as-expected from the DigitalOcean.com droplet vm after running this in the bash console:

BOKEH_RESOURCES=cdn ; export BOKEH_RESOURCES

then:

bokeh serve --allow-websocket-origin='*' --log-level=debug myapp.py

The export command was necessary. Didn’t work without it. Afterwards, just fine.

Solved.

Hm, well, ok. These results are all using Bokeh 3.2.1.

I was mistaken, the issue is still open

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.