I'm building a dashboard in Holoviews and try to serve it with panel.serve() from Jupyter notebook. It is working fine on my local computer, but I need to share it with other computers in my corporate network so people can actually use it. I can't deploy it to Heroku or something like that due to privacy concerns. Here is the sample code:
import panel as pn
pn.extension()
dashboard_title = pn.panel('## Test Dashboard')
dashboard_footlote = pn.panel('Test Test Test')
dash = pn.Column(dashboard_title, dashboard_footlote)
dash.servable(title="Claims Dashboard")
pn.serve(dash)
When I run it in the Jupyter notebook it opens a new browser window and the dashboard in it. I tried accessing that same dashboard from the other computer by typing http://10.80.60.31:60840/ in the address bar. But that does not show anything. And in Jupyter cell I get the following error:
ERROR:bokeh.server.views.ws:Refusing websocket connection from Origin 'http://10.80.40.41:60840';
use --allow-websocket-origin=10.80.40.41:60840 or set BOKEH_ALLOW_WS_ORIGIN=10.80.40.41:60840 to permit this; currently we allow origins {'localhost:60840'}
I tried changing the last line in my code to the following:
pn.serve(dash, websocket_origin=['10.80.60.31:60840','localhost:60840'])
But then it does not work even locally because the port changes. It gives me an error:
ERROR:bokeh.server.views.ws:Refusing websocket connection from Origin 'http://localhost:58370';
use --allow-websocket-origin=localhost:58370 or set BOKEH_ALLOW_WS_ORIGIN=localhost:58370 to permit this; currently we allow origins {'localhost:60840', '10.80.60.31:60840'}
If I try to assign a specific port like this:
pn.serve(dash, port = 60840, websocket_origin=['10.80.60.31:60840','localhost:60840'])
It does not even start saying:
OSError: [WinError 10048] Only one usage of each socket address (protocol/network address/port) is normally permitted
The solution might be simple but I know very little about all network stuff and I don't even know what to google.
I'd appreciate it if you could guide me on how to make it work.
I use pn.serveable(dash) in the .py file and then launch panel serve --port 8086 file.py separately, but I assume that would work similarly to what you are doing. The typical "gotcha" is that you need to ensure that whatever port you are using is not being firewalled by your networking configuration, so that other computers can access it. You may need to add an exception to your machine's firewall rules to open up a specific port. You can test that using any program on that port (a web server, ssh client, telnet client, etc.); panel's server doesn't have any special requirements in that regard. There are a lot of details at https://docs.bokeh.org/en/latest/docs/user_guide/server.html#deployment-scenarios , but configuring your system not to block a certain port is something you'll have to work out with your IT department in a corporate setting.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With