Embedded Bokeh Server within Flask + Apache+Ubuntu

Hello
I am currently deploying a flask app with an embedded bokeh server on apache over ubuntu, but I have some issues:

If I define a proxy in apache, bokeh server responds ok rendering an html with all the charts, tables and widgets but without the flask app layout, it bypasses the flask app! .

If I do not define a proxy/reverseproxy in apache , I get either a "Failed to load resource: net::ERR_CONNECTION_TIMED_OUT " if I use my server IP in the url when calling server_document:

 
@bokehs.route("/bokeh", methods=[‘GET’])
@login_required
def bokeh():
   script = server_document(url=‘http://52.251.xxx.xxx:5006/bkapp’)
   return render_template(“embed.html”, script=script)

if I use instead 127.0.0.1 or localhost in script = server_document(url=‘http://127.0.0.1:5006/bkapp’) , I get the error :

bokeh:74 GET http://localhost:5006/bkapp/autoload.js?bokeh-autoload-element=1325&bokeh-app-path=/bkapp&bokeh-absolute-url=http://localhost:5006/bkapp net::ERR_CONNECTION_REFUSED

These are the two functions I use in order to define my embedded bokeh server within flask:

 
def bk_worker():
  server = Server(
      {’/bkapp’: run,
       ‘/grafos’: run_grafos
      },
     io_loop=IOLoop(),
     port=5006,
     allow_websocket_origin=["*"]
  )
 server.start()
 server.io_loop.start()

def create_app(config_class=Config):
    app = Flask(name)
    app.config.from_object(Config)
    db.init_app(app)
  bcrypt.init_app(app)
  login_manager.init_app(app)
  mail.init_app(app)

  from mutabis.bokeh.routes import bokehs
  from mutabis.users.routes import users

  app.register_blueprint(bokehs)
  app.register_blueprint(users)

  Thread(target=bk_worker).start()
  return app

the init.py file is :

 
from mutabis import create_app

app = create_app()

if __name__ == '__main__':
    app.run(debug=True)


I will appreciate any help or hint you could give me to solve this issue

Thanks

If the Bokeh server is refusing there connection there should be a console log message that has more information about why. If embedding as a library you may need to call bokeh.util.logging.basicConfig (not sure tho will have to just try)

Hello Bryan

On my local virtual environment ( flask with bokeh server as a library ) everything works fine, but when I deploy the flask app on apache-ubuntu I get the connection refused error as mentioned above.
I followed your suggestion and activated flask and bokeh logging. This is the file output I get:


11-23 20:46:48] p10249 {/var/www/html/mutabis/mutabis/__init__.py:119} INFO - Logging is set up.
[2020-11-23 20:46:48,867] p10249 {/var/www/html/mutabis/mutabis/__init__.py:119} INFO - Logging is set up.
[2020-11-23 20:46:49,019] p10249 {/usr/lib/python3.6/asyncio/selector_events.py:54} DEBUG - Using selector: EpollSelector
[2020-11-23 20:46:49,028] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/server.py:372} INFO - Starting Bokeh server version 2.2.3 (running on Tornado 6.1)
[2020-11-23 20:46:49,029] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/util.py:135} WARNING - Host wildcard '*' will allow connections originating from multiple (or possibly all) hostnames or IPs. Use non-wildcar
d values to restrict access explicitly
[2020-11-23 20:46:49,039] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:308} INFO - User authentication hooks NOT provided (default user enabled)
[2020-11-23 20:46:49,039] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:338} DEBUG - These host origins can connect to the websocket: ['*']
[2020-11-23 20:46:49,040] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:392} DEBUG - Patterns are:
[2020-11-23 20:46:49,041] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -   [('/bkapp/?',
[2020-11-23 20:46:49,041] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -     ,
[2020-11-23 20:46:49,041] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -     {'application_context': ,
[2020-11-23 20:46:49,041] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -      'bokeh_websocket_path': '/bkapp/ws'}),
[2020-11-23 20:46:49,041] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -    ('/bkapp/ws',
[2020-11-23 20:46:49,041] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -     ,
[2020-11-23 20:46:49,041] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -     {'application_context': ,
[2020-11-23 20:46:49,042] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -      'bokeh_websocket_path': '/bkapp/ws'}),
[2020-11-23 20:46:49,042] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -    ('/bkapp/metadata',
[2020-11-23 20:46:49,042] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -     ,
[2020-11-23 20:46:49,042] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -     {'application_context': ,
[2020-11-23 20:46:49,042] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -      'bokeh_websocket_path': '/bkapp/ws'}),
[2020-11-23 20:46:49,042] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -    ('/bkapp/autoload.js',
[2020-11-23 20:46:49,042] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -     ,
[2020-11-23 20:46:49,042] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -     {'application_context': ,
[2020-11-23 20:46:49,042] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -      'bokeh_websocket_path': '/bkapp/ws'}),
[2020-11-23 20:46:49,042] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -    ('/grafos/?',
[2020-11-23 20:46:49,042] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -     ,
[2020-11-23 20:46:49,042] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -     {'application_context': ,
[2020-11-23 20:46:49,048] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -      'bokeh_websocket_path': '/grafos/ws'}),
[2020-11-23 20:46:49,067] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -    ('/grafos/ws',
[2020-11-23 20:46:49,067] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -     ,
[2020-11-23 20:46:49,067] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -     {'application_context': ,
[2020-11-23 20:46:49,067] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -      'bokeh_websocket_path': '/grafos/ws'}),
[2020-11-23 20:46:49,067] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -    ('/grafos/metadata',
[2020-11-23 20:46:49,067] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -     ,
[2020-11-23 20:46:49,067] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -     {'application_context': ,
[2020-11-23 20:46:49,067] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -      'bokeh_websocket_path': '/grafos/ws'}),
[2020-11-23 20:46:49,067] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -    ('/grafos/autoload.js',
[2020-11-23 20:46:49,067] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -     ,
[2020-11-23 20:46:49,068] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -     {'application_context': ,
[2020-11-23 20:46:49,068] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -      'bokeh_websocket_path': '/grafos/ws'}),
[2020-11-23 20:46:49,068] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -    ('/?',
[2020-11-23 20:46:49,068] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -     ,
[2020-11-23 20:46:49,068] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -     {'applications': {'/bkapp': ,
[2020-11-23 20:46:49,068] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -                       '/grafos': },
[2020-11-23 20:46:49,068] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -      'index': None,
[2020-11-23 20:46:49,068] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -      'prefix': '',
[2020-11-23 20:46:49,068] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -      'use_redirect': True}),
[2020-11-23 20:46:49,068] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -    ('/static/extensions/(.*)',
[2020-11-23 20:46:49,068] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -     ,
[2020-11-23 20:46:49,068] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -     {'root': {}}),
[2020-11-23 20:46:49,068] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -    ('/static/(.*)',
[2020-11-23 20:46:49,068] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG -     )]
[11-23 20:46:52] p10248 {/var/www/html/mutabis/mutabis/__init__.py:119} INFO - Logging is set up.
[2020-11-23 20:46:52,977] p10248 {/var/www/html/mutabis/mutabis/__init__.py:119} INFO - Logging is set up.
[2020-11-23 20:46:53,088] p10248 {/usr/lib/python3.6/asyncio/selector_events.py:54} DEBUG - Using selector: EpollSelector
[2020-11-23 20:46:53,089] p10248 {/usr/local/lib/python3.6/dist-packages/bokeh/server/server.py:372} INFO - Starting Bokeh server version 2.2.3 (running on Tornado 6.1)
[2020-11-23 20:47:04,085] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:658} DEBUG - [pid 10249] 0 clients connected
[2020-11-23 20:47:04,085] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:666} DEBUG - [pid 10249]   /bkapp has 0 sessions with 0 unused
[2020-11-23 20:47:04,085] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:666} DEBUG - [pid 10249]   /grafos has 0 sessions with 0 unused
[2020-11-23 20:47:19,084] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:658} DEBUG - [pid 10249] 0 clients connected
[2020-11-23 20:47:19,085] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:666} DEBUG - [pid 10249]   /bkapp has 0 sessions with 0 unused
[2020-11-23 20:47:19,085] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:666} DEBUG - [pid 10249]   /grafos has 0 sessions with 0 unused
[2020-11-23 20:47:34,078] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:658} DEBUG - [pid 10249] 0 clients connected
[2020-11-23 20:47:34,078] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:666} DEBUG - [pid 10249]   /bkapp has 0 sessions with 0 unused
[2020-11-23 20:47:34,078] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:666} DEBUG - [pid 10249]   /grafos has 0 sessions with 0 unused
[2020-11-23 20:47:49,079] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:658} DEBUG - [pid 10249] 0 clients connected
[2020-11-23 20:47:49,079] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:666} DEBUG - [pid 10249]   /bkapp has 0 sessions with 0 unused
[2020-11-23 20:47:49,080] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:666} DEBUG - [pid 10249]   /grafos has 0 sessions with 0 unused
[2020-11-23 20:48:04,071] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:658} DEBUG - [pid 10249] 0 clients connected
[2020-11-23 20:48:04,071] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:666} DEBUG - [pid 10249]   /bkapp has 0 sessions with 0 unused
[2020-11-23 20:48:04,071] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:666} DEBUG - [pid 10249]   /grafos has 0 sessions with 0 unused
[2020-11-23 21:20:19,074] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:666} DEBUG - [pid 10249]   /bkapp has 0 sessions with 0 unused
[2020-11-23 21:20:19,074] p10249 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:666} DEBUG - [pid 10249]   /grafos has 0 sessions with 0 unused
[11-23 21:21:24] p10646 {/var/www/html/mutabis/mutabis/__init__.py:122} INFO - Logging is set up.
[2020-11-23 21:21:24,184] p10646 {/var/www/html/mutabis/mutabis/__init__.py:122} INFO - Logging is set up.
[11-23 21:21:38] p10647 {/var/www/html/mutabis/mutabis/__init__.py:122} INFO - Logging is set up.
[2020-11-23 21:21:38,435] p10647 {/var/www/html/mutabis/mutabis/__init__.py:122} INFO - Logging is set up.

 

