-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support having different WS and HTTP urls #57
Conversation
Support having different WS and HTTP urls
@@ -112,7 +112,7 @@ def __init__(self): | |||
@gen.coroutine | |||
def _connect(self, kernel_id): | |||
ws_url = url_path_join( | |||
KG_URL.replace('http', 'ws'), | |||
os.getenv('KG_WS_URL', KG_URL.replace('http', 'ws')), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The notebook server has a configuration option for specifying the websocket URL already:
NotebookApp.websocket_url : Unicode
Default: ''The base URL for websockets, if it differs from the HTTP server (hint: it almost certainly doesn’t).
Should be in the form of an HTTP origin: ws[s]://hostname[:port]
https://jupyter-notebook.readthedocs.io/en/stable/config.html
You should be able to access it via self.settings['websocket_url']
in the handler class where you need it, instead of inventing a new configuration parameter. (See https://github.com/jupyter/notebook/blob/master/notebook/notebookapp.py#L266 for how that setting is populated.)
@parente that setting looks like it only allows you to set the scheme, host and port? The requirement is to be able to set the path. |
I'm pretty sure it allows the path too. It gets passed to the jinja template renderer here: populates the notebook template here: and ultimately gets joined to a kernel path here in the JavaScript: I think that URL join should work fine even if the Can you give it a shot? If it works, we can send a PR to notebook to update the documentation of the |
I've set the parameter
However, I only see http calls in the log output, no ws calls. To enable me to debug this further, is it possible to switch on http/ws trace debugging so the log output shows the actual http/ws requests and responses? Update: I found out that I can debug the ws calls in the browser in a notebook session. |
I've identified some differences in the behavoir ... This works:
This doesn't work:
|
Suggested alt does not work as expected. Let's go with the env var.
@snowch Merging your original since clearly the alternative doesn't do what I think it did. Thanks for experimenting with the command line parameter and your patience. |
Thanks, @parente! No worries - it was a really useful adventure into the jupyter source code for me. The code is starting to feel familiar which is nice :) |
nb2kg does not work when connecting to a host that has different urls for WS and HTTP, for example:
This patch allows users to specify the KG_WS_URL.