Sorry in advance if any of what I say sounds dumb, I don’t have any experience working with servers in any capacity.
I’m having trouble deploying a bokeh server on my local IP address that allows multiple users to use it (who are on the same network) at the same time. I’m using Flask and based it off the flask example on github. I’m trying to allow multiple users to use the application off the link “IP:5001,” where I’m referring to my IP address as IP here for security purposes. It allows a user to use it who is not me but doesn’t allow multiple users to use at the same time. I would’ve thought to increase the number of processes beyond 1 but I’m on a windows machine so was looking for some help on how to do this because I’m such a newbie with this stuff. I tried to use the gunicorn example but I’m on anaconda and there were no anaconda repositories for asyncio that work in Windows 64 bit. Thanks so much in advance for any help.
The bokeh server example flask_embed.py,which uses the Flask development server, from which your app is derived works well with several users on an internal network using the server’s IP address instead of localhost just as you’ve done.
As a starting point, I would confirm that works as expected for multiple concurrent users in your network environment.
If so, you should probably next inspect the differences between your application and the illustrative one in flask_embed.py.
As the bokeh server is single-threaded, is your tabs model doing anything in a blocking mode? If so, you’ll want to go through the bokeh server documentation on how to have a thread for any necessary blocking opeations, etc.
Not sure what you mean by blocking mode. I’m now trying to use the waitress package to do it, on a modification of the “gunicorn” example. Should it work to use waitress with the traditional flask example to allow for multiple users? I do think the issue is the single thread because I need multiple users to be able to use it at once. I’m really lacking some understanding with respect to what is supposed to be happening here.
Can you run the flask_embed.py example as is, with the small exception to change the localhost to your IP? And then try to have multiple concurrent users? That works fine for several users under the Flask development server with only one process.
By blocking mode, I mean that your code is running an operation or function that causes the server to wait on input from a user such that it cannot do anything else like service requests coming in from other users to update their session(s).
No functions should be blocking. And the flask example doesn’t work as is for multiple users on my company’s network. That’s what I was using originally before trying to use waitress and asyncio to address the fact that it didn’t work.
What is the nature of it not working? Are there any printouts in the server terminal window when different users attempt to use the app?
Can you run from one computer with multiple browsers or browser tabs? If so that might rule out the software and point to something in your network topology.
Okay. The devs might have some input on why the websockets are being closed perhaps related to the implementation of things in Windows, which I do not use.
I do not have any experience with waitress, but the first thing I would check is that embed.html used by render_template is in the place that waitress expects. Does it look for this in the templates directory?
You can also use the JavaScript console for your client’s browser to see if there are any error logs there to see what is going on. Each browser is different, but for Chrome, right-click, select Inspect, and then activate the Console tab to see the JavaScript console.
Yes, embed is in templates folder. It worked fine when running on my IP. Now when using computer_name.network.com:port instead, it doesn’t seem to be recognizing it. Before, it would also load the html from my embed before loading the bokeh script. Now all of it loads when the url is put in the browser before showing any html
That’s fine. You can access the JavaScript console from Firefox too. CTRL+SHIFT+J or COMMAND+SHIFT+J (on Mac).
That might give some insight into why the rendering is not happening in the client’s browser assuming there are no errors related to it in the server console.
One additional thought… Given the claim that waitress is essentially a Windows equivalent to gunicorn for Unix operating systems, you might want to model your application on the bokeh flask_gunicorn_embed.py example on GitHub. The details of how this sets up/coordinates the server, IOLoop, and Tornado server might be relevant.
That’s what I’ve been trying to do. I’ve had success having multiple users use it at the same time, just not with also using an HTML template. The HTML template loads when I remove t.join() from above but in that case it seems to interpret the html file as a javascript file because I’m getting a syntax error of “<”
Here’s a version that works with waitress. I essentially modified the flask_gunicorn_embed.py example from bokeh’s GitHub by adding the APP_SERVER_ADDR and APP_SERVER_PORT variables.
I run it using the waitress-serve command line option as follows.