Spawned user process not visible from other machine

I managed to startup (spawn) jupyter hub from a user connection using c.JupyterHub.authenticator_class = 'firstuseauthenticator.FirstUseAuthenticator'. At the end I get in the browser: " A Jupyter Server is running."

I can look at the output in the shell or log to see, that a server was startet at 127.0.0.1:some_random_port. What I need is, that users from remote can connect and see the ip-address and port of the server.

I added to the config file:

c.ConfigurableHTTPProxy.command = [
    'configurable-http-proxy',
    '--ip', '0.0.0.0',
    '--port', '8002',
    '--api-ip', '127.0.0.1', 
    '--api-port', '8001', 
    '--error-target', 'http://127.0.0.1:8081/hub/error', 
    '--log-level', 'info'
]

but on startup i see
[34m[D 2023-08-23 16:15:27.004 JupyterHub proxy:751]e(Be[m Proxy cmd: ['configurable-http-proxy', '--ip', '0.0.0.0', '--port', '8002', '--api-ip', '127.0.0.1', '--api-port', '8001', '--error-target', 'http://127.0.0.1:8081/hub/error', '--log-level', 'info', '--ip', '', '--port', '8002', '--api-ip', '127.0.0.1', '--api-port', '8001', '--error-target', 'http://127.0.0.1:8081/hub/error', '--log-level', 'info']

This means that somwhere the server sets its own values and ignores mine, because the spanw is still on 127.0.0.1

How to set the configuration to be visible from remote and to give the user the information of the server or better redirect to the running server?

Meanwhile I managed to get ip to 0.0.0.0 - which is from documentation comparable to ’ '.

Nevertheless, How to get finally to the Jupyter server from a remote computer. I think I have a basic lack of understanding but also didn’t find anything in the documentation.

I always end with “A Jupyter Server is running”. Even if I go from local computer to the port mentioned in the logfile or log output, e.g. [I 2023-08-24 08:16:50,837 configurable_http_proxy] Adding route /user/user02 -> http://127.0.0.1:46897 there is no Jupyter on this port.

How does it finally work or where is the part in the documentation how to get finally to the server and do Python stuff.

This is my full config file for jupyterhub:

# Configuration file for jupyterhub.

c = get_config()  #noqa

c.JupyterHub.extra_log_file = '/home/jupyteruser/jupyter/log/jupyterhub.log'

c.JupyterHub.bind_url = 'http://0.0.0.0:8002'

import os
users_base_path = '/home/jupyteruser/jupyter/users'
def set_user_environment(spawner):
    username = spawner.user.name
    os.environ['PATH'] = f'{users_base_path}/{username}/bin:{os.environ["PATH"]}'
    os.environ['LD_LIBRARY_PATH'] = f'/home/jupyteruser/jupyter/instantclient_19_5'

c.Spawner.pre_spawn_hook = set_user_environment

c.JupyterHub.authenticator_class = 'firstuseauthenticator.FirstUseAuthenticator'

c.Authenticator.whitelist = {'user01', 'user02', 'user03'} 

c.Spawner.notebook_dir = '/home/jupyteruser/jupyter/users/{username}'
c.Spawner.concurrent_spawn_limit = 20

c.Spawner.dummy_passwords = {
    'user01': 'pwdUser01',
    'user02': 'pwdUser02',
    'user03': 'pwdUser03'
}

from jupyterhub.spawner import SimpleLocalProcessSpawner
c.JupyterHub.spawner_class = SimpleLocalProcessSpawner

All other rows are commented out, i.e. go with default behaviour.

1 Like

A message A Jupyter Server is running typically means that the spawner started just a jupyter_server. To give a bit of background, jupyter_server is the backend server that is used for jupyterlab and notebook interfaces. So, what I assume is that your single user environments do not have jupyterlab/notebook or your single user environments are not properly configured and hence, JupyterHub is starting just the backend jupyter_server. That is why you do not see anything except the message A Jupyter Server is running.

So check if your single user environment is properly configured.

Instead of using pre_spawn_hook use Spawner.environment to setup the user env variables. I dont think env variables setup in pre_spawn_hook will be propagated to single user servers. You can use a custom spawner based on SimpleLocalProcessSpawner in config

from jupyterhub.spawner import SimpleLocalProcessSpawner
import os

class MyCustomSpawner(SimpleLocalProcessSpawner):

     def get_env(self):
           super().get_env()
           users_base_path = '/home/jupyteruser/jupyter/users'
           username = self.user.name
           env['PATH'] = f'{users_base_path}/{username}/bin:{os.environ["PATH"]}'
           env['LD_LIBRARY_PATH'] = f'/home/jupyteruser/jupyter/instantclient_19_5'
     return env
c.JupyterHub.spawner_class = 'MyCustomSpawner'

Try this approach and let us know.

2 Likes

Opened another thread for this to avoid confusion: Redirect to notebook not working

Don’t know how to close this thread.