[flask + bokeh] WebSocket connection closed: code=None, reason=None

I want t run a flask site calling bokeh server that streams data from computations occur. The standalone bokeh server works great and streams data perfectly. However, when I have the same bokeh server embedded in a flask site, I get this strange error below. Can someone please take a look and advice what I can tweak or change to avoid this error?
Thanks a lot in advance.

2019-03-10 20:56:47,167 Starting Bokeh server with process id: 8905

2019-03-10 20:56:54,066 root_url should end with a /, adding one

2019-03-10 20:56:54,073 200 GET /bokeh/designData/autoload.js?bokeh-autoload-element=1000&bokeh-app-path=/bokeh/designData&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 236.03ms

2019-03-10 20:56:54,102 root_url should end with a /, adding one

2019-03-10 20:56:54,104 200 GET /bokeh/domeProfile/autoload.js?bokeh-autoload-element=1001&bokeh-app-path=/bokeh/domeProfile&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 30.60ms

2019-03-10 20:56:54,123 root_url should end with a /, adding one

2019-03-10 20:56:54,125 200 GET /bokeh/modelGen/autoload.js?bokeh-autoload-element=1004&bokeh-app-path=/bokeh/modelGen&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 20.58ms

2019-03-10 20:56:54,261 Found credentials in shared credentials file: ~/.aws/credentials

2019-03-10 20:56:54,373 root_url should end with a /, adding one

2019-03-10 20:56:54,376 200 GET /bokeh/runFEA/autoload.js?bokeh-autoload-element=1005&bokeh-app-path=/bokeh/runFEA&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 249.74ms

2019-03-10 20:56:54,400 root_url should end with a /, adding one

2019-03-10 20:56:54,402 200 GET /bokeh/matProp/autoload.js?bokeh-autoload-element=1002&bokeh-app-path=/bokeh/matProp&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 25.32ms

2019-03-10 20:56:54,416 root_url should end with a /, adding one

2019-03-10 20:56:54,419 200 GET /bokeh/windSeq/autoload.js?bokeh-autoload-element=1003&bokeh-app-path=/bokeh/windSeq&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 16.18ms

2019-03-10 20:56:54,423 root_url should end with a /, adding one

2019-03-10 20:56:54,425 200 GET /bokeh/contourPlots/autoload.js?bokeh-autoload-element=1006&bokeh-app-path=/bokeh/contourPlots&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 4.67ms

2019-03-10 20:56:54,428 root_url should end with a /, adding one

2019-03-10 20:56:54,429 200 GET /bokeh/interactModel/autoload.js?bokeh-autoload-element=1007&bokeh-app-path=/bokeh/interactModel&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 4.13ms

2019-03-10 20:56:54,432 root_url should end with a /, adding one

2019-03-10 20:56:54,434 200 GET /bokeh/viewMovie/autoload.js?bokeh-autoload-element=1008&bokeh-app-path=/bokeh/viewMovie&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 3.70ms

2019-03-10 20:56:54,616 101 GET /bokeh/designData/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.78ms

2019-03-10 20:56:54,617 WebSocket connection opened

2019-03-10 20:56:54,617 ServerConnection created

2019-03-10 20:56:54,629 101 GET /bokeh/domeProfile/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.72ms

2019-03-10 20:56:54,629 WebSocket connection opened

2019-03-10 20:56:54,630 ServerConnection created

2019-03-10 20:56:54,642 101 GET /bokeh/matProp/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.65ms

2019-03-10 20:56:54,642 WebSocket connection opened

2019-03-10 20:56:54,642 ServerConnection created

2019-03-10 20:56:54,655 101 GET /bokeh/windSeq/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.75ms

2019-03-10 20:56:54,655 WebSocket connection opened

2019-03-10 20:56:54,655 ServerConnection created

2019-03-10 20:56:54,670 101 GET /bokeh/modelGen/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.70ms

2019-03-10 20:56:54,671 WebSocket connection opened

2019-03-10 20:56:54,671 ServerConnection created

2019-03-10 20:56:54,692 101 GET /bokeh/runFEA/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.58ms

2019-03-10 20:56:54,693 WebSocket connection opened

2019-03-10 20:56:54,693 ServerConnection created

2019-03-10 20:56:54,707 101 GET /bokeh/contourPlots/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.61ms

2019-03-10 20:56:54,708 WebSocket connection opened

2019-03-10 20:56:54,708 ServerConnection created

2019-03-10 20:56:54,719 101 GET /bokeh/interactModel/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.47ms

2019-03-10 20:56:54,719 WebSocket connection opened

2019-03-10 20:56:54,720 ServerConnection created

2019-03-10 20:56:54,732 101 GET /bokeh/viewMovie/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.50ms

2019-03-10 20:56:54,732 WebSocket connection opened

2019-03-10 20:56:54,732 ServerConnection created

2019-03-10 20:58:07,307 Failed sending message as connection was closed

2019-03-10 20:58:07,309 WebSocket connection closed: code=None, reason=None

2019-03-10 20:58:07,310 Exception in callback <bound method BokehTornado._keep_alive of <bokeh.server.tornado.BokehTornado object at 0x7f0e2e7d3438>>

Traceback (most recent call last):