I do not see any type of error at the server side …it seems to be more related to front-end issue, websockects maybe

if I compare this log to the one generated on my local env , I noticed there are some differences in some lines :
for instance the following lines do not appear in the log file generated on the ubuntu apache server :


2020-11-23 15:49:59,996] p12212 {/usr/local/lib/python3.8/site-packages/tornado/web.py:2239} INFO - 200 GET /bkapp/autoload.js?bokeh-autoload-element=1001&bokeh-app-path=/bkapp&bokeh-absolute-url=http://localhost:5006/bkapp (::1) 1747.48ms
[2020-11-23 15:50:00,045] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/views/ws.py:154} DEBUG - Subprotocol header received
[2020-11-23 15:50:00,046] p12212 {/usr/local/lib/python3.8/site-packages/tornado/web.py:2239} INFO - 101 GET /bkapp/ws (::1) 0.56ms
[2020-11-23 15:50:00,046] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/views/ws.py:120} INFO - WebSocket connection opened
[2020-11-23 15:50:00,046] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/views/ws.py:187} DEBUG - Receiver created for Protocol()
[2020-11-23 15:50:00,046] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/views/ws.py:190} DEBUG - ProtocolHandler created for Protocol()
[2020-11-23 15:50:00,046] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/views/ws.py:193} INFO - ServerConnection created
[2020-11-23 15:50:00,048] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/session.py:231} DEBUG - Sending pull-doc-reply from session '03P7Q1i2Bc0RDOO5tiapVDFFj8tZca97eItwWye1FaI0'

  

this is the log file generated on my local env where the bokhe server as library works fine in flask app



.[11-23 15:49:40] p12212 {/Users/humbertozuluaga/Documents/PROYECTOS/PythonProjects/mutabis/mutabis/__init__.py:119} INFO - Logging is set up.
[2020-11-23 15:49:40,039] p12212 {/Users/humbertozuluaga/Documents/PROYECTOS/PythonProjects/mutabis/mutabis/__init__.py:119} INFO - Logging is set up.
[11-23 15:49:40] p12212 {/Users/humbertozuluaga/Documents/PROYECTOS/PythonProjects/mutabis/mutabis/__init__.py:123} INFO - creĂł la app!!
[2020-11-23 15:49:40,040] p12212 {/Users/humbertozuluaga/Documents/PROYECTOS/PythonProjects/mutabis/mutabis/__init__.py:123} INFO - creĂł la app!!
[2020-11-23 15:49:40,073] p12212 {/usr/local/Cellar/[email protected]/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/selector_events.py:59} DEBUG - Using selector: KqueueSelector
[2020-11-23 15:49:40,073] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/server.py:372} INFO - Starting Bokeh server version 2.2.3 (running on Tornado 6.1)
[2020-11-23 15:49:40,074] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/util.py:132} WARNING - Host wildcard '*' will allow connections originating from multiple (or possibly all) hostnames or IPs. Use non-wildcard values to restrict access explicitly
[2020-11-23 15:49:40,082] p12212 {/usr/local/lib/python3.8/site-packages/werkzeug/_internal.py:113} INFO -  * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
[2020-11-23 15:49:40,083] p12212 {/usr/local/lib/python3.8/site-packages/werkzeug/_internal.py:113} INFO -  * Restarting with stat
[2020-11-23 15:49:40,085] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:308} INFO - User authentication hooks NOT provided (default user enabled)
[2020-11-23 15:49:40,085] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:338} DEBUG - These host origins can connect to the websocket: ['*']
[2020-11-23 15:49:40,086] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:392} DEBUG - Patterns are:
[2020-11-23 15:49:40,086] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -   [('/bkapp/?',
[2020-11-23 15:49:40,086] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -     ,
[2020-11-23 15:49:40,086] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -     {'application_context': ,
[2020-11-23 15:49:40,086] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -      'bokeh_websocket_path': '/bkapp/ws'}),
[2020-11-23 15:49:40,086] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -    ('/bkapp/ws',
[2020-11-23 15:49:40,087] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -     ,
[2020-11-23 15:49:40,087] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -     {'application_context': ,
[2020-11-23 15:49:40,087] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -      'bokeh_websocket_path': '/bkapp/ws'}),
[2020-11-23 15:49:40,087] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -    ('/bkapp/metadata',
[2020-11-23 15:49:40,087] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -     ,
[2020-11-23 15:49:40,087] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -     {'application_context': ,
[2020-11-23 15:49:40,087] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -      'bokeh_websocket_path': '/bkapp/ws'}),
[2020-11-23 15:49:40,087] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -    ('/bkapp/autoload.js',
[2020-11-23 15:49:40,087] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -     ,
[2020-11-23 15:49:40,087] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -     {'application_context': ,
[2020-11-23 15:49:40,087] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -      'bokeh_websocket_path': '/bkapp/ws'}),
[2020-11-23 15:49:40,087] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -    ('/grafos/?',
[2020-11-23 15:49:40,087] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -     ,
[2020-11-23 15:49:40,087] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -     {'application_context': ,
[2020-11-23 15:49:40,087] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -      'bokeh_websocket_path': '/grafos/ws'}),
[2020-11-23 15:49:40,087] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -    ('/grafos/ws',
[2020-11-23 15:49:40,087] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -     ,
[2020-11-23 15:49:40,087] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -     {'application_context': ,
[2020-11-23 15:49:40,087] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -      'bokeh_websocket_path': '/grafos/ws'}),
[2020-11-23 15:49:40,087] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -    ('/grafos/metadata',
[2020-11-23 15:49:40,087] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -     ,
[2020-11-23 15:49:40,087] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -     {'application_context': ,
[2020-11-23 15:49:40,087] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -      'bokeh_websocket_path': '/grafos/ws'}),
[2020-11-23 15:49:40,087] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -    ('/grafos/autoload.js',
[2020-11-23 15:49:40,087] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -     ,
[2020-11-23 15:49:40,087] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -     {'application_context': ,
[2020-11-23 15:49:40,087] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -      'bokeh_websocket_path': '/grafos/ws'}),
[2020-11-23 15:49:40,087] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -    ('/?',
[2020-11-23 15:49:40,088] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -     ,
[2020-11-23 15:49:40,088] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -     {'applications': {'/bkapp': ,
[2020-11-23 15:49:40,088] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -                       '/grafos': },
[2020-11-23 15:49:40,088] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -      'index': None,
[2020-11-23 15:49:40,088] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -      'prefix': '',
[2020-11-23 15:49:40,088] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -      'use_redirect': True}),
[2020-11-23 15:49:40,088] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -    ('/static/extensions/(.*)',
[2020-11-23 15:49:40,088] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -     ,
[2020-11-23 15:49:40,088] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -     {'root': {}}),
[2020-11-23 15:49:40,088] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -    ('/static/(.*)',
[2020-11-23 15:49:40,088] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:394} DEBUG -     )]
[11-23 15:49:42] p12216 {/Users/humbertozuluaga/Documents/PROYECTOS/PythonProjects/mutabis/mutabis/__init__.py:119} INFO - Logging is set up.
[2020-11-23 15:49:42,759] p12216 {/Users/humbertozuluaga/Documents/PROYECTOS/PythonProjects/mutabis/mutabis/__init__.py:119} INFO - Logging is set up.
[11-23 15:49:42] p12216 {/Users/humbertozuluaga/Documents/PROYECTOS/PythonProjects/mutabis/mutabis/__init__.py:123} INFO - creĂł la app!!
[2020-11-23 15:49:42,759] p12216 {/Users/humbertozuluaga/Documents/PROYECTOS/PythonProjects/mutabis/mutabis/__init__.py:123} INFO - creĂł la app!!
[2020-11-23 15:49:42,789] p12216 {/usr/local/Cellar/[email protected]/3.8.5/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/selector_events.py:59} DEBUG - Using selector: KqueueSelector
[2020-11-23 15:49:42,789] p12216 {/usr/local/lib/python3.8/site-packages/bokeh/server/server.py:372} INFO - Starting Bokeh server version 2.2.3 (running on Tornado 6.1)
[2020-11-23 15:49:42,795] p12216 {/usr/local/lib/python3.8/site-packages/werkzeug/_internal.py:113} WARNING -  * Debugger is active!
[2020-11-23 15:49:42,802] p12216 {/usr/local/lib/python3.8/site-packages/werkzeug/_internal.py:113} INFO -  * Debugger PIN: 185-942-693
[2020-11-23 15:49:48,065] p12216 {/usr/local/lib/python3.8/site-packages/werkzeug/_internal.py:113} INFO - 127.0.0.1 - - [23/Nov/2020 15:49:48] "e[37mGET /account HTTP/1.1e[0m" 200 -
[2020-11-23 15:49:49,643] p12216 {/usr/local/lib/python3.8/site-packages/werkzeug/_internal.py:113} INFO - 127.0.0.1 - - [23/Nov/2020 15:49:49] "e[32mGET /logout HTTP/1.1e[0m" 302 -
[2020-11-23 15:49:49,659] p12216 {/usr/local/lib/python3.8/site-packages/werkzeug/_internal.py:113} INFO - 127.0.0.1 - - [23/Nov/2020 15:49:49] "e[37mGET /home HTTP/1.1e[0m" 200 -
[2020-11-23 15:49:50,674] p12216 {/usr/local/lib/python3.8/site-packages/werkzeug/_internal.py:113} INFO - 127.0.0.1 - - [23/Nov/2020 15:49:50] "e[37mGET /login HTTP/1.1e[0m" 200 -
[2020-11-23 15:49:54,634] p12216 {/usr/local/lib/python3.8/site-packages/werkzeug/_internal.py:113} INFO - 127.0.0.1 - - [23/Nov/2020 15:49:54] "e[32mPOST /login HTTP/1.1e[0m" 302 -
[2020-11-23 15:49:54,642] p12216 {/usr/local/lib/python3.8/site-packages/werkzeug/_internal.py:113} INFO - 127.0.0.1 - - [23/Nov/2020 15:49:54] "e[37mGET /home HTTP/1.1e[0m" 200 -
[2020-11-23 15:49:55,094] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:658} DEBUG - [pid 12212] 0 clients connected
[2020-11-23 15:49:55,094] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:665} DEBUG - [pid 12212]   /bkapp has 0 sessions with 0 unused
[2020-11-23 15:49:55,094] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:665} DEBUG - [pid 12212]   /grafos has 0 sessions with 0 unused
[2020-11-23 15:49:58,216] p12216 {/usr/local/lib/python3.8/site-packages/werkzeug/_internal.py:113} INFO - 127.0.0.1 - - [23/Nov/2020 15:49:58] "e[37mGET /bokeh HTTP/1.1e[0m" 200 -
[2020-11-23 15:49:59,996] p12212 {/usr/local/lib/python3.8/site-packages/tornado/web.py:2239} INFO - 200 GET /bkapp/autoload.js?bokeh-autoload-element=1001&bokeh-app-path=/bkapp&bokeh-absolute-url=http://localhost:5006/bkapp (::1) 1747.48ms
[2020-11-23 15:50:00,045] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/views/ws.py:154} DEBUG - Subprotocol header received
[2020-11-23 15:50:00,046] p12212 {/usr/local/lib/python3.8/site-packages/tornado/web.py:2239} INFO - 101 GET /bkapp/ws (::1) 0.56ms
[2020-11-23 15:50:00,046] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/views/ws.py:120} INFO - WebSocket connection opened
[2020-11-23 15:50:00,046] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/views/ws.py:187} DEBUG - Receiver created for Protocol()
[2020-11-23 15:50:00,046] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/views/ws.py:190} DEBUG - ProtocolHandler created for Protocol()
[2020-11-23 15:50:00,046] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/views/ws.py:193} INFO - ServerConnection created
[2020-11-23 15:50:00,048] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/session.py:231} DEBUG - Sending pull-doc-reply from session '03P7Q1i2Bc0RDOO5tiapVDFFj8tZca97eItwWye1FaI0'
[2020-11-23 15:50:10,091] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:658} DEBUG - [pid 12212] 1 clients connected
[2020-11-23 15:50:10,091] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:665} DEBUG - [pid 12212]   /bkapp has 1 sessions with 0 unused
[2020-11-23 15:50:10,091] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:665} DEBUG - [pid 12212]   /grafos has 0 sessions with 0 unused
[2020-11-23 15:50:25,094] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:658} DEBUG - [pid 12212] 1 clients connected
[2020-11-23 15:50:25,094] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:665} DEBUG - [pid 12212]   /bkapp has 1 sessions with 0 unused
[2020-11-23 15:50:25,094] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:665} DEBUG - [pid 12212]   /grafos has 0 sessions with 0 unused
[2020-11-23 15:50:40,090] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:658} DEBUG - [pid 12212] 1 clients connected
[2020-11-23 15:50:40,090] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:665} DEBUG - [pid 12212]   /bkapp has 1 sessions with 0 unused

