[SOLVED] Cannot log into the NRP with the virtual coach


#1

Hello,
I am trying to access the NRP from a jupyter notebook in the backend container (docker installation on Ubuntu 20.04).

After successful import of the virtual coach, when I run the line
vc = VirtualCoach('http://localhost:9000', storage_username='nrpuser', storage_password='password')
I get:

NFO: [2022-04-19 11:51:59,128 - Configuration] Loading configuration file config.json
WARNING: [2022-04-19 11:51:59,130 - VirtualCoach] No OIDC username supplied, simulation services will fail if OIDC is enabled in this environment (http://localhost:9000).
INFO: [2022-04-19 11:51:59,130 - VirtualCoach] Logging into the Storage Server as: nrpuser
---------------------------------------------------------------------------
ConnectionRefusedError                    Traceback (most recent call last)
~/.opt/platform_venv/lib/python3.8/site-packages/urllib3/connection.py in _new_conn(self)
    158         try:
--> 159             conn = connection.create_connection(
    160                 (self._dns_host, self.port), self.timeout, **extra_kw

~/.opt/platform_venv/lib/python3.8/site-packages/urllib3/util/connection.py in create_connection(address, timeout, source_address, socket_options)
     83     if err is not None:
---> 84         raise err
     85 

~/.opt/platform_venv/lib/python3.8/site-packages/urllib3/util/connection.py in create_connection(address, timeout, source_address, socket_options)
     73                 sock.bind(source_address)
---> 74             sock.connect(sa)
     75             return sock

ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

NewConnectionError                        Traceback (most recent call last)
~/.opt/platform_venv/lib/python3.8/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    669             # Make the request on the httplib connection object.
--> 670             httplib_response = self._make_request(
    671                 conn,

~/.opt/platform_venv/lib/python3.8/site-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
    391         else:
--> 392             conn.request(method, url, **httplib_request_kw)
    393 

/usr/lib/python3.8/http/client.py in request(self, method, url, body, headers, encode_chunked)
   1251         """Send a complete request to the server."""
-> 1252         self._send_request(method, url, body, headers, encode_chunked)
   1253 

/usr/lib/python3.8/http/client.py in _send_request(self, method, url, body, headers, encode_chunked)
   1297             body = _encode(body, 'body')
-> 1298         self.endheaders(body, encode_chunked=encode_chunked)
   1299 

/usr/lib/python3.8/http/client.py in endheaders(self, message_body, encode_chunked)
   1246             raise CannotSendHeader()
-> 1247         self._send_output(message_body, encode_chunked=encode_chunked)
   1248 

/usr/lib/python3.8/http/client.py in _send_output(self, message_body, encode_chunked)
   1006         del self._buffer[:]
-> 1007         self.send(msg)
   1008 

/usr/lib/python3.8/http/client.py in send(self, data)
    946             if self.auto_open:
--> 947                 self.connect()
    948             else:

~/.opt/platform_venv/lib/python3.8/site-packages/urllib3/connection.py in connect(self)
    186     def connect(self):
--> 187         conn = self._new_conn()
    188         self._prepare_conn(conn)

~/.opt/platform_venv/lib/python3.8/site-packages/urllib3/connection.py in _new_conn(self)
    170         except SocketError as e:
--> 171             raise NewConnectionError(
    172                 self, "Failed to establish a new connection: %s" % e

NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f9b468be580>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

MaxRetryError                             Traceback (most recent call last)
~/.opt/platform_venv/lib/python3.8/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
    438             if not chunked:
--> 439                 resp = conn.urlopen(
    440                     method=request.method,

~/.opt/platform_venv/lib/python3.8/site-packages/urllib3/connectionpool.py in urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    725 
--> 726             retries = retries.increment(
    727                 method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]

~/.opt/platform_venv/lib/python3.8/site-packages/urllib3/util/retry.py in increment(self, method, url, response, error, _pool, _stacktrace)
    445         if new_retry.is_exhausted():
--> 446             raise MaxRetryError(_pool, url, error or ResponseError(cause))
    447 

MaxRetryError: HTTPConnectionPool(host='localhost', port=9000): Max retries exceeded with url: /proxy/authentication/authenticate (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f9b468be580>: Failed to establish a new connection: [Errno 111] Connection refused'))

During handling of the above exception, another exception occurred:

ConnectionError                           Traceback (most recent call last)
~/nrp/src/VirtualCoach/hbp_nrp_virtual_coach/pynrp/virtual_coach.py in __get_storage_token(self, user_name, password)
    239         try:
--> 240             resp = requests.post(self.__config['proxy-services']['storage-authentication'],
    241                                  json={'user': user_name, 'password': password})

~/.opt/platform_venv/lib/python3.8/site-packages/requests/api.py in post(url, data, json, **kwargs)
    116 
--> 117     return request('post', url, data=data, json=json, **kwargs)
    118 

~/.opt/platform_venv/lib/python3.8/site-packages/requests/api.py in request(method, url, **kwargs)
     60     with sessions.Session() as session:
---> 61         return session.request(method=method, url=url, **kwargs)
     62 

~/.opt/platform_venv/lib/python3.8/site-packages/requests/sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
    541         send_kwargs.update(settings)
--> 542         resp = self.send(prep, **send_kwargs)
    543 

~/.opt/platform_venv/lib/python3.8/site-packages/requests/sessions.py in send(self, request, **kwargs)
    654         # Send the request
--> 655         r = adapter.send(request, **kwargs)
    656 

~/.opt/platform_venv/lib/python3.8/site-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
    515 
--> 516             raise ConnectionError(e, request=request)
    517 

ConnectionError: HTTPConnectionPool(host='localhost', port=9000): Max retries exceeded with url: /proxy/authentication/authenticate (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f9b468be580>: Failed to establish a new connection: [Errno 111] Connection refused'))

During handling of the above exception, another exception occurred:

Exception                                 Traceback (most recent call last)
<ipython-input-5-21338c2d2121> in <module>
----> 1 vc = VirtualCoach('http://localhost:9000', storage_username='nrpuser', storage_password='password')

~/nrp/src/VirtualCoach/hbp_nrp_virtual_coach/pynrp/virtual_coach.py in __init__(self, environment, oidc_username, oidc_password, oidc_token, storage_username, storage_password)
    127             if not storage_password:
    128                 storage_password = getpass.getpass()
--> 129             token = self.__get_storage_token(storage_username, storage_password)
    130         else:
    131             raise Exception('Virtual Coach instantiated without storage server credentials or oidc'

~/nrp/src/VirtualCoach/hbp_nrp_virtual_coach/pynrp/virtual_coach.py in __get_storage_token(self, user_name, password)
    242         # pylint: disable=broad-except
    243         except Exception as e:
--> 244             raise Exception('Storage Server authentication failed, with exception: {}'.format(e))
    245 
    246         if resp.status_code != 200:

Exception: Storage Server authentication failed, with exception: HTTPConnectionPool(host='localhost', port=9000): Max retries exceeded with url: /proxy/authentication/authenticate (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f9b468be580>: Failed to establish a new connection: [Errno 111] Connection refused'))

Trying to access the NRP online
vc = VirtualCoach('http://148.187.149.212', oidc_username='mmiekus2')
results in:

INFO: [2022-04-19 11:42:02,545 - Configuration] Loading configuration file config.json
INFO: [2022-04-19 11:42:02,547 - VirtualCoach] Logging into OIDC as: mmiekus2
input your OIDC password: ...
---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
<ipython-input-4-b4d276f93385> in <module>
----> 1 vc = VirtualCoach('http://148.187.149.212', oidc_username='mmiekus2')

~/nrp/src/VirtualCoach/hbp_nrp_virtual_coach/pynrp/virtual_coach.py in __init__(self, environment, oidc_username, oidc_password, oidc_token, storage_username, storage_password)
    113                 if not oidc_password:
    114                     oidc_password = getpass.getpass(prompt='input your OIDC password: ')
--> 115                 token = self.__get_oidc_token(oidc_username, oidc_password)
    116             else:
    117                 if self.__oidc_token_is_valid(token):

~/nrp/src/VirtualCoach/hbp_nrp_virtual_coach/pynrp/virtual_coach.py in __get_oidc_token(self, user_name, password)
    212                 break
    213         else:
--> 214             raise Exception('OIDC authorization failed. Probably you used wrong credentials.')
    215 
    216         # the user is forwarded to the approve page if not approved yet

Exception: OIDC authorization failed. Probably you used wrong credentials.

I have no problems with accessing the NRP using the web cockpit (locally and online). My login and password work there.


#2

Hi,

In a docker install, you don’t access an OIDC server to authenticate, so you should use the storage_username and storage_password parameters in the VirtualCoach constructor instead of oidc_username and oidc_password.

Best

More details:
https://neurorobotics.net/Documentation/latest/nrp/modules/VirtualCoach/hbp_nrp_virtual_coach/tutorials/launching_exp.html


#3

Hi, yes, that’s what I used. And that’s the tutorial I’ve been following. Can you help me with the errors I’m getting?

If what you mean here is that I cannot access online NRP from Docker virtual coach, then if would be good if you noted that in the tutorial you linked. It doesn’t solve the problem that I can’t access local NRP, though.


#4

Ah, sorry I overlooked your local trial.
Accessing localhost:9000 works only from your host computer, since the frontend server is mapped to localhost:9000 by docker. But from the backend container, localhost points to the backend container itself. You could try to use the docker IP of the frontend container instead

vc = VirtualCoach('http://<nrp_frontend_docker_ip>:9000', storage_username='nrpuser', storage_password='password')

#5

Thank you. Could you please tell me how to check my frontend IP?


#6

If you open a terminal in your frontend container:

./nrp_installer.sh connect_frontend

and run

ifconfig

there, you will get an IP address from the eth0 block. I got 172.19.0.2.
Now, connecting to your backend container, you should be able to ping the frontend from there

 ./nrp_installer.sh connect_backend
ping 172.19.0.2

It works on my side.


#7

Thank you very much. It works locally now.

Could you please give me more information about the error I am getting when trying to access the online NRP servers? Contrary to what the error message suggests, the credentials I use are correct and work when I try to access the online web cockpit from the browser. Is this some incompatibility because of the docker installation?


#8

Hm, not sure. Checking with the dev tem, since OIDC servers changed recently.
Meanwhile, can you try to give your password from the VC constructor, in case that would help?

vc = VirtualCoach('http://148.187.149.212', oidc_username='<your-hbp-username>', oidc_password='<your-hbp-password>')

#9

Unfortunately, it does not work either.


#10

@mmiekus you should use the exact username/password that you use for logging into http://148.187.149.212/#/esv-private?dev
Do you have the ebrains or HBP account ?


#11

I am using the same credentials when trying to log in here using a browser and I have no problems with that.
I have an ebrains account.


#12

The dev team is reproducing and investigating the issue.
https://hbpneurorobotics.atlassian.net/browse/NUIT-290 (for tracking)


#13

@mmiekus
I think we need to explain the use case here. The main purpose of running your script via Virtual Coach on the online version (http://148.187.149.212) is that you haven’t installed NRP locally (source installation or local docker installation) so you just do pip install pynrp and then you connect to the online server using the provided tutorial. In your case, you have tried to connect to the online server from within the docker, while with docker installation you already have NRP locally installed and you don’t need to connect to the online server.
I hope I could explain well the situation, if you have further questions, please reply here.
Thanks.


#14

Ok, now I understand. Thank you, that seems to be all.