File “/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/tornado/ioloop.py”, line 1229, in _run

return self.callback()

File “/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/bokeh/server/tornado.py”, line 514, in _keep_alive

c.send_ping()

File “/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/bokeh/server/connection.py”, line 46, in send_ping

self._socket.ping(codecs.encode(str(self._ping_count), “utf-8”))

File “/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/tornado/websocket.py”, line 367, in ping

self.ws_connection.write_ping(data)

File “/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/tornado/websocket.py”, line 882, in write_ping

self._write_frame(True, 0x9, data)

File “/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/tornado/websocket.py”, line 846, in _write_frame

return self.stream.write(frame)

File “/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/tornado/iostream.py”, line 570, in write

self._check_closed()

File “/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/tornado/iostream.py”, line 1112, in _check_closed

raise StreamClosedError(real_error=self.error)

tornado.iostream.StreamClosedError: Stream is closed

2019-03-10 20:58:07,316 WebSocket connection closed: code=None, reason=None

2019-03-10 20:58:07,317 WebSocket connection closed: code=None, reason=None

2019-03-10 20:58:07,318 WebSocket connection closed: code=None, reason=None

2019-03-10 20:58:07,318 WebSocket connection closed: code=None, reason=None

2019-03-10 20:58:07,319 WebSocket connection closed: code=None, reason=None

2019-03-10 20:58:07,320 WebSocket connection closed: code=None, reason=None

2019-03-10 20:58:07,320 WebSocket connection closed: code=None, reason=None

2019-03-10 20:58:07,320 WebSocket connection closed: code=None, reason=None

``

Hi,

It's not really possible to speculate without some idea of the actual code involved, ideally a *minimal* reproducer that other people can run themselves to investigate.

Thanks,

Bryan

···

On Mar 10, 2019, at 2:04 PM, [email protected] wrote:

I want t run a flask site calling bokeh server that streams data from computations occur. The standalone bokeh server works great and streams data perfectly. However, when I have the same bokeh server embedded in a flask site, I get this strange error below. Can someone please take a look and advice what I can tweak or change to avoid this error?
Thanks a lot in advance.

2019-03-10 20:56:47,167 Starting Bokeh server with process id: 8905
2019-03-10 20:56:54,066 root_url should end with a /, adding one
2019-03-10 20:56:54,073 200 GET /bokeh/designData/autoload.js?bokeh-autoload-element=1000&bokeh-app-path=/bokeh/designData&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 236.03ms
2019-03-10 20:56:54,102 root_url should end with a /, adding one
2019-03-10 20:56:54,104 200 GET /bokeh/domeProfile/autoload.js?bokeh-autoload-element=1001&bokeh-app-path=/bokeh/domeProfile&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 30.60ms
2019-03-10 20:56:54,123 root_url should end with a /, adding one
2019-03-10 20:56:54,125 200 GET /bokeh/modelGen/autoload.js?bokeh-autoload-element=1004&bokeh-app-path=/bokeh/modelGen&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 20.58ms
2019-03-10 20:56:54,261 Found credentials in shared credentials file: ~/.aws/credentials
2019-03-10 20:56:54,373 root_url should end with a /, adding one
2019-03-10 20:56:54,376 200 GET /bokeh/runFEA/autoload.js?bokeh-autoload-element=1005&bokeh-app-path=/bokeh/runFEA&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 249.74ms
2019-03-10 20:56:54,400 root_url should end with a /, adding one
2019-03-10 20:56:54,402 200 GET /bokeh/matProp/autoload.js?bokeh-autoload-element=1002&bokeh-app-path=/bokeh/matProp&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 25.32ms
2019-03-10 20:56:54,416 root_url should end with a /, adding one
2019-03-10 20:56:54,419 200 GET /bokeh/windSeq/autoload.js?bokeh-autoload-element=1003&bokeh-app-path=/bokeh/windSeq&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 16.18ms
2019-03-10 20:56:54,423 root_url should end with a /, adding one
2019-03-10 20:56:54,425 200 GET /bokeh/contourPlots/autoload.js?bokeh-autoload-element=1006&bokeh-app-path=/bokeh/contourPlots&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 4.67ms
2019-03-10 20:56:54,428 root_url should end with a /, adding one
2019-03-10 20:56:54,429 200 GET /bokeh/interactModel/autoload.js?bokeh-autoload-element=1007&bokeh-app-path=/bokeh/interactModel&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 4.13ms
2019-03-10 20:56:54,432 root_url should end with a /, adding one
2019-03-10 20:56:54,434 200 GET /bokeh/viewMovie/autoload.js?bokeh-autoload-element=1008&bokeh-app-path=/bokeh/viewMovie&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 3.70ms
2019-03-10 20:56:54,616 101 GET /bokeh/designData/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.78ms
2019-03-10 20:56:54,617 WebSocket connection opened
2019-03-10 20:56:54,617 ServerConnection created
2019-03-10 20:56:54,629 101 GET /bokeh/domeProfile/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.72ms
2019-03-10 20:56:54,629 WebSocket connection opened
2019-03-10 20:56:54,630 ServerConnection created
2019-03-10 20:56:54,642 101 GET /bokeh/matProp/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.65ms
2019-03-10 20:56:54,642 WebSocket connection opened
2019-03-10 20:56:54,642 ServerConnection created
2019-03-10 20:56:54,655 101 GET /bokeh/windSeq/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.75ms
2019-03-10 20:56:54,655 WebSocket connection opened
2019-03-10 20:56:54,655 ServerConnection created
2019-03-10 20:56:54,670 101 GET /bokeh/modelGen/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.70ms
2019-03-10 20:56:54,671 WebSocket connection opened
2019-03-10 20:56:54,671 ServerConnection created
2019-03-10 20:56:54,692 101 GET /bokeh/runFEA/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.58ms
2019-03-10 20:56:54,693 WebSocket connection opened
2019-03-10 20:56:54,693 ServerConnection created
2019-03-10 20:56:54,707 101 GET /bokeh/contourPlots/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.61ms
2019-03-10 20:56:54,708 WebSocket connection opened
2019-03-10 20:56:54,708 ServerConnection created
2019-03-10 20:56:54,719 101 GET /bokeh/interactModel/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.47ms
2019-03-10 20:56:54,719 WebSocket connection opened
2019-03-10 20:56:54,720 ServerConnection created
2019-03-10 20:56:54,732 101 GET /bokeh/viewMovie/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.50ms
2019-03-10 20:56:54,732 WebSocket connection opened
2019-03-10 20:56:54,732 ServerConnection created
2019-03-10 20:58:07,307 Failed sending message as connection was closed
2019-03-10 20:58:07,309 WebSocket connection closed: code=None, reason=None
2019-03-10 20:58:07,310 Exception in callback <bound method BokehTornado._keep_alive of <bokeh.server.tornado.BokehTornado object at 0x7f0e2e7d3438>>
Traceback (most recent call last):
  File "/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/tornado/ioloop.py", line 1229, in _run
    return self.callback()
  File "/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/bokeh/server/tornado.py", line 514, in _keep_alive
    c.send_ping()
  File "/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/bokeh/server/connection.py", line 46, in send_ping
    self._socket.ping(codecs.encode(str(self._ping_count), "utf-8"))
  File "/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/tornado/websocket.py", line 367, in ping
    self.ws_connection.write_ping(data)
  File "/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/tornado/websocket.py", line 882, in write_ping
    self._write_frame(True, 0x9, data)
  File "/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/tornado/websocket.py", line 846, in _write_frame
    return self.stream.write(frame)
  File "/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/tornado/iostream.py", line 570, in write
    self._check_closed()
  File "/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/tornado/iostream.py", line 1112, in _check_closed
    raise StreamClosedError(real_error=self.error)