[2020-11-23 16:00:40,094] p12212 {/usr/local/lib/python3.8/site-packages/bokeh/server/tornado.py:665} DEBUG - [pid 12212]   /bkapp has 1 sessions with 0 unused
 

This is how it looks on my local env:

Bryan , do you know any Bokeh consultant we can hire in order to help us to setup our production environment?

Thanks

@Humberto_Zuluaga If you mean for a small one-off engangement, I don’t know anyone offhand. Looking at your log file, no connection attempt is ever even reaching the Bokeh server, so the problem almost certainly lies in the Apache proxy in front. Do the apache logs report denying a connection?

Hello Bryan

This is my apache 000-default.conf file:

< VirtualHost *:80>

    ServerName mutabis.co

    WSGIScriptAlias "/" "/var/www/html/mutabis/app.wsgi"
    <Directory /var/www/html/mutabis/>
     Order allow,deny
     Allow from all
    </Directory>

    CustomLog "/var/www/html/mutabis/access_log" combined
    ErrorLog "/var/www/html/mutabis/error_log"

    ProxyPreserveHost On

    ProxyPass "/bokeh/piloto/ws" "ws://127.0.0.1:5006/piloto/ws"
    ProxyPassReverse "/bokeh/piloto/ws" "ws://127.0.0.1:5006/piloto/ws"

    ProxyPass "/bokeh/piloto" "http://127.0.0.1:5006/piloto"
    ProxyPassReverse "/bokeh/piloto" "http://127.0.0.1:5006/piloto"

    ProxyPass "/bokeh/grafos/ws" "ws://127.0.0.1:5006/grafos/ws"
    ProxyPassReverse "/bokeh/grafos/ws" "ws://127.0.0.1:5006/grafos/ws"

    ProxyPass "/bokeh/grafos" "http://127.0.0.1:5006/grafos/"
    ProxyPassReverse "/bokeh/grafos" "http://127.0.0.1:5006/grafos/"

If I enable this apache configuration , any request to http://mutabis.co/bokeh/piloto or to http://mutabis.co/bokeh/grafos is sent to Bokeh server, which runs on port 5006 and has being started by the following code defined in flask :



def bk_worker():
    
    basicConfig(level='DEBUG')
    server = Server(
            {'/piloto': run_piloto,
             '/grafos': run_grafos
            },
            io_loop=IOLoop(),
            port=5006,
            allow_websocket_origin=["*"]
        )

    server.start()
    server.io_loop.start()

and it renders and responds with the correct charts, but it bypasses the flask routing functions:


@bokehs.route("/bokeh/piloto", methods=['GET'])
@login_required
def piloto():
    print('enters  piloto')
  
    script = server_document(url='http://localhost:5006/piloto')
    return render_template("embed.html", script=script)


@bokehs.route("/bokeh/grafos", methods=['GET'])
@login_required
def grafos():
    print('enters grafos')
    script = server_document(url='http://localhost:5006/grafos')
    return render_template("embed.html", script=script)

