Grasshopper Tutorial - Rhino Compute URL connection problem

Hi VIKTOR team.

I recently did a workshop with Marcel and Jasper and we struggled to get the Grasshopper Tutorial working. Since doing the workshop, and trying to debug, I cannot find any solutions.

My setup
Windows 11 Pro version 22H2
PyCharm Professional & Community - Latest Version
Python 3.10 installed from Windows Store
Rhino v7 sr32 (latest)
Hops v0.16.2 (latest)

All dependencies installed:

Debugging Tried

  • I tried different ports, such as localhost:127.0.0.1
  • I tried opening the firewall connections for Rhino, PyCharm, etc.
  • I tried running the 'run_grasshopper.py` script while the internet was off
  • I tried running on Private or Public wifi networks.

The ERROR CODE to the Rhino Compute localhost:

Traceback (most recent call last):
  File "C:\Users\Darrel\.virtualenvs\viktor-grasshopper\lib\site-packages\urllib3\connection.py", line 203, in _new_conn
    sock = connection.create_connection(
  File "C:\Users\Darrel\.virtualenvs\viktor-grasshopper\lib\site-packages\urllib3\util\connection.py", line 85, in create_connection
    raise err
  File "C:\Users\Darrel\.virtualenvs\viktor-grasshopper\lib\site-packages\urllib3\util\connection.py", line 73, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\Darrel\.virtualenvs\viktor-grasshopper\lib\site-packages\urllib3\connectionpool.py", line 790, in urlopen
    response = self._make_request(
  File "C:\Users\Darrel\.virtualenvs\viktor-grasshopper\lib\site-packages\urllib3\connectionpool.py", line 496, in _make_request
    conn.request(
  File "C:\Users\Darrel\.virtualenvs\viktor-grasshopper\lib\site-packages\urllib3\connection.py", line 395, in request
    self.endheaders()
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\http\client.py", line 1278, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\http\client.py", line 1038, in _send_output
    self.send(msg)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\http\client.py", line 976, in send
    self.connect()
  File "C:\Users\Darrel\.virtualenvs\viktor-grasshopper\lib\site-packages\urllib3\connection.py", line 243, in connect
    self.sock = self._new_conn()
  File "C:\Users\Darrel\.virtualenvs\viktor-grasshopper\lib\site-packages\urllib3\connection.py", line 218, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x000001E5E3A1E530>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\Darrel\.virtualenvs\viktor-grasshopper\lib\site-packages\requests\adapters.py", line 486, in send
    resp = conn.urlopen(
  File "C:\Users\Darrel\.virtualenvs\viktor-grasshopper\lib\site-packages\urllib3\connectionpool.py", line 844, in urlopen
    retries = retries.increment(
  File "C:\Users\Darrel\.virtualenvs\viktor-grasshopper\lib\site-packages\urllib3\util\retry.py", line 515, in increment
    raise MaxRetryError(_pool, url, reason) from reason  # type: ignore[arg-type]
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=6500): Max retries exceeded with url: /grasshopper (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000001E5E3A1E530>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Darrel\Documents\Github\KCAPbv\viktor-grasshopper\run_grasshopper.py", line 27, in <module>
    output = gh.EvaluateDefinition(
  File "C:\Users\Darrel\.virtualenvs\viktor-grasshopper\lib\site-packages\compute_rhino3d\Grasshopper.py", line 57, in EvaluateDefinition
    response = Util.ComputeFetch(url, args)
  File "C:\Users\Darrel\.virtualenvs\viktor-grasshopper\lib\site-packages\compute_rhino3d\Util.py", line 34, in ComputeFetch
    r = requests.post(posturl, data=postdata, headers=headers)
  File "C:\Users\Darrel\.virtualenvs\viktor-grasshopper\lib\site-packages\requests\api.py", line 115, in post
    return request("post", url, data=data, json=json, **kwargs)
  File "C:\Users\Darrel\.virtualenvs\viktor-grasshopper\lib\site-packages\requests\api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Users\Darrel\.virtualenvs\viktor-grasshopper\lib\site-packages\requests\sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\Darrel\.virtualenvs\viktor-grasshopper\lib\site-packages\requests\sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\Darrel\.virtualenvs\viktor-grasshopper\lib\site-packages\requests\adapters.py", line 519, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=6500): Max retries exceeded with url: /grasshopper (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x000001E5E3A1E530>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it'))

Hi Maketank,

Welcome to our community!

In order for the Compute server to work correctly, both Rhino and Grasshopper need to be open while running the server. Can you verify that is the case?

Next to the tutorial, we also have a more general description of the integration, maybe that will help you further also. See the docs.

kind regards

Hi
I am getting a similar error, where I am unable to make a connection. Just to give an over-view, I have python 2.7, 3.10 and 3.12 installed on my system. For me to run the python script and install libraries, I had to create a virtual environment and use python 3.10.10 version. Do you think this might be the reason for the error? Thanks in advance :slight_smile:

Hi @medha.bansal !

Nice to see you posting! Welcome!

The newest version of Python the Rhino supports is 3.11, so that’s a nice catch of you to use 3.10.

From you picture we cannot see what error is happening. It seems like a connection was made, but there was an error in Rhino.Compute.

It would be helpful to see the error in your Rhino.Compute terminal.

Rick

Hi Rick
Thank you for reverting to my query. Below is a snippet from Visual Studio Code’s terminal window, where the error says ’ Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it’

Hi Medha,

It seems the issue is on the server side of the connection. Could you post the recent log from your Rhino.Compute terminal?

Hi rvandijk

Apologies for a late reply. I am actually trying the new worker for viktor-gh integration. I am still running into error. Pasting a copy of it below.

Hi Medha,

Nice to see you trying the new worker!

Your issue seems to be an issue on how Rhino Compute is configured. I would suggest taking a look into Hops not working. Unable to start a local compute server - Hops - McNeel Forum. There are some people with similar problems and Andy is helping them out.

Hopefully that gives you a push in the right direction!

Rick

1 Like

For people that run into the same issue:

This error can have multiple causes, but in this case there was a duplicate plugin loaded, causing Rhino Compute to crash while starting!