tornado.iostream.StreamClosedError: Stream is closed
2019-03-10 20:58:07,316 WebSocket connection closed: code=None, reason=None
2019-03-10 20:58:07,317 WebSocket connection closed: code=None, reason=None
2019-03-10 20:58:07,318 WebSocket connection closed: code=None, reason=None
2019-03-10 20:58:07,318 WebSocket connection closed: code=None, reason=None
2019-03-10 20:58:07,319 WebSocket connection closed: code=None, reason=None
2019-03-10 20:58:07,320 WebSocket connection closed: code=None, reason=None
2019-03-10 20:58:07,320 WebSocket connection closed: code=None, reason=None
2019-03-10 20:58:07,320 WebSocket connection closed: code=None, reason=None

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/4cdd2ae7-ecca-4df1-8889-fe585bc5b915%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

OK I can understand that. I wish I could create a “minimal reproducer” but unfortunately it would be hard to reproduce because of the code base hosted on Amazon EC2 as you will see below. I am hoping I have detailed the main idea below and I can generate any diagnostics if requested.

I have a flask app, that calls the bokeh server like this:

s_id = session_id.generate_session_id()

@app.route(’/appPage’, methods=[‘GET’])

def appPage():

if current_user.is_authenticated:

script = server_session(session_id=s_id, url=“http://www.site.com/bokeh/myapp”,relative_urls=True)
return render_template(“appPage.html”, script=script, template=“Flask”)

``

And I run my bokeh server like this via supervisor:

bokeh serve myapp --address=127.0.0.1 --port 5100 --allow-websocket-origin=localhost --allow-websocket-origin=site.com --prefix /bokeh --session-ids external-signed --disable-index --disable-index-redirect --use-xheaders

``

The myapp script fires up computation on an Amazon instance that generates data points x-y data points from files written to a NFS (Amazn EFS) share. The script then creates a column data source (CDS) from those x-y points and streams to a plot. The data volume is paltry.

As I mentioned before, the bokeh sever and myapp.py works just fine together and shows the streaming data in the plot. However, when I have the flask app calling the bokeh server, I get the “Websocket connection closed: code=None, reason=None” error in the log file with a blank plot. The data files are generated in the background just fine, just simply no streaming plot.

I have also tried adding all of the following three options to my bokeh serve command, but no luck:

--keep-alive
--check-unused-sessions
--unused-session-lifetime

Let me know if I can provide anything else.

···

On Sunday, March 10, 2019 at 11:35:36 PM UTC, Bryan Van de ven wrote:

Hi,

It’s not really possible to speculate without some idea of the actual code involved, ideally a minimal reproducer that other people can run themselves to investigate.

Thanks,

Bryan

On Mar 10, 2019, at 2:04 PM, [email protected] wrote:

I want t run a flask site calling bokeh server that streams data from computations occur. The standalone bokeh server works great and streams data perfectly. However, when I have the same bokeh server embedded in a flask site, I get this strange error below. Can someone please take a look and advice what I can tweak or change to avoid this error?

Thanks a lot in advance.

2019-03-10 20:56:47,167 Starting Bokeh server with process id: 8905

2019-03-10 20:56:54,066 root_url should end with a /, adding one

2019-03-10 20:56:54,073 200 GET /bokeh/designData/autoload.js?bokeh-autoload-element=1000&bokeh-app-path=/bokeh/designData&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 236.03ms

2019-03-10 20:56:54,102 root_url should end with a /, adding one

2019-03-10 20:56:54,104 200 GET /bokeh/domeProfile/autoload.js?bokeh-autoload-element=1001&bokeh-app-path=/bokeh/domeProfile&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 30.60ms

2019-03-10 20:56:54,123 root_url should end with a /, adding one

2019-03-10 20:56:54,125 200 GET /bokeh/modelGen/autoload.js?bokeh-autoload-element=1004&bokeh-app-path=/bokeh/modelGen&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 20.58ms

2019-03-10 20:56:54,261 Found credentials in shared credentials file: ~/.aws/credentials

2019-03-10 20:56:54,373 root_url should end with a /, adding one

2019-03-10 20:56:54,376 200 GET /bokeh/runFEA/autoload.js?bokeh-autoload-element=1005&bokeh-app-path=/bokeh/runFEA&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 249.74ms

2019-03-10 20:56:54,400 root_url should end with a /, adding one

2019-03-10 20:56:54,402 200 GET /bokeh/matProp/autoload.js?bokeh-autoload-element=1002&bokeh-app-path=/bokeh/matProp&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 25.32ms

2019-03-10 20:56:54,416 root_url should end with a /, adding one

2019-03-10 20:56:54,419 200 GET /bokeh/windSeq/autoload.js?bokeh-autoload-element=1003&bokeh-app-path=/bokeh/windSeq&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 16.18ms

2019-03-10 20:56:54,423 root_url should end with a /, adding one

2019-03-10 20:56:54,425 200 GET /bokeh/contourPlots/autoload.js?bokeh-autoload-element=1006&bokeh-app-path=/bokeh/contourPlots&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 4.67ms

2019-03-10 20:56:54,428 root_url should end with a /, adding one

2019-03-10 20:56:54,429 200 GET /bokeh/interactModel/autoload.js?bokeh-autoload-element=1007&bokeh-app-path=/bokeh/interactModel&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 4.13ms

2019-03-10 20:56:54,432 root_url should end with a /, adding one

2019-03-10 20:56:54,434 200 GET /bokeh/viewMovie/autoload.js?bokeh-autoload-element=1008&bokeh-app-path=/bokeh/viewMovie&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 3.70ms

2019-03-10 20:56:54,616 101 GET /bokeh/designData/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.78ms

2019-03-10 20:56:54,617 WebSocket connection opened

2019-03-10 20:56:54,617 ServerConnection created

2019-03-10 20:56:54,629 101 GET /bokeh/domeProfile/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.72ms

2019-03-10 20:56:54,629 WebSocket connection opened

2019-03-10 20:56:54,630 ServerConnection created

2019-03-10 20:56:54,642 101 GET /bokeh/matProp/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.65ms

2019-03-10 20:56:54,642 WebSocket connection opened

2019-03-10 20:56:54,642 ServerConnection created

2019-03-10 20:56:54,655 101 GET /bokeh/windSeq/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.75ms

2019-03-10 20:56:54,655 WebSocket connection opened

2019-03-10 20:56:54,655 ServerConnection created

2019-03-10 20:56:54,670 101 GET /bokeh/modelGen/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.70ms

2019-03-10 20:56:54,671 WebSocket connection opened

2019-03-10 20:56:54,671 ServerConnection created

2019-03-10 20:56:54,692 101 GET /bokeh/runFEA/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.58ms

2019-03-10 20:56:54,693 WebSocket connection opened

2019-03-10 20:56:54,693 ServerConnection created

2019-03-10 20:56:54,707 101 GET /bokeh/contourPlots/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.61ms

2019-03-10 20:56:54,708 WebSocket connection opened

2019-03-10 20:56:54,708 ServerConnection created

2019-03-10 20:56:54,719 101 GET /bokeh/interactModel/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.47ms

2019-03-10 20:56:54,719 WebSocket connection opened

2019-03-10 20:56:54,720 ServerConnection created

2019-03-10 20:56:54,732 101 GET /bokeh/viewMovie/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.50ms

2019-03-10 20:56:54,732 WebSocket connection opened

2019-03-10 20:56:54,732 ServerConnection created

2019-03-10 20:58:07,307 Failed sending message as connection was closed

2019-03-10 20:58:07,309 WebSocket connection closed: code=None, reason=None

2019-03-10 20:58:07,310 Exception in callback <bound method BokehTornado._keep_alive of <bokeh.server.tornado.BokehTornado object at 0x7f0e2e7d3438>>

Traceback (most recent call last):

File “/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/tornado/ioloop.py”, line 1229, in _run

return self.callback()

File “/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/bokeh/server/tornado.py”, line 514, in _keep_alive

c.send_ping()

File “/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/bokeh/server/connection.py”, line 46, in send_ping

self._socket.ping(codecs.encode(str(self._ping_count), "utf-8"))

File “/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/tornado/websocket.py”, line 367, in ping

self.ws_connection.write_ping(data)

File “/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/tornado/websocket.py”, line 882, in write_ping

self._write_frame(True, 0x9, data)

File “/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/tornado/websocket.py”, line 846, in _write_frame

return self.stream.write(frame)

File “/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/tornado/iostream.py”, line 570, in write

self._check_closed()

File “/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/tornado/iostream.py”, line 1112, in _check_closed

raise StreamClosedError(real_error=self.error)

tornado.iostream.StreamClosedError: Stream is closed

2019-03-10 20:58:07,316 WebSocket connection closed: code=None, reason=None

2019-03-10 20:58:07,317 WebSocket connection closed: code=None, reason=None

2019-03-10 20:58:07,318 WebSocket connection closed: code=None, reason=None

2019-03-10 20:58:07,318 WebSocket connection closed: code=None, reason=None

2019-03-10 20:58:07,319 WebSocket connection closed: code=None, reason=None

2019-03-10 20:58:07,320 WebSocket connection closed: code=None, reason=None

2019-03-10 20:58:07,320 WebSocket connection closed: code=None, reason=None

2019-03-10 20:58:07,320 WebSocket connection closed: code=None, reason=None


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/4cdd2ae7-ecca-4df1-8889-fe585bc5b915%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi,

When you say "bokeh sever and myapp.py works just fine together" do you mean locally they work fine? Or they also work fine from AWS? If the former, then offhand my first suggestion is to make sure that AWS is not blowing the websocket connections. Typically you have to set up a security rule to allow TCP traffic, not just HTTP.

Thanks,

Bryan

···

On Mar 10, 2019, at 5:43 PM, [email protected] wrote:

OK I can understand that. I wish I could create a "minimal reproducer" but unfortunately it would be hard to reproduce because of the code base hosted on Amazon EC2 as you will see below. I am hoping I have detailed the main idea below and I can generate any diagnostics if requested.

I have a flask app, that calls the bokeh server like this:

s_id = session_id.generate_session_id()
@app.route('/appPage', methods=['GET'])
def appPage():

    if current_user.is_authenticated:
               script = server_session(session_id=s_id, url=“http://www.site.com/bokeh/myapp”,relative_urls=True)
               return render_template(“appPage.html”, script=script, template=“Flask”)

And I run my bokeh server like this via supervisor:

bokeh serve myapp --address=127.0.0.1 --port 5100 --allow-websocket-origin=localhost --allow-websocket-origin=site.com --prefix /bokeh --session-ids external-signed --disable-index --disable-index-redirect --use-xheaders

The myapp script fires up computation on an Amazon instance that generates data points x-y data points from files written to a NFS (Amazn EFS) share. The script then creates a column data source (CDS) from those x-y points and streams to a plot. The data volume is paltry.

As I mentioned before, the bokeh sever and myapp.py works just fine together and shows the streaming data in the plot. However, when I have the flask app calling the bokeh server, I get the "Websocket connection closed: code=None, reason=None" error in the log file with a blank plot. The data files are generated in the background just fine, just simply no streaming plot.

I have also tried adding all of the following three options to my bokeh serve command, but no luck:

--keep-alive
--check-unused-sessions
--unused-session-lifetime

Let me know if I can provide anything else.

On Sunday, March 10, 2019 at 11:35:36 PM UTC, Bryan Van de ven wrote:
Hi,

It's not really possible to speculate without some idea of the actual code involved, ideally a *minimal* reproducer that other people can run themselves to investigate.

Thanks,

Bryan

> On Mar 10, 2019, at 2:04 PM, [email protected] wrote:
>
> I want t run a flask site calling bokeh server that streams data from computations occur. The standalone bokeh server works great and streams data perfectly. However, when I have the same bokeh server embedded in a flask site, I get this strange error below. Can someone please take a look and advice what I can tweak or change to avoid this error?
> Thanks a lot in advance.
>
> 2019-03-10 20:56:47,167 Starting Bokeh server with process id: 8905
> 2019-03-10 20:56:54,066 root_url should end with a /, adding one
> 2019-03-10 20:56:54,073 200 GET /bokeh/designData/autoload.js?bokeh-autoload-element=1000&bokeh-app-path=/bokeh/designData&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 236.03ms
> 2019-03-10 20:56:54,102 root_url should end with a /, adding one
> 2019-03-10 20:56:54,104 200 GET /bokeh/domeProfile/autoload.js?bokeh-autoload-element=1001&bokeh-app-path=/bokeh/domeProfile&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 30.60ms
> 2019-03-10 20:56:54,123 root_url should end with a /, adding one
> 2019-03-10 20:56:54,125 200 GET /bokeh/modelGen/autoload.js?bokeh-autoload-element=1004&bokeh-app-path=/bokeh/modelGen&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 20.58ms
> 2019-03-10 20:56:54,261 Found credentials in shared credentials file: ~/.aws/credentials
> 2019-03-10 20:56:54,373 root_url should end with a /, adding one
> 2019-03-10 20:56:54,376 200 GET /bokeh/runFEA/autoload.js?bokeh-autoload-element=1005&bokeh-app-path=/bokeh/runFEA&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 249.74ms
> 2019-03-10 20:56:54,400 root_url should end with a /, adding one
> 2019-03-10 20:56:54,402 200 GET /bokeh/matProp/autoload.js?bokeh-autoload-element=1002&bokeh-app-path=/bokeh/matProp&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 25.32ms
> 2019-03-10 20:56:54,416 root_url should end with a /, adding one
> 2019-03-10 20:56:54,419 200 GET /bokeh/windSeq/autoload.js?bokeh-autoload-element=1003&bokeh-app-path=/bokeh/windSeq&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 16.18ms
> 2019-03-10 20:56:54,423 root_url should end with a /, adding one
> 2019-03-10 20:56:54,425 200 GET /bokeh/contourPlots/autoload.js?bokeh-autoload-element=1006&bokeh-app-path=/bokeh/contourPlots&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 4.67ms
> 2019-03-10 20:56:54,428 root_url should end with a /, adding one
> 2019-03-10 20:56:54,429 200 GET /bokeh/interactModel/autoload.js?bokeh-autoload-element=1007&bokeh-app-path=/bokeh/interactModel&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 4.13ms
> 2019-03-10 20:56:54,432 root_url should end with a /, adding one
> 2019-03-10 20:56:54,434 200 GET /bokeh/viewMovie/autoload.js?bokeh-autoload-element=1008&bokeh-app-path=/bokeh/viewMovie&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 3.70ms
> 2019-03-10 20:56:54,616 101 GET /bokeh/designData/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.78ms
> 2019-03-10 20:56:54,617 WebSocket connection opened
> 2019-03-10 20:56:54,617 ServerConnection created
> 2019-03-10 20:56:54,629 101 GET /bokeh/domeProfile/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.72ms
> 2019-03-10 20:56:54,629 WebSocket connection opened
> 2019-03-10 20:56:54,630 ServerConnection created
> 2019-03-10 20:56:54,642 101 GET /bokeh/matProp/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.65ms
> 2019-03-10 20:56:54,642 WebSocket connection opened
> 2019-03-10 20:56:54,642 ServerConnection created
> 2019-03-10 20:56:54,655 101 GET /bokeh/windSeq/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.75ms
> 2019-03-10 20:56:54,655 WebSocket connection opened
> 2019-03-10 20:56:54,655 ServerConnection created
> 2019-03-10 20:56:54,670 101 GET /bokeh/modelGen/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.70ms
> 2019-03-10 20:56:54,671 WebSocket connection opened
> 2019-03-10 20:56:54,671 ServerConnection created
> 2019-03-10 20:56:54,692 101 GET /bokeh/runFEA/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.58ms
> 2019-03-10 20:56:54,693 WebSocket connection opened
> 2019-03-10 20:56:54,693 ServerConnection created
> 2019-03-10 20:56:54,707 101 GET /bokeh/contourPlots/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.61ms
> 2019-03-10 20:56:54,708 WebSocket connection opened
> 2019-03-10 20:56:54,708 ServerConnection created
> 2019-03-10 20:56:54,719 101 GET /bokeh/interactModel/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.47ms
> 2019-03-10 20:56:54,719 WebSocket connection opened
> 2019-03-10 20:56:54,720 ServerConnection created
> 2019-03-10 20:56:54,732 101 GET /bokeh/viewMovie/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.50ms
> 2019-03-10 20:56:54,732 WebSocket connection opened
> 2019-03-10 20:56:54,732 ServerConnection created
> 2019-03-10 20:58:07,307 Failed sending message as connection was closed
> 2019-03-10 20:58:07,309 WebSocket connection closed: code=None, reason=None
> 2019-03-10 20:58:07,310 Exception in callback <bound method BokehTornado._keep_alive of <bokeh.server.tornado.BokehTornado object at 0x7f0e2e7d3438>>
> Traceback (most recent call last):
> File "/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/tornado/ioloop.py", line 1229, in _run
> return self.callback()
> File "/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/bokeh/server/tornado.py", line 514, in _keep_alive
> c.send_ping()
> File "/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/bokeh/server/connection.py", line 46, in send_ping
> self._socket.ping(codecs.encode(str(self._ping_count), "utf-8"))
> File "/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/tornado/websocket.py", line 367, in ping
> self.ws_connection.write_ping(data)
> File "/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/tornado/websocket.py", line 882, in write_ping
> self._write_frame(True, 0x9, data)
> File "/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/tornado/websocket.py", line 846, in _write_frame
> return self.stream.write(frame)
> File "/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/tornado/iostream.py", line 570, in write
> self._check_closed()
> File "/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/tornado/iostream.py", line 1112, in _check_closed
> raise StreamClosedError(real_error=self.error)
> tornado.iostream.StreamClosedError: Stream is closed
> 2019-03-10 20:58:07,316 WebSocket connection closed: code=None, reason=None
> 2019-03-10 20:58:07,317 WebSocket connection closed: code=None, reason=None
> 2019-03-10 20:58:07,318 WebSocket connection closed: code=None, reason=None
> 2019-03-10 20:58:07,318 WebSocket connection closed: code=None, reason=None
> 2019-03-10 20:58:07,319 WebSocket connection closed: code=None, reason=None
> 2019-03-10 20:58:07,320 WebSocket connection closed: code=None, reason=None
> 2019-03-10 20:58:07,320 WebSocket connection closed: code=None, reason=None
> 2019-03-10 20:58:07,320 WebSocket connection closed: code=None, reason=None
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/4cdd2ae7-ecca-4df1-8889-fe585bc5b915%40continuum.io.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout.

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/e046b61f-e26a-42fa-8db9-e358c4486526%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Should be: not blocking the websocket connections

···

On Mar 10, 2019, at 6:39 PM, Bryan Van de ven <[email protected]> wrote:

Hi,

When you say "bokeh sever and myapp.py works just fine together" do you mean locally they work fine? Or they also work fine from AWS? If the former, then offhand my first suggestion is to make sure that AWS is not blowing the websocket connections. Typically you have to set up a security rule to allow TCP traffic, not just HTTP.

Thanks,

Bryan

On Mar 10, 2019, at 5:43 PM, [email protected] wrote:

OK I can understand that. I wish I could create a "minimal reproducer" but unfortunately it would be hard to reproduce because of the code base hosted on Amazon EC2 as you will see below. I am hoping I have detailed the main idea below and I can generate any diagnostics if requested.

I have a flask app, that calls the bokeh server like this:

s_id = session_id.generate_session_id()
@app.route('/appPage', methods=['GET'])
def appPage():

   if current_user.is_authenticated:
              script = server_session(session_id=s_id, url=“http://www.site.com/bokeh/myapp”,relative_urls=True)
              return render_template(“appPage.html”, script=script, template=“Flask”)

And I run my bokeh server like this via supervisor:

bokeh serve myapp --address=127.0.0.1 --port 5100 --allow-websocket-origin=localhost --allow-websocket-origin=site.com --prefix /bokeh --session-ids external-signed --disable-index --disable-index-redirect --use-xheaders

The myapp script fires up computation on an Amazon instance that generates data points x-y data points from files written to a NFS (Amazn EFS) share. The script then creates a column data source (CDS) from those x-y points and streams to a plot. The data volume is paltry.

As I mentioned before, the bokeh sever and myapp.py works just fine together and shows the streaming data in the plot. However, when I have the flask app calling the bokeh server, I get the "Websocket connection closed: code=None, reason=None" error in the log file with a blank plot. The data files are generated in the background just fine, just simply no streaming plot.

I have also tried adding all of the following three options to my bokeh serve command, but no luck:

--keep-alive
--check-unused-sessions
--unused-session-lifetime

Let me know if I can provide anything else.

On Sunday, March 10, 2019 at 11:35:36 PM UTC, Bryan Van de ven wrote:
Hi,

It's not really possible to speculate without some idea of the actual code involved, ideally a *minimal* reproducer that other people can run themselves to investigate.

Thanks,

Bryan

On Mar 10, 2019, at 2:04 PM, [email protected] wrote:

I want t run a flask site calling bokeh server that streams data from computations occur. The standalone bokeh server works great and streams data perfectly. However, when I have the same bokeh server embedded in a flask site, I get this strange error below. Can someone please take a look and advice what I can tweak or change to avoid this error?
Thanks a lot in advance.

2019-03-10 20:56:47,167 Starting Bokeh server with process id: 8905
2019-03-10 20:56:54,066 root_url should end with a /, adding one
2019-03-10 20:56:54,073 200 GET /bokeh/designData/autoload.js?bokeh-autoload-element=1000&bokeh-app-path=/bokeh/designData&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 236.03ms
2019-03-10 20:56:54,102 root_url should end with a /, adding one
2019-03-10 20:56:54,104 200 GET /bokeh/domeProfile/autoload.js?bokeh-autoload-element=1001&bokeh-app-path=/bokeh/domeProfile&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 30.60ms
2019-03-10 20:56:54,123 root_url should end with a /, adding one
2019-03-10 20:56:54,125 200 GET /bokeh/modelGen/autoload.js?bokeh-autoload-element=1004&bokeh-app-path=/bokeh/modelGen&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 20.58ms
2019-03-10 20:56:54,261 Found credentials in shared credentials file: ~/.aws/credentials
2019-03-10 20:56:54,373 root_url should end with a /, adding one
2019-03-10 20:56:54,376 200 GET /bokeh/runFEA/autoload.js?bokeh-autoload-element=1005&bokeh-app-path=/bokeh/runFEA&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 249.74ms
2019-03-10 20:56:54,400 root_url should end with a /, adding one
2019-03-10 20:56:54,402 200 GET /bokeh/matProp/autoload.js?bokeh-autoload-element=1002&bokeh-app-path=/bokeh/matProp&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 25.32ms
2019-03-10 20:56:54,416 root_url should end with a /, adding one
2019-03-10 20:56:54,419 200 GET /bokeh/windSeq/autoload.js?bokeh-autoload-element=1003&bokeh-app-path=/bokeh/windSeq&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 16.18ms
2019-03-10 20:56:54,423 root_url should end with a /, adding one
2019-03-10 20:56:54,425 200 GET /bokeh/contourPlots/autoload.js?bokeh-autoload-element=1006&bokeh-app-path=/bokeh/contourPlots&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 4.67ms
2019-03-10 20:56:54,428 root_url should end with a /, adding one
2019-03-10 20:56:54,429 200 GET /bokeh/interactModel/autoload.js?bokeh-autoload-element=1007&bokeh-app-path=/bokeh/interactModel&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 4.13ms
2019-03-10 20:56:54,432 root_url should end with a /, adding one
2019-03-10 20:56:54,434 200 GET /bokeh/viewMovie/autoload.js?bokeh-autoload-element=1008&bokeh-app-path=/bokeh/viewMovie&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 3.70ms
2019-03-10 20:56:54,616 101 GET /bokeh/designData/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.78ms
2019-03-10 20:56:54,617 WebSocket connection opened
2019-03-10 20:56:54,617 ServerConnection created
2019-03-10 20:56:54,629 101 GET /bokeh/domeProfile/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.72ms
2019-03-10 20:56:54,629 WebSocket connection opened
2019-03-10 20:56:54,630 ServerConnection created
2019-03-10 20:56:54,642 101 GET /bokeh/matProp/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.65ms
2019-03-10 20:56:54,642 WebSocket connection opened
2019-03-10 20:56:54,642 ServerConnection created
2019-03-10 20:56:54,655 101 GET /bokeh/windSeq/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.75ms
2019-03-10 20:56:54,655 WebSocket connection opened
2019-03-10 20:56:54,655 ServerConnection created
2019-03-10 20:56:54,670 101 GET /bokeh/modelGen/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.70ms
2019-03-10 20:56:54,671 WebSocket connection opened
2019-03-10 20:56:54,671 ServerConnection created
2019-03-10 20:56:54,692 101 GET /bokeh/runFEA/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.58ms
2019-03-10 20:56:54,693 WebSocket connection opened
2019-03-10 20:56:54,693 ServerConnection created
2019-03-10 20:56:54,707 101 GET /bokeh/contourPlots/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.61ms
2019-03-10 20:56:54,708 WebSocket connection opened
2019-03-10 20:56:54,708 ServerConnection created
2019-03-10 20:56:54,719 101 GET /bokeh/interactModel/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.47ms
2019-03-10 20:56:54,719 WebSocket connection opened
2019-03-10 20:56:54,720 ServerConnection created
2019-03-10 20:56:54,732 101 GET /bokeh/viewMovie/ws?bokeh-protocol-version=1.0&bokeh-session-id=Pe0oVVUUwIfunzmfvC13qRbxEAYBSf8cf1GDN40ajQ3e-EA7Ye4tzUZS7hdLtaYEET4LIBStbhIR16kfN1n-IAd8 (34.212.125.218) 0.50ms
2019-03-10 20:56:54,732 WebSocket connection opened
2019-03-10 20:56:54,732 ServerConnection created
2019-03-10 20:58:07,307 Failed sending message as connection was closed
2019-03-10 20:58:07,309 WebSocket connection closed: code=None, reason=None
2019-03-10 20:58:07,310 Exception in callback <bound method BokehTornado._keep_alive of <bokeh.server.tornado.BokehTornado object at 0x7f0e2e7d3438>>
Traceback (most recent call last):
File "/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/tornado/ioloop.py", line 1229, in _run
   return self.callback()
File "/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/bokeh/server/tornado.py", line 514, in _keep_alive
   c.send_ping()
File "/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/bokeh/server/connection.py", line 46, in send_ping
   self._socket.ping(codecs.encode(str(self._ping_count), "utf-8"))
File "/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/tornado/websocket.py", line 367, in ping
   self.ws_connection.write_ping(data)
File "/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/tornado/websocket.py", line 882, in write_ping
   self._write_frame(True, 0x9, data)
File "/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/tornado/websocket.py", line 846, in _write_frame
   return self.stream.write(frame)
File "/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/tornado/iostream.py", line 570, in write
   self._check_closed()
File "/home/ubuntu/.virtualenvs/cpvdesign_env/lib/python3.6/site-packages/tornado/iostream.py", line 1112, in _check_closed
   raise StreamClosedError(real_error=self.error)
tornado.iostream.StreamClosedError: Stream is closed
2019-03-10 20:58:07,316 WebSocket connection closed: code=None, reason=None
2019-03-10 20:58:07,317 WebSocket connection closed: code=None, reason=None
2019-03-10 20:58:07,318 WebSocket connection closed: code=None, reason=None
2019-03-10 20:58:07,318 WebSocket connection closed: code=None, reason=None
2019-03-10 20:58:07,319 WebSocket connection closed: code=None, reason=None
2019-03-10 20:58:07,320 WebSocket connection closed: code=None, reason=None
2019-03-10 20:58:07,320 WebSocket connection closed: code=None, reason=None
2019-03-10 20:58:07,320 WebSocket connection closed: code=None, reason=None

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/4cdd2ae7-ecca-4df1-8889-fe585bc5b915%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/e046b61f-e26a-42fa-8db9-e358c4486526%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.