So basically the lines script = server_document(url=‘http://localhost:5006/grafos’) or script = server_document(url=‘http://localhost:5006/piloto’) are never called, because of apache configuration.

With this apache proxy conf , the log file I get is:

[11-30 16:39:48] p22676 {/var/www/html/mutabis/mutabis/__init__.py:122} INFO - Logging is set up. [2020-11-30 16:39:48,160] p22676 {/var/www/html/mutabis/mutabis/__init__.py:122} INFO - Logging is set up. [2020-11-30 16:39:48,392] p22676 {/usr/lib/python3.6/asyncio/selector_events.py:54} DEBUG - Using selector: EpollSelector [2020-11-30 16:39:48,427] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/server.py:372} INFO - Starting Bokeh server version 2.2.3 (running on Tornado 6.1 ) [2020-11-30 16:39:48,428] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/util.py:135} WARNING - Host wildcard '*' will allow connections originating from multiple (or possibly all) hostnames or IPs. Use non-wildcard values to restrict access explicitly [2020-11-30 16:39:48,470] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:308} INFO - User authentication hooks NOT provided (default user enabl ed) [2020-11-30 16:39:48,470] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:338} DEBUG - These host origins can connect to the websocket: ['*'] [2020-11-30 16:39:48,517] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:392} DEBUG - Patterns are: [2020-11-30 16:39:48,518] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - [('/piloto/?', [2020-11-30 16:39:48,518] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - , [2020-11-30 16:39:48,518] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - {'application_context': , [2020-11-30 16:39:48,519] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - 'bokeh_websocket_path': '/piloto/ws'}), [2020-11-30 16:39:48,519] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - ('/piloto/ws', [2020-11-30 16:39:48,519] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - , [2020-11-30 16:39:48,519] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - {'application_context': , [2020-11-30 16:39:48,519] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - 'bokeh_websocket_path': '/piloto/ws'}), [2020-11-30 16:39:48,519] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - ('/piloto/metadata', [2020-11-30 16:39:48,519] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - , [2020-11-30 16:39:48,519] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - {'application_context': , [2020-11-30 16:39:48,519] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - 'bokeh_websocket_path': '/piloto/ws'}), [2020-11-30 16:39:48,519] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - ('/piloto/autoload.js', [2020-11-30 16:39:48,519] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - , [2020-11-30 16:39:48,519] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - {'application_context': , [2020-11-30 16:39:48,519] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - 'bokeh_websocket_path': '/piloto/ws'}), [2020-11-30 16:39:48,519] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - ('/grafos/?', [2020-11-30 16:39:48,519] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - , [2020-11-30 16:39:48,519] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - {'application_context': , [2020-11-30 16:39:48,519] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - 'bokeh_websocket_path': '/grafos/ws'}), [2020-11-30 16:39:48,519] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - ('/grafos/ws', [2020-11-30 16:39:48,519] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - , [2020-11-30 16:39:48,519] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - {'application_context': , [2020-11-30 16:39:48,519] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - 'bokeh_websocket_path': '/grafos/ws'}), [2020-11-30 16:39:48,519] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - ('/grafos/metadata', [2020-11-30 16:39:48,519] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - , [2020-11-30 16:39:48,519] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - {'application_context': , [2020-11-30 16:39:48,519] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - 'bokeh_websocket_path': '/grafos/ws'}), [2020-11-30 16:39:48,519] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - ('/grafos/autoload.js', [2020-11-30 16:39:48,519] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - , [2020-11-30 16:39:48,519] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - {'application_context': , [2020-11-30 16:39:48,519] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - 'bokeh_websocket_path': '/grafos/ws'}), [2020-11-30 16:39:48,519] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - ('/?', [2020-11-30 16:39:48,520] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - , [2020-11-30 16:39:48,520] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - {'applications': {'/grafos': , [2020-11-30 16:39:48,520] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - '/piloto': }, [2020-11-30 16:39:48,520] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - 'index': None, [2020-11-30 16:39:48,520] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - 'prefix': '', [2020-11-30 16:39:48,520] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - 'use_redirect': True}), [2020-11-30 16:39:48,520] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - ('/static/extensions/(.*)', [2020-11-30 16:39:48,520] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - , [2020-11-30 16:39:48,520] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - {'root': {}}), [2020-11-30 16:39:48,520] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - ('/static/(.*)', [2020-11-30 16:39:48,520] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:394} DEBUG - )] [11-30 16:39:52] p22677 {/var/www/html/mutabis/mutabis/__init__.py:122} INFO - Logging is set up. [2020-11-30 16:39:52,259] p22677 {/var/www/html/mutabis/mutabis/__init__.py:122} INFO - Logging is set up. [2020-11-30 16:39:52,387] p22677 {/usr/lib/python3.6/asyncio/selector_events.py:54} DEBUG - Using selector: EpollSelector [2020-11-30 16:39:52,405] p22677 {/usr/local/lib/python3.6/dist-packages/bokeh/server/server.py:372} INFO - Starting Bokeh server version 2.2.3 (running on Tornado 6.1 ) [2020-11-30 16:40:03,571] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:658} DEBUG - [pid 22676] 0 clients connected [2020-11-30 16:40:03,571] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:666} DEBUG - [pid 22676] /piloto has 0 sessions with 0 unused [2020-11-30 16:40:03,571] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:666} DEBUG - [pid 22676] /grafos has 0 sessions with 0 unused [2020-11-30 16:40:07,670] p22676 {/usr/local/lib/python3.6/dist-packages/tornado/web.py:2243} INFO - 200 GET /piloto (127.0.0.1) 421.19ms [2020-11-30 16:40:08,024] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/views/ws.py:154} DEBUG - Subprotocol header received [2020-11-30 16:40:08,024] p22676 {/usr/local/lib/python3.6/dist-packages/tornado/web.py:2243} INFO - 101 GET /piloto/ws (127.0.0.1) 1.62ms [2020-11-30 16:40:08,025] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/views/ws.py:120} INFO - WebSocket connection opened [2020-11-30 16:40:08,030] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/views/ws.py:187} DEBUG - Receiver created for Protocol() [2020-11-30 16:40:08,031] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/views/ws.py:190} DEBUG - ProtocolHandler created for Protocol() [2020-11-30 16:40:08,031] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/views/ws.py:193} INFO - ServerConnection created [2020-11-30 16:40:08,247] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/session.py:231} DEBUG - Sending pull-doc-reply from session 'MCWp4gZx7fF9KemO58RL w8gZKFriUq3m4EQWI9Jtpw7s' [2020-11-30 16:40:12,275] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/views/ws.py:284} INFO - WebSocket connection closed: code=1001, reason=None [2020-11-30 16:40:14,414] p22676 {/usr/local/lib/python3.6/dist-packages/tornado/web.py:2243} INFO - 200 GET /grafos/ (127.0.0.1) 757.09ms [2020-11-30 16:40:14,609] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/views/ws.py:154} DEBUG - Subprotocol header received [2020-11-30 16:40:14,609] p22676 {/usr/local/lib/python3.6/dist-packages/tornado/web.py:2243} INFO - 101 GET /grafos/ws (127.0.0.1) 1.20ms [2020-11-30 16:40:14,609] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/views/ws.py:120} INFO - WebSocket connection opened [2020-11-30 16:40:14,610] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/views/ws.py:187} DEBUG - Receiver created for Protocol() [2020-11-30 16:40:14,610] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/views/ws.py:190} DEBUG - ProtocolHandler created for Protocol() [2020-11-30 16:40:14,610] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/views/ws.py:193} INFO - ServerConnection created [2020-11-30 16:40:14,679] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/session.py:231} DEBUG - Sending pull-doc-reply from session 'GA0tNKPBxOWS6VLQmKyx L18KfCPnfG5klJamL92nTis0' [2020-11-30 16:40:18,556] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:658} DEBUG - [pid 22676] 1 clients connected [2020-11-30 16:40:18,557] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:666} DEBUG - [pid 22676] /piloto has 1 sessions with 1 unused [2020-11-30 16:40:18,557] p22676 {/usr/local/lib/python3.6/dist-packages/bokeh/server/tornado.py:666} DEBUG - [pid 22676] /grafos has 1 sessions with 0 unused

I don’t know what else I should try , I am blocked ! I need help from an expert…do you know anyone willing to help me understand what I am missing !

thx

@Humberto_Zuluaga The main problem is that I have essentially zero experience with Apache, so I simply have no specific knowledge to share. You might fare better asking about Apache configuration issues on an Apache-specific forum.

FWIW the logs above look like Bokeh server logs? I was asking about Apache’s own logs, whether there were any errors, warnings, or messages about rejected or failed connections, etc.

Thanks Bryan for your prompt response.
Do you think I should try Nginx instead?

If I decide not to run a Bokeh server , can I create complex and reactive bokeh charts/graphics/plots using javascript and BokehJS and backend bokeh libraries and Flask? or it is compulsory to run bokeh server in order to get the best results?

