简体   繁体   中英

Bokeh Server on IIS Setup

I'm trying to figure out how to deploy a Bokeh slider chart over an IIS server. I recently finished up a Flask application, so I figured I'd try the route where you embed through flask:

https://github.com/bokeh/bokeh/tree/master/examples/howto/server_embed

It's nice and easy when I launch the script locally.. but I can't seem to set it up properly over IIS. I believe the complexity is stemming from the fact that the wfastcgi.py module I'm using to deploy over IIS can't easily multi-thread without some sort of hack-like work around.

So, my second attempt was to wrap the flask app in tornado as below OPTION B (without much success, but still think this is my best lead here)

Run Flask as threaded on IIS 7

My third attempt was to try and run Bokeh server standalone on a specific port. I figured I'd be able to run the server via standalone_embed.py using wfastcgi.py on say port 8888 & while using port 5000 for the server callbacks. However, the Server function:

from bokeh.server.server import Server

still launches it locally on the host machine

server = Server({'/': bokeh_app}, io_loop=io_loop, port=5000)
server.start()

So this actually works if I go to http://localhost:5000/ on the host, but fails if I go to http://%my_host_ip%:5000/ from a remote machine.

I even tried manually setting the host but get an "invalid host" error:

server = Server({'/': bokeh_app}, io_loop=io_loop, host='%my_host_ip_address_here%:5000')
server.start()

ERR:

Error occurred while reading WSGI handler: Traceback (most recent call last): File "C:\\Python34\\lib\\site-packages\\bokeh\\server\\server.py", line 45, in _create_hosts_whitelist int(parts[1]) ValueError: invalid literal for int() with base 10: '' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\\WebsitesFlask\\bokehTest\\wfastcgi.py", line 711, in main env, handler = read_wsgi_handler(response.physical_path) File "C:\\WebsitesFlask\\bokehTest\\wfastcgi.py", line 568, in read_wsgi_handler return env, get_wsgi_handler(handler_name) File "C:\\WebsitesFlask\\bokehTest\\wfastcgi.py", line 537, in get_wsgi_handler handler = import (module_name, fromlist=[name_list[0][0]]) File ".\\app.py", line 41, in server = Server({'/': bokeh_app}, io_loop=io_loop, host='%my_host_ip_address_here%:5000') File "C:\\Python34\\lib\\site-packages\\bokeh\\server\\server.py", line 123, in init tornado_kwargs['hosts'] = _create_hosts_whitelist(kwargs.get('host'), self._ port) File "C:\\Python34\\lib\\site-packages\\bokeh\\server\\server.py", line 47, in _create_hosts_whitelist raise ValueError("Invalid port in host value: %s" % host) ValueError: Invalid port in host value: : StdOut: StdErr:

First off, the --host parameter should no longer be needed in the next 0.12.5 release. It's probably been the most confusing stumbling block for people trying to deploy a Bokeh server app in a "production" environment. You can follow the discussion on this issue on GitHub for more details.


Looking at the actual implementation in Bokeh that generates the error you are seeing, it is just this:

parts = host.split(':')
if len(parts) == 1:
    if parts[0] == "":
        raise ValueError("Empty host value")
    hosts.append(host+":80")
elif len(parts) == 2:
    try:
        int(parts[1])
    except ValueError:
        raise ValueError("Invalid port in host value: %s" % host)

The exception you are reporting that states that int(parts[1]) is failing:

Traceback (most recent call last): 
File "C:\Python34\lib\site-packages\bokeh\server\server.py", line 45, 
in _create_hosts_whitelist int(parts[1]) 
ValueError: invalid literal for int() with base 10:

So, there is something amiss with the string you are passing for hosts that's causing the part after the colon to not be able to be converted to in int But without seeing the actual string, it's impossible to say much more. Maybe there is some encoding issue that needs to be handled differently or better. If you can provide a concrete string example that reproduces the problem I can take a closer look.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM