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!

Hi guys, I am having a very similar issue.

  1. On institute HPC (linux), Built Nvidia Monai-Toolkit docker using Singularity (our institute does not allow use of docker).
  2. Activated server on HPC
  3. Tunneled into HPC Monai-toolkit server from local computer
  4. Accessed Jupyter-lab that comes with Monai-toolkit container
  5. Accessed terminal within Jupyter-lab
  6. Installed radiology app and sample task Spleen09
  7. Started Monai Label server - no problems so far
  8. Installed 3D slicer on local computer and accessed MonaiLabel Module
  9. I input the same server address that the Monai-Toolkit server gave me for accessing jupyter lab but I get the infamous error:
    Screenshot 2023-10-05 at 21.56.38

I also tried putting in the IP that the jupyter server outputted, followed by :8888 but that isnt working either

Can you make any suggestions?

Did you create the tunnel to the HPC server from the computer you installed the Slicer (In the last step)?

yes, I have tunneled in and connected successfully to the node running my server on the HPC.

The way we implement MonaoLabel into Slicer is way too complicated. It is a science on its own and requires programming experience.
It should be built into the program with its own automatic server and become an integral part of the segment editor. Same a Slicer LLM should assist in solving problems before people get lost.
Slicer should have several detail layers (noob, beginner, expert) to facilitate clinical or scientific use.
I suggest a roadmap for 2030 with a clear goal and strategy.

Agreed @rbumm, the current implementation of MONAI Label is hard for people to install and modify. It would be great if we could figure out a way to improve that, perhaps with a funded effort via an NIH grant or similar. As you know most of the core developers implement things they need for their own projects so general usability improvements are often hard to allocate resources for.

Dr. Andres emailed me suggesting port mapping may be the issue and thats exactly what it was (8000 is the default port), but thanks for the help everyone. I agree with the points made by @rbumm and @pieper, I think the Monai label documentation needs a revamp, and it needs to be put in the context of the biomedical/clinical user’s experience rather than a bioinformatician’s.

Cheers,

Ulvi

@mangotee Hi, i running the MONAI LABEL server which inside a docker container from a server and i got the same access issue, do you know how to set correct server ip in 3dslicer in this case?
For example,
my server ip is 10.10.10.15
the docker port is 5735:8888
monailabel shows"http:0.0.0.0:8000"
what the correct ip should be? i tried 10.10.10.15:5735, and 10.10.10.15:8000, it shows connect refused