thanks

Hello Bryan

I am back :wink:

I decided to do a fresh install on a new ubuntu machine, but this time using Nginx and Gunicorn. The installation and configuration went smoothly and the flask app runs ok. However I get exactly the same behaviour as the one I previously had with apache.

If I define a reverse proxy in nginx, bohek server responds ok, all tables, plots and widgets are rendered correctly and callbacks work as expected , but they are on a new html, without the flask app layout (no nav bar , menus , etc ). The reverse proxy redirects requests to the bokeh server without going through the flask app, which is the correct behaviour I guess , but that is not what I want!

This is my Nginx conf file:

server {
    listen 80;
    server_name 40.84.58.139;

location / {
        include proxy_params;
        proxy_pass http://unix:/var/www/html/mutabisenv/mutabis.sock;
        error_log  /var/log/nginx/mutabis.error_log  debug;
        access_log /var/log/nginx/mutabis.access.log;
    }

location /bokeh/piloto {
        proxy_pass http://127.0.0.1:5006/piloto;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host:$server_port;
        proxy_buffering off;
    }


location /bokeh/grafos {
        proxy_pass http://127.0.0.1:5006/grafos;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host:$server_port;
        proxy_buffering off;
    }

location /bokeh/static {
    alias /var/www/html/mutabisenv/mutabis/static;
}

If I do not setup a reverse proxy, in order to let flask handle all requests and routing, I get the same errors on the browser console as the ones I got when using apache:

"piloto:84 GET http://40.84.58.139:5006/piloto/autoload.js?bokeh-autoload-element=1001&bokeh-app-path=/piloto net::ERR_CONNECTION_TIMED_OUT "
if I pass the my server’s public IP.

or

"piloto:84 GET http://127.0.0.1:5006/piloto/autoload.js?bokeh-autoload-element=1001&bokeh-app-path=/piloto net::ERR_CONNECTION_REFUSED", if i use 127.0.0.1 or localhost

Once the flask app is created, the embedded bokeh server is instantiated and starts on port 5006. These are the running processes on my machine:

systemd-r   824 systemd-resolve   13u  IPv4   17904      0t0  TCP 127.0.0.53:53 (LISTEN)
sshd       1033            root    3u  IPv4   21024      0t0  TCP *:22 (LISTEN)
sshd       1033            root    4u  IPv6   21035      0t0  TCP *:22 (LISTEN)
mysqld    13262           mysql   30u  IPv4  359170      0t0  TCP 127.0.0.1:3306 (LISTEN)
gunicorn  17905            root   17u  IPv4 2428793      0t0  TCP *:5006 (LISTEN)
gunicorn  17905            root   18u  IPv6 2428794      0t0  TCP *:5006 (LISTEN)
nginx     17928            root    8u  IPv4 2428741      0t0  TCP *:80 (LISTEN)
nginx     17929        www-data    8u  IPv4 2428741      0t0  TCP *:80 (LISTEN)

This is the Nginx error log (debug mode) that is created for the “/bokeh/piloto” route that throws the “CONNECTION REFUSED” message:


2020/12/17 22:56:36 [debug] 18307#18307: *1 http header done
2020/12/17 22:56:36 [debug] 18307#18307: *1 generic phase: 0
2020/12/17 22:56:36 [debug] 18307#18307: *1 rewrite phase: 1
2020/12/17 22:56:36 [debug] 18307#18307: *1 test location: "/"
2020/12/17 22:56:36 [debug] 18307#18307: *1 test location: "bokeh/static"
2020/12/17 22:56:36 [debug] 18307#18307: *1 test location: "bokeh/grafos"
2020/12/17 22:56:36 [debug] 18307#18307: *1 using configuration "/"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http cl:-1 max:1048576
2020/12/17 22:56:36 [debug] 18307#18307: *1 rewrite phase: 3
2020/12/17 22:56:36 [debug] 18307#18307: *1 post rewrite phase: 4
2020/12/17 22:56:36 [debug] 18307#18307: *1 generic phase: 5
2020/12/17 22:56:36 [debug] 18307#18307: *1 generic phase: 6
2020/12/17 22:56:36 [debug] 18307#18307: *1 generic phase: 7
2020/12/17 22:56:36 [debug] 18307#18307: *1 access phase: 8
2020/12/17 22:56:36 [debug] 18307#18307: *1 access phase: 9
2020/12/17 22:56:36 [debug] 18307#18307: *1 access phase: 10
2020/12/17 22:56:36 [debug] 18307#18307: *1 post access phase: 11
2020/12/17 22:56:36 [debug] 18307#18307: *1 generic phase: 12
2020/12/17 22:56:36 [debug] 18307#18307: *1 generic phase: 13
2020/12/17 22:56:36 [debug] 18307#18307: *1 http init upstream, client timer: 0
2020/12/17 22:56:36 [debug] 18307#18307: *1 http script copy: "Host"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http script var: "40.84.58.139"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http script copy: "X-Real-IP"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http script var: "186.31.13.115"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http script copy: "X-Forwarded-For"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http script var: "186.31.13.115"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http script copy: "X-Forwarded-Proto"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http script var: "http"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http script copy: "Connection"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http script copy: "close"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http script copy: ""
2020/12/17 22:56:36 [debug] 18307#18307: *1 http script copy: ""
2020/12/17 22:56:36 [debug] 18307#18307: *1 http proxy header: "Upgrade-Insecure-Requests: 1"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http proxy header: "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http proxy header: "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http proxy header: "Referer: http://40.84.58.139/"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http proxy header: "Accept-Encoding: gzip, deflate"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http proxy header: "Accept-Language: en-US,en;q=0.9,es;q=0.8,fr;q=0.7,de;q=0.6,la;q=0.5,gl;q=0.4"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http proxy header: "Cookie: session=.eJwlTkGKAzEM-0vOPdhOnMT9zOA4NrsUdmGmPZX-fQ17kISEBHqXI06_vsr9eb78Vo7vXe6FxBrXUEbttVogThZpqtMmD1HdyVsGAE7h7QBUldpSZ-s2Oqpi0MQI24NWGHGOoW2yWFit8yYO7C
AZeoOx1CZkmyBRoeSR1-Xn_xtMa9cZx_P34T8ZDKvglbagqFCrORca5JQSLrpGIExv5fMH2Hw_VQ.X9vZ-A.0fbt3To-gKxnJNZo7GUfQ9meRi4"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http proxy header:
"GET /bokeh/piloto HTTP/1.0
Host: 40.84.58.139
X-Real-IP: 186.31.13.115
X-Forwarded-For: 186.31.13.115
X-Forwarded-Proto: http
Connection: close
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Referer: http://40.84.58.139/
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9,es;q=0.8,fr;q=0.7,de;q=0.6,la;q=0.5,gl;q=0.4
Cookie: session=.eJwlTkGKAzEM-0vOPdhOnMT9zOA4NrsUdmGmPZX-fQ17kISEBHqXI06_vsr9eb78Vo7vXe6FxBrXUEbttVogThZpqtMmD1HdyVsGAE7h7QBUldpSZ-s2Oqpi0MQI24NWGHGOoW2yWFit8yYO7CAZeoOx1CZkmyBRoeSR1-Xn_xtMa9cZx_P34T8ZDKvglbagqFCrORca5JQSLrpGIE
xv5fMH2Hw_VQ.X9vZ-A.0fbt3To-gKxnJNZo7GUfQ9meRi4

"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http cleanup add: 0000557D8971A988
2020/12/17 22:56:36 [debug] 18307#18307: *1 get rr peer, try: 1
2020/12/17 22:56:36 [debug] 18307#18307: *1 stream socket 13
2020/12/17 22:56:36 [debug] 18307#18307: *1 epoll add connection: fd:13 ev:80002005
2020/12/17 22:56:36 [debug] 18307#18307: *1 connect to unix:/var/www/html/mutabisenv/mutabis.sock, fd:13 #4
2020/12/17 22:56:36 [debug] 18307#18307: *1 connected
2020/12/17 22:56:36 [debug] 18307#18307: *1 http upstream connect: 0
2020/12/17 22:56:36 [debug] 18307#18307: *1 posix_memalign: 0000557D8974DB10:128 @16
2020/12/17 22:56:36 [debug] 18307#18307: *1 http upstream send request
2020/12/17 22:56:36 [debug] 18307#18307: *1 http upstream send request body
2020/12/17 22:56:36 [debug] 18307#18307: *1 chain writer buf fl:1 s:877
2020/12/17 22:56:36 [debug] 18307#18307: *1 chain writer in: 0000557D897624E0
2020/12/17 22:56:36 [debug] 18307#18307: *1 writev: 877 of 877
2020/12/17 22:56:36 [debug] 18307#18307: *1 chain writer out: 0000000000000000
2020/12/17 22:56:36 [debug] 18307#18307: *1 event timer add: 13: 60000:634611366
2020/12/17 22:56:36 [debug] 18307#18307: *1 http finalize request: -4, "/bokeh/piloto?" a:1, c:2
2020/12/17 22:56:36 [debug] 18307#18307: *1 http request count:2 blk:0
2020/12/17 22:56:36 [debug] 18307#18307: *1 http run request: "/bokeh/piloto?"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http upstream check client, write event:1, "/bokeh/piloto"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http upstream request: "/bokeh/piloto?"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http upstream dummy handler
2020/12/17 22:56:36 [debug] 18307#18307: *1 http upstream request: "/bokeh/piloto?"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http upstream dummy handler
2020/12/17 22:56:36 [debug] 18307#18307: *1 http upstream request: "/bokeh/piloto?"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http upstream process header
2020/12/17 22:56:36 [debug] 18307#18307: *1 malloc: 0000557D8974DBA0:4096
2020/12/17 22:56:36 [debug] 18307#18307: *1 recv: eof:0, avail:1
2020/12/17 22:56:36 [debug] 18307#18307: *1 recv: fd:13 176 of 4096
2020/12/17 22:56:36 [debug] 18307#18307: *1 http proxy status 200 "200 OK"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http proxy header: "Server: gunicorn/20.0.4"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http proxy header: "Date: Thu, 17 Dec 2020 22:56:36 GMT"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http proxy header: "Connection: close"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http proxy header: "Content-Type: text/html; charset=utf-8"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http proxy header: "Content-Length: 5007"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http proxy header: "Vary: Cookie"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http proxy header done
2020/12/17 22:56:36 [debug] 18307#18307: *1 xslt filter header
2020/12/17 22:56:36 [debug] 18307#18307: *1 posix_memalign: 0000557D89722CA0:4096 @16
2020/12/17 22:56:36 [debug] 18307#18307: *1 HTTP/1.1 200 OK
Server: nginx/1.14.0 (Ubuntu)
Date: Thu, 17 Dec 2020 22:56:36 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Cookie
Content-Encoding: gzip

2020/12/17 22:56:36 [debug] 18307#18307: *1 write new buf t:1 f:0 0000557D89722E18, pos 0000557D89722E18, size: 217 file: 0, size: 0
2020/12/17 22:56:36 [debug] 18307#18307: *1 http write filter: l:0 f:0 s:217
2020/12/17 22:56:36 [debug] 18307#18307: *1 http cacheable: 0
2020/12/17 22:56:36 [debug] 18307#18307: *1 http proxy filter init s:200 h:0 c:0 l:5007
2020/12/17 22:56:36 [debug] 18307#18307: *1 http upstream process upstream
2020/12/17 22:56:36 [debug] 18307#18307: *1 pipe read upstream: 0
2020/12/17 22:56:36 [debug] 18307#18307: *1 pipe preread: 0
2020/12/17 22:56:36 [debug] 18307#18307: *1 pipe buf free s:0 t:1 f:0 0000557D8974DBA0, pos 0000557D8974DC50, size: 0 file: 0, size: 0
2020/12/17 22:56:36 [debug] 18307#18307: *1 pipe length: 5007
2020/12/17 22:56:36 [debug] 18307#18307: *1 event timer: 13, old: 634611366, new: 634611478
2020/12/17 22:56:36 [debug] 18307#18307: *1 http upstream request: "/bokeh/piloto?"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http upstream dummy handler
2020/12/17 22:56:36 [debug] 18307#18307: *1 http upstream request: "/bokeh/piloto?"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http upstream process upstream
2020/12/17 22:56:36 [debug] 18307#18307: *1 pipe read upstream: 1
2020/12/17 22:56:36 [debug] 18307#18307: *1 readv: eof:0, avail:1
2020/12/17 22:56:36 [debug] 18307#18307: *1 readv: 1, last:3920
2020/12/17 22:56:36 [debug] 18307#18307: *1 pipe recv chain: 3920
2020/12/17 22:56:36 [debug] 18307#18307: *1 input buf #0
2020/12/17 22:56:36 [debug] 18307#18307: *1 malloc: 0000557D89723CB0:4096
2020/12/17 22:56:36 [debug] 18307#18307: *1 readv: eof:0, avail:1
2020/12/17 22:56:36 [debug] 18307#18307: *1 readv: 1, last:4096
2020/12/17 22:56:36 [debug] 18307#18307: *1 pipe recv chain: 1087
2020/12/17 22:56:36 [debug] 18307#18307: *1 pipe buf in   s:1 t:1 f:0 0000557D8974DBA0, pos 0000557D8974DC50, size: 3920 file: 0, size: 0
2020/12/17 22:56:36 [debug] 18307#18307: *1 pipe buf free s:0 t:1 f:0 0000557D89723CB0, pos 0000557D89723CB0, size: 1087 file: 0, size: 0
2020/12/17 22:56:36 [debug] 18307#18307: *1 pipe length: 1087
2020/12/17 22:56:36 [debug] 18307#18307: *1 input buf #1
2020/12/17 22:56:36 [debug] 18307#18307: *1 pipe write downstream: 1
2020/12/17 22:56:36 [debug] 18307#18307: *1 pipe write downstream flush in
2020/12/17 22:56:36 [debug] 18307#18307: *1 http output filter "/bokeh/piloto?"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http copy filter: "/bokeh/piloto?"
2020/12/17 22:56:36 [debug] 18307#18307: *1 image filter
2020/12/17 22:56:36 [debug] 18307#18307: *1 xslt filter body
2020/12/17 22:56:36 [debug] 18307#18307: *1 http postpone filter "/bokeh/piloto?" 0000557D897627C8
2020/12/17 22:56:36 [debug] 18307#18307: *1 http gzip filter
2020/12/17 22:56:36 [debug] 18307#18307: *1 malloc: 0000557D897955D0:73728
2020/12/17 22:56:36 [debug] 18307#18307: *1 gzip alloc: n:1 s:5952 a:8192 p:0000557D897955D0
2020/12/17 22:56:36 [debug] 18307#18307: *1 gzip alloc: n:8192 s:2 a:16384 p:0000557D897975D0
2020/12/17 22:56:36 [debug] 18307#18307: *1 gzip alloc: n:8192 s:2 a:16384 p:0000557D8979B5D0
2020/12/17 22:56:36 [debug] 18307#18307: *1 gzip alloc: n:8192 s:2 a:16384 p:0000557D8979F5D0
2020/12/17 22:56:36 [debug] 18307#18307: *1 gzip alloc: n:4096 s:4 a:16384 p:0000557D897A35D0
2020/12/17 22:56:36 [debug] 18307#18307: *1 gzip in: 0000557D89723190
2020/12/17 22:56:36 [debug] 18307#18307: *1 gzip in_buf:0000557D89723008 ni:0000557D8974DC50 ai:3920
2020/12/17 22:56:36 [debug] 18307#18307: *1 malloc: 0000557D89724CC0:4096
2020/12/17 22:56:36 [debug] 18307#18307: *1 deflate in: ni:0000557D8974DC50 no:0000557D89724CC0 ai:3920 ao:4096 fl:0 redo:0
2020/12/17 22:56:36 [debug] 18307#18307: *1 deflate out: ni:0000557D8974EBA0 no:0000557D89724CC0 ai:0 ao:4096 rc:0
2020/12/17 22:56:36 [debug] 18307#18307: *1 gzip in_buf:0000557D89723008 pos:0000557D8974DC50
2020/12/17 22:56:36 [debug] 18307#18307: *1 gzip in: 0000557D897231A0
2020/12/17 22:56:36 [debug] 18307#18307: *1 gzip in_buf:0000557D897230A8 ni:0000557D89723CB0 ai:1087
2020/12/17 22:56:36 [debug] 18307#18307: *1 deflate in: ni:0000557D89723CB0 no:0000557D89724CC0 ai:1087 ao:4096 fl:0 redo:0
2020/12/17 22:56:36 [debug] 18307#18307: *1 deflate out: ni:0000557D897240EF no:0000557D89724CC0 ai:0 ao:4096 rc:0
2020/12/17 22:56:36 [debug] 18307#18307: *1 gzip in_buf:0000557D897230A8 pos:0000557D89723CB0
2020/12/17 22:56:36 [debug] 18307#18307: *1 gzip in: 0000000000000000
2020/12/17 22:56:36 [debug] 18307#18307: *1 http copy filter: 0 "/bokeh/piloto?"
2020/12/17 22:56:36 [debug] 18307#18307: *1 pipe write downstream done
2020/12/17 22:56:36 [debug] 18307#18307: *1 event timer: 13, old: 634611366, new: 634611482
2020/12/17 22:56:36 [debug] 18307#18307: *1 http upstream exit: 0000000000000000
2020/12/17 22:56:36 [debug] 18307#18307: *1 finalize http upstream request: 0
2020/12/17 22:56:36 [debug] 18307#18307: *1 finalize http proxy request
2020/12/17 22:56:36 [debug] 18307#18307: *1 free rr peer 1 0
2020/12/17 22:56:36 [debug] 18307#18307: *1 close http upstream connection: 13
2020/12/17 22:56:36 [debug] 18307#18307: *1 free: 0000557D8974DB10, unused: 48
2020/12/17 22:56:36 [debug] 18307#18307: *1 event timer del: 13: 634611366
2020/12/17 22:56:36 [debug] 18307#18307: *1 reusable connection: 0
2020/12/17 22:56:36 [debug] 18307#18307: *1 http upstream temp fd: -1
2020/12/17 22:56:36 [debug] 18307#18307: *1 http output filter "/bokeh/piloto?"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http copy filter: "/bokeh/piloto?"
2020/12/17 22:56:36 [debug] 18307#18307: *1 image filter
2020/12/17 22:56:36 [debug] 18307#18307: *1 xslt filter body
2020/12/17 22:56:36 [debug] 18307#18307: *1 http postpone filter "/bokeh/piloto?" 00007FFEE8D03E00
2020/12/17 22:56:36 [debug] 18307#18307: *1 http gzip filter
2020/12/17 22:56:36 [debug] 18307#18307: *1 gzip in: 0000557D89723170
2020/12/17 22:56:36 [debug] 18307#18307: *1 gzip in_buf:0000557D89723210 ni:0000000000000000 ai:0
2020/12/17 22:56:36 [debug] 18307#18307: *1 deflate in: ni:0000000000000000 no:0000557D89724CC0 ai:0 ao:4096 fl:4 redo:0
2020/12/17 22:56:36 [debug] 18307#18307: *1 deflate out: ni:0000000000000000 no:0000557D897253F2 ai:0 ao:2254 rc:1
2020/12/17 22:56:36 [debug] 18307#18307: *1 gzip in_buf:0000557D89723210 pos:0000000000000000
2020/12/17 22:56:36 [debug] 18307#18307: *1 free: 0000557D897955D0
2020/12/17 22:56:36 [debug] 18307#18307: *1 http chunk: 10
2020/12/17 22:56:36 [debug] 18307#18307: *1 http chunk: 1850
2020/12/17 22:56:36 [debug] 18307#18307: *1 write old buf t:1 f:0 0000557D89722E18, pos 0000557D89722E18, size: 217 file: 0, size: 0
2020/12/17 22:56:36 [debug] 18307#18307: *1 write new buf t:1 f:0 0000557D89723310, pos 0000557D89723310, size: 5 file: 0, size: 0
2020/12/17 22:56:36 [debug] 18307#18307: *1 write new buf t:0 f:0 0000000000000000, pos 0000557D880221A0, size: 10 file: 0, size: 0
2020/12/17 22:56:36 [debug] 18307#18307: *1 write new buf t:1 f:0 0000557D89724CC0, pos 0000557D89724CC0, size: 1850 file: 0, size: 0
2020/12/17 22:56:36 [debug] 18307#18307: *1 write new buf t:0 f:0 0000000000000000, pos 0000557D87DF54F5, size: 7 file: 0, size: 0
2020/12/17 22:56:36 [debug] 18307#18307: *1 http write filter: l:1 f:1 s:2089
2020/12/17 22:56:36 [debug] 18307#18307: *1 http write filter limit 0
2020/12/17 22:56:36 [debug] 18307#18307: *1 writev: 2089 of 2089
2020/12/17 22:56:36 [debug] 18307#18307: *1 http write filter 0000000000000000
2020/12/17 22:56:36 [debug] 18307#18307: *1 http copy filter: 0 "/bokeh/piloto?"
2020/12/17 22:56:36 [debug] 18307#18307: *1 http finalize request: 0, "/bokeh/piloto?" a:1, c:1
2020/12/17 22:56:36 [debug] 18307#18307: *1 set http keepalive handler
2020/12/17 22:56:36 [debug] 18307#18307: *1 http close request
2020/12/17 22:56:36 [debug] 18307#18307: *1 http log handler
2020/12/17 22:56:36 [debug] 18307#18307: *1 free: 0000557D89724CC0
2020/12/17 22:56:36 [debug] 18307#18307: *1 free: 0000000000000000
2020/12/17 22:56:36 [debug] 18307#18307: *1 free: 0000557D89723CB0
2020/12/17 22:56:36 [debug] 18307#18307: *1 free: 0000557D8974DBA0
2020/12/17 22:56:36 [debug] 18307#18307: *1 free: 0000557D897199A0, unused: 0
2020/12/17 22:56:36 [debug] 18307#18307: *1 free: 0000557D89761810, unused: 8
2020/12/17 22:56:36 [debug] 18307#18307: *1 free: 0000557D89722CA0, unused: 2001
2020/12/17 22:56:36 [debug] 18307#18307: *1 free: 0000557D897031D0
2020/12/17 22:56:36 [debug] 18307#18307: *1 hc free: 0000000000000000
2020/12/17 22:56:36 [debug] 18307#18307: *1 hc busy: 0000000000000000 0
2020/12/17 22:56:36 [debug] 18307#18307: *1 reusable connection: 1
2020/12/17 22:56:36 [debug] 18307#18307: *1 event timer add: 3: 65000:634616482

This is the Flask-Bokeh server log file:

[12-17 22:55:54] p18339 {/var/www/html/mutabisenv/mutabis/__init__.py:122} INFO - Logging is set up.
[2020-12-17 22:55:54,869] p18339 {/var/www/html/mutabisenv/mutabis/__init__.py:122} INFO - Logging is set up.
[12-17 22:55:54] p18339 {/var/www/html/mutabisenv/mutabis/__init__.py:126} INFO - se creĂł la app!!
[2020-12-17 22:55:54,869] p18339 {/var/www/html/mutabisenv/mutabis/__init__.py:126} INFO - se creĂł la app!!
[12-17 22:55:55] p18334 {/var/www/html/mutabisenv/mutabis/__init__.py:122} INFO - Logging is set up.
[2020-12-17 22:55:55,047] p18334 {/var/www/html/mutabisenv/mutabis/__init__.py:122} INFO - Logging is set up.
[12-17 22:55:55] p18334 {/var/www/html/mutabisenv/mutabis/__init__.py:126} INFO - se creĂł la app!!
[2020-12-17 22:55:55,048] p18334 {/var/www/html/mutabisenv/mutabis/__init__.py:126} INFO - se creĂł la app!!
[2020-12-17 22:55:55,093] p18339 {/usr/lib/python3.6/asyncio/selector_events.py:54} DEBUG - Using selector: EpollSelector
[2020-12-17 22:55:55,113] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/server.py:372} INFO - Starting Bokeh server version 2.2.3 (running on Tornado 6.1)
[2020-12-17 22:55:55,120] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/util.py:135} WARNING - Host wildcard '*' will allow connections originating from multiple (or possibly all) hostnames or IPs. U
se non-wildcard values to restrict access explicitly
[2020-12-17 22:55:55,137] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:308} INFO - User authentication hooks NOT provided (default user enabled)
[2020-12-17 22:55:55,137] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:338} DEBUG - These host origins can connect to the websocket: ['*']
[2020-12-17 22:55:55,137] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:392} DEBUG - Patterns are:
[2020-12-17 22:55:55,138] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -   [('/piloto/?',
[2020-12-17 22:55:55,147] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -     <class 'bokeh.server.views.doc_handler.DocHandler'>,
[2020-12-17 22:55:55,147] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -     {'application_context': <bokeh.server.contexts.ApplicationContext object at 0x7f5aa3b0c470>,
[2020-12-17 22:55:55,147] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -      'bokeh_websocket_path': '/piloto/ws'}),
[2020-12-17 22:55:55,147] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -    ('/piloto/ws',
[2020-12-17 22:55:55,147] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -     <class 'bokeh.server.views.ws.WSHandler'>,
[2020-12-17 22:55:55,147] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -     {'application_context': <bokeh.server.contexts.ApplicationContext object at 0x7f5aa3b0c470>,
[2020-12-17 22:55:55,147] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -      'bokeh_websocket_path': '/piloto/ws'}),
[2020-12-17 22:55:55,147] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -    ('/piloto/metadata',
[2020-12-17 22:55:55,147] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -     <class 'bokeh.server.views.metadata_handler.MetadataHandler'>,
[2020-12-17 22:55:55,147] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -     {'application_context': <bokeh.server.contexts.ApplicationContext object at 0x7f5aa3b0c470>,
[2020-12-17 22:55:55,147] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -      'bokeh_websocket_path': '/piloto/ws'}),
[2020-12-17 22:55:55,147] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -    ('/piloto/autoload.js',
[2020-12-17 22:55:55,149] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -     <class 'bokeh.server.views.autoload_js_handler.AutoloadJsHandler'>,
[2020-12-17 22:55:55,149] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -     {'application_context': <bokeh.server.contexts.ApplicationContext object at 0x7f5aa3b0c470>,
[2020-12-17 22:55:55,149] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -      'bokeh_websocket_path': '/piloto/ws'}),
[2020-12-17 22:55:55,149] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -    ('/grafos/?',
[2020-12-17 22:55:55,149] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -     <class 'bokeh.server.views.doc_handler.DocHandler'>,
[2020-12-17 22:55:55,149] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -     {'application_context': <bokeh.server.contexts.ApplicationContext object at 0x7f5aa32b6240>,
[2020-12-17 22:55:55,149] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -      'bokeh_websocket_path': '/grafos/ws'}),
[2020-12-17 22:55:55,149] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -    ('/grafos/ws',
[2020-12-17 22:55:55,149] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -     <class 'bokeh.server.views.ws.WSHandler'>,
[2020-12-17 22:55:55,149] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -     {'application_context': <bokeh.server.contexts.ApplicationContext object at 0x7f5aa32b6240>,
[2020-12-17 22:55:55,149] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -      'bokeh_websocket_path': '/grafos/ws'}),
[2020-12-17 22:55:55,149] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -    ('/grafos/metadata',
[2020-12-17 22:55:55,149] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -     <class 'bokeh.server.views.metadata_handler.MetadataHandler'>,
[2020-12-17 22:55:55,149] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -     {'application_context': <bokeh.server.contexts.ApplicationContext object at 0x7f5aa32b6240>,
[2020-12-17 22:55:55,149] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -      'bokeh_websocket_path': '/grafos/ws'}),
[2020-12-17 22:55:55,149] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -    ('/grafos/autoload.js',
[2020-12-17 22:55:55,149] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -     <class 'bokeh.server.views.autoload_js_handler.AutoloadJsHandler'>,
[2020-12-17 22:55:55,149] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -     {'application_context': <bokeh.server.contexts.ApplicationContext object at 0x7f5aa32b6240>,
[2020-12-17 22:55:55,160] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -      'bokeh_websocket_path': '/grafos/ws'}),
[2020-12-17 22:55:55,160] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -    ('/?',
[2020-12-17 22:55:55,160] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -     <class 'bokeh.server.views.root_handler.RootHandler'>,
[2020-12-17 22:55:55,160] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -     {'applications': {'/grafos': <bokeh.server.contexts.ApplicationContext object at 0x7f5aa32b6240>,
[2020-12-17 22:55:55,160] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -                       '/piloto': <bokeh.server.contexts.ApplicationContext object at 0x7f5aa3b0c470>},
[2020-12-17 22:55:55,160] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -      'index': None,
[2020-12-17 22:55:55,160] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -      'prefix': '',
[2020-12-17 22:55:55,160] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -      'use_redirect': True}),
[2020-12-17 22:55:55,160] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -    ('/static/extensions/(.*)',
[2020-12-17 22:55:55,160] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -     <class 'bokeh.server.views.multi_root_static_handler.MultiRootStaticHandler'>,
[2020-12-17 22:55:55,160] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -     {'root': {}}),
[2020-12-17 22:55:55,160] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -    ('/static/(.*)',
[2020-12-17 22:55:55,160] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:394} DEBUG -     <class 'bokeh.server.views.static_handler.StaticHandler'>)]
[12-17 22:55:55] p18340 {/var/www/html/mutabisenv/mutabis/__init__.py:122} INFO - Logging is set up.
[2020-12-17 22:55:55,206] p18340 {/var/www/html/mutabisenv/mutabis/__init__.py:122} INFO - Logging is set up.
[12-17 22:55:55] p18340 {/var/www/html/mutabisenv/mutabis/__init__.py:126} INFO - se creĂł la app!!
[2020-12-17 22:55:55,206] p18340 {/var/www/html/mutabisenv/mutabis/__init__.py:126} INFO - se creĂł la app!!
[2020-12-17 22:55:55,281] p18334 {/usr/lib/python3.6/asyncio/selector_events.py:54} DEBUG - Using selector: EpollSelector
[2020-12-17 22:55:55,282] p18334 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/server.py:372} INFO - Starting Bokeh server version 2.2.3 (running on Tornado 6.1)
[2020-12-17 22:55:55,339] p18340 {/usr/lib/python3.6/asyncio/selector_events.py:54} DEBUG - Using selector: EpollSelector
[2020-12-17 22:55:55,340] p18340 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/server.py:372} INFO - Starting Bokeh server version 2.2.3 (running on Tornado 6.1)
[2020-12-17 22:56:10,177] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:658} DEBUG - [pid 18339] 0 clients connected
[2020-12-17 22:56:10,177] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-packages/bokeh/server/tornado.py:666} DEBUG - [pid 18339]   /piloto has 0 sessions with 0 unused
[2020-12-17 22:56:10,177] p18339 {/var/www/html/mutabisenv/lib/python3.6/site-

Honestly I do not know what else I should try. Any help you could provide I will really appreciate,… I am stuck…

Thx

@Humberto_Zuluaga There are just too many unknowns here for me to even begin to speculate. Basically the only hope I can offer to be able to help concretely is if you have a minimal repo set up that I could check out and run things to investigate. I don’t have nearly enough nginx experience to be able to have ideas about what the problem might be without actual experimentation.

Hello Bryan

Will it be possible for you to have a 15 minute “meet” or “zoom” session so I can show you very quickly the app and the system setup?
thx

@Humberto_Zuluaga I don’t think that will be helpful, I need to actually be able to run something and have time to experiment on my own.

Hello Bryan

Today I realized the 5006 port in the azure server was not opened, so I asked the admin to open it and see whether this was the reason. Although it is still not working , now a get a different error message on the browser console:

 WebSocket connection to 'ws://40.84.58.139/piloto/ws' failed: Error during WebSocket handshake: Unexpected response code: 404

I can provide u access to this server if you think that will be ok and enough to experiment with .

Thx again

I don’t want to sound overly critical but this is the first mention of Azure in this entire thread. If it had been stated up front that this was a cloud deployment I could have mentioned that in my experience it also usually necessary to explicitly open up ports on cloud service configurations.

BTW this also applies, individually and separately from HTTP connections, to web sockets. My experience (which is only on AWS) is that extra steps have to be taken to permit websocket connections to VMs (e.g setting some configuration in the admin panel). I can’t help with the details of that as I am not familiar with Azure.

Bryan , I am sorry I did not mention from the very beginning I was deploying on a cloud server (Azure) so you could have a better picture and give more accurate recommendations.

As I initially mentioned Bokeh server responds and renders all tables, plots and widgets correctly and callbacks work ok if nginx reverse proxy is defined, which means the problem is not related to whether port 5006 was open or not …it seems it has been always opened and websocket connections are correctly enabled , otherwise it wouldn’t have worked at all, I certainly got confused this morning trying to find a reason and thought port 5006 was blocked.

Thanks anyway for your time and help.

regards

Hello Bryan

As mentioned on my previous message, although we opened or enabled the “websockets flow” on the Azure platform we still got an error, but this time the message was different. This made me retry some of the things I had previously done but that failed, in particular changing the address “localhost” by the real IP of our server on every call to “server_session” function and it all worked perfectly this time!!
No need to define any reverse proxy at Apache , or NGINX conf files, all routing is done by Flask. Bokeh server , started by a “worker” within the Flask app on port 5006 , responds and renders all plots correctly !!
In order to secure the access to my bokeh server, I have defined a “session_id” calling generate_session_id function and passing a secret_key that I generate through calling “bokeh secret” .
Here is the routing function in flask that will call the Bokeh server (all used params are loaded from a environment “.env” file ):

@bokehs.route("/bokeh/grafos", methods=['GET'])
@login_required
def grafos():
    script = server_session(url=current_app.config['BOKEH_URL']+':'+current_app.config['BOKEH_PORT']+'/grafos',session_id=generate_session_id(secret_key=current_app.config['BOKEH_SECRET_KEY'], signed=current_app.config['BOKEH_SIGN_SESSIONS']))
    return render_template("embed.html", script=script)

Now everything that is rendered and returned by the Bokeh Server, is displayed inside the Flask app:

If someone tries to access the boker server directly using the correct URL (e.g: mutabis.co:5006/grafos), it gets rejected because there is no correct session_id.

Just wanted to let you know I finally managed to solve the problems I had and thank you for your help.

1 Like