bokeh server- rejected connection because host is not in whitelist

天大地大妈咪最大 提交于 2019-12-11 15:32:16

问题


I am trying to run a simple bokeh server script on my local machine:

#app.py
from bokeh.io import curdoc
from bokeh.models import ColumnDataSource
from bokeh.plotting import figure
from random import randrange
#create figure
f=figure(x_range=(0,11),y_range=(0,11))

#create columndatasource
source=ColumnDataSource(data=dict(x=[],y=[]))

#create glyphs
f.circle(x='x',y='y',size=8,fill_color='olive',line_color='yellow',source=source)

#create periodic function
def update():
    new_data=dict(x=[randrange(1,10)],y=[randrange(1,10)])
    source.stream(new_data,rollover=15)
    print(source.data)

#add figure to curdoc and configure callback
curdoc().add_root(f)
curdoc().add_periodic_callback(update,1000)`

On the command line I tried various combinations of:

bokeh serve app.py bokeh serve app.py --port 5100 bokeh serve app.py --host * bokeh serve app.py --allow-websocket-origin=127.0.0.1:80

they all return a message saying the host was rejected because it is not on the whitelist. I am running windows. What is going wrong?

Hilariously, I actually got it working before lunch. After rewarding myself with food, it stopped working and I have not been able to get it since. I believe the working combination used --port and --allow-websocket


回答1:


First things first, if you just run

bokeh serve --show app.py 

Then Bokeh will automatically raise a browser window opened to the correct URL. The deafult URL would be

http://localhost:5006/app

Note that's localhost and not 127.0.0.1

A few other notes:

  • --allow-websocket-origin is only needed if you are embedding a Bokeh app in a different, separate website with its own address. It is not need just to view locally.

  • The (confusing) --host parameter was deprecated and removed (perhaps you have an old version?) but would also not be needed to view locally

  • --address tells the Bokeh server which network addresses to listen on, again not typically needed for local.

  • --port tells the Bokeh server what network port to listen on rather than the default port of 5006. E.g.

    bokeh serve --port 8080 --show app.py 
    

    would result in an app accessible here:

    http://localhost:8080/app
    

If this does not help then more information is needed. Specifically, the exact error messages, which you have not provided, or some indication of what URL you are actually trying to navigate to (since that is half of the issue).




回答2:


the answer is version control. Tornado 4.4.2 worked but 4.5.3 did not



来源:https://stackoverflow.com/questions/48533745/bokeh-server-rejected-connection-because-host-is-not-in-whitelist

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!