Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Serve application at random port failed #10175

Closed
xavArtley opened this issue Jun 16, 2020 · 3 comments · Fixed by #10178
Closed

[BUG] Serve application at random port failed #10175

xavArtley opened this issue Jun 16, 2020 · 3 comments · Fixed by #10178

Comments

@xavArtley
Copy link
Contributor

xavArtley commented Jun 16, 2020

Hello,

since Bokeh 2.1.0 (windows 10), trying to serve an application with random port (--port=0) does not work anymore and result in the following error:

(py37) D:\PythonWorkspace\divers>bokeh serve C:\Users\xa235208\Downloads\bokeh-master\examples\app\sliders.py --show --port=0
2020-06-16 09:39:45,845 Starting Bokeh server version 2.1.0 (running on Tornado 6.0.4)
2020-06-16 09:39:45,847 User authentication hooks NOT provided (default user enabled)
2020-06-16 09:39:45,850 Bokeh app running at: http://localhost:61622/sliders
2020-06-16 09:39:45,850 Starting Bokeh server with process id: 14652
2020-06-16 09:39:46,587 Refusing websocket connection from Origin 'http://localhost:61622';                       use --allow-websocket-origin=localhost:61622 or set BOKEH_ALLOW_WS_ORIGIN=localhost:61622
to permit this; currently we allow origins {'localhost:0'}
@xavArtley xavArtley changed the title [BUG] [BUG] Serve appication at random port failed Jun 16, 2020
@xavArtley xavArtley changed the title [BUG] Serve appication at random port failed [BUG] Serve application at random port failed Jun 16, 2020
@bryevdv
Copy link
Member

bryevdv commented Jun 16, 2020

If this is local usage then --allow-websocket-origin="*" is a potential workaround for now. Not sure when/how this got introduced.

@bryevdv
Copy link
Member

bryevdv commented Jun 16, 2020

Most likely it was this PR #10070 the port added to the allowlist is the original passed-in opts.port, not the value returned from bind_sockets

https://github.com/bokeh/bokeh/pull/10070/files#diff-35e262b3fd4a971d380038e009fd69acR398

@bryevdv
Copy link
Member

bryevdv commented Jun 16, 2020

This diff fixes, but any PR needs to come with a test

diff --git a/bokeh/server/server.py b/bokeh/server/server.py
index 78f19bbe8..97eec3965 100644
--- a/bokeh/server/server.py
+++ b/bokeh/server/server.py
@@ -395,7 +395,7 @@ class Server(BaseServer):
         sockets, self._port = bind_sockets(opts.address, opts.port)
         self._address = opts.address

-        extra_websocket_origins = create_hosts_allowlist(opts.allow_websocket_origin, opts.port)
+        extra_websocket_origins = create_hosts_allowlist(opts.allow_websocket_origin, self.port)
         try:
             tornado_app = BokehTornado(applications,
                                        extra_websocket_origins=extra_websocket_origins,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants