PX4 / flight_review

web application for flight log analysis & review
https://logs.px4.io/
BSD 3-Clause "New" or "Revised" License
206 stars 198 forks source link

Bokeh raises Token is Expired exception #231

Open henrykotze opened 2 years ago

henrykotze commented 2 years ago

For logs which are large, and takes time to fully load the webapp results in Bokeh throwing "Token is expired" exception. This occurs when I run the webapp locally and launch it using the ./serve -f /path/to/ulog.ulg

The console output is the following:

ERROR:tornado.application:Uncaught exception GET /plot_app/ws?log=/home/$USER/Desktop/2022-03-04/05_57_54.ulg (127.0.0.1)
HTTPServerRequest(protocol='http', host='localhost:5006', method='GET', uri='/plot_app/ws?log=/home/$USER//Desktop/2022-03-04/05_57_54.ulg', version='HTTP/1.1', remote_ip='127.0.0.1')
Traceback (most recent call last):
  File "/home/$USER//.local/lib/python3.8/site-packages/tornado/websocket.py", line 954, in _accept_connection
    open_result = handler.open(*handler.open_args, **handler.open_kwargs)
  File "/home/$USER//.local/lib/python3.8/site-packages/tornado/web.py", line 3173, in wrapper
    return method(self, *args, **kwargs)
  File "/home/$USER//.local/lib/python3.8/site-packages/bokeh/server/views/ws.py", line 149, in open
    raise ProtocolError("Token is expired.")
bokeh.protocol.exceptions.ProtocolError: Token is expired.
WARNING:tornado.access:404 GET /favicon.ico (127.0.0.1) 0.88ms

The program than just waits here indefinitely with the web application waiting on "Loading Plots"

bkueng commented 2 years ago

Can you check if there's a timeout we can increase?

henrykotze commented 2 years ago

Here are relevant links which help me solved the issue: bokeh-server-2-0-0-session-expiration-duration slow-response-protocol-exceptions-protocol-error-token-is-expired

I had to increase the DEFAULT_SESSION_TOKEN_EXPIRATION global variable which is used for the parameter session_token_expiration in the BokehTornado object. BokehTornado. Thus I increased the global variable in the bokeh/server/tornado.py file in my local user path.

I dont see a way how to increase this parameter from flight review without extending bokeh to provide access to this variable from the bokeh.server.server object (Server)which is called from the serve.py file.

bkueng commented 2 years ago

It looks like you can just pass it in:

diff --git a/app/serve.py b/app/serve.py
index 0abc47f..6e8293d 100755
--- a/app/serve.py
+++ b/app/serve.py
@@ -95,6 +95,7 @@ server_kwargs['websocket_max_message_size'] = 100 * 1024 * 1024

 # increase the maximum upload size (default is 100MB)
 server_kwargs['http_server_kwargs'] = {'max_buffer_size': 300 * 1024 * 1024}
+server_kwargs['session_token_expiration'] = 300

 show_ulog_file = False
henrykotze commented 2 years ago

Interesting, I thought I tried that, and it didn't work. Will inspect and report.

bkueng commented 1 year ago

Did it work?