Can't access MONAI Label server from 3D Slicer

I’m trying to use 3D Slicer as a visualization tool for MONAI Label. I started up the MONAI Label server using the monailabel CLI in an SSH terminal, and got an IP address of the Uvicorn session:

I then input this IP address in the MONAI Label extension of 3D Slicer:
3d monai

I am unable to connect and receive the following error:
image

The details are below. Is this an access issue from my end, or with MONAI Label’s servers, or something else?

Traceback (most recent call last):
File “C:/Users/uXXXXXXX/AppData/Local/NA-MIC/Slicer 5.2.2/NA-MIC/Extensions-31382/MONAILabel/lib/Slicer-5.2/qt-scripted-modules/MONAILabel.py”, line 1072, in fetchInfo
info = self.logic.info()
File “C:/Users/uXXXXXXX/AppData/Local/NA-MIC/Slicer 5.2.2/NA-MIC/Extensions-31382/MONAILabel/lib/Slicer-5.2/qt-scripted-modules/MONAILabel.py”, line 2263, in info
return self._client().info()
File “C:/Users/uXXXXXXX/AppData/Local/NA-MIC/Slicer 5.2.2/NA-MIC/Extensions-31382/MONAILabel/lib/Slicer-5.2/qt-scripted-modules/MONAILabel.py”, line 2239, in _client
if mc.auth_enabled():
File “C:\Users\uXXXXXXX\AppData\Local\NA-MIC\Slicer 5.2.2\NA-MIC\Extensions-31382\MONAILabel\lib\Slicer-5.2\qt-scripted-modules\MONAILabelLib\client.py”, line 83, in auth_enabled
status, response, _, _ = MONAILabelUtils.http_method(“GET”, self._server_url, selector)
File “C:\Users\uXXXXXXX\AppData\Local\NA-MIC\Slicer 5.2.2\NA-MIC\Extensions-31382\MONAILabel\lib\Slicer-5.2\qt-scripted-modules\MONAILabelLib\client.py”, line 521, in http_method
conn.request(method, selector, body=body, headers=headers)
File “C:\Users\uXXXXXXX\AppData\Local\NA-MIC\Slicer 5.2.2\lib\Python\Lib\http\client.py”, line 1285, in request
self._send_request(method, url, body, headers, encode_chunked)
File “C:\Users\uXXXXXXX\AppData\Local\NA-MIC\Slicer 5.2.2\lib\Python\Lib\http\client.py”, line 1331, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File “C:\Users\uXXXXXXX\AppData\Local\NA-MIC\Slicer 5.2.2\lib\Python\Lib\http\client.py”, line 1280, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File “C:\Users\uXXXXXXX\AppData\Local\NA-MIC\Slicer 5.2.2\lib\Python\Lib\http\client.py”, line 1040, in _send_output
self.send(msg)
File “C:\Users\uXXXXXXX\AppData\Local\NA-MIC\Slicer 5.2.2\lib\Python\Lib\http\client.py”, line 980, in send
self.connect()
File “C:\Users\uXXXXXXX\AppData\Local\NA-MIC\Slicer 5.2.2\lib\Python\Lib\http\client.py”, line 946, in connect
self.sock = self._create_connection(
File “C:\Users\uXXXXXXX\AppData\Local\NA-MIC\Slicer 5.2.2\lib\Python\Lib\socket.py”, line 844, in create_connection
raise err
File “C:\Users\uXXXXXXX\AppData\Local\NA-MIC\Slicer 5.2.2\lib\Python\Lib\socket.py”, line 832, in create_connection
sock.connect(sa)
OSError: [WinError 10049] The requested address is not valid in its context

Hi,
sounds like you are almost there. The URL displayed in the CLI output needs to be modified. In http://0.0.0.0:8000, replace the 0.0.0.0 part with the IP address of your server where MONAI Label is running on. For example:

  • If you are running this on localhost (i.e. MONAI Label server and 3D Slicer are running locally on the same laptop/workstation), then replace it with http://127.0.0.1:8000
  • If you are running MONAI Label on a remote server and 3D Slicer locally, then enter that address, e.g. http://123.456.789.012:8000

If this does not help, it would be great if you could share the server setup - is this the same workstation, or is MONAI Label server running remotely? Did you start MONAI Label server from inside a docker container or barebone with a local conda/pip install?

Hi, I’ve tried the local server as well, and it does not help. I’m starting the server from a local pip install, attempting to run it from the same workstation. If it helps, I’m able to run a Jupyter Server to run jupyter notebooks, for instance. It runs on the local host and uses a token. Does the MONAI Label server have a similar protocol? Similarly, how do I try and run MONAI Label on a remote server? Do I have to set anything up, or is it as simple as entering a server address?

Actually - your comment gave me a clue. I tried the same port as jupyter notebook uses and it now works!