Python SDK throws "Controller not available" error

Hi,

we've been trying to use the Python SDK for the first time but can't get past the following error:

(98264)[        0.084]   ERROR ziti-sdk:ziti_ctrl.c:162 ctrl_resp_cb() ctrl[zt.company.de] request failed: -53(software caused connection abort)
(98264)[        0.084]   ERROR ziti-sdk:ziti.c:1668 version_cb() ztx[0] failed to get controller version from https://zt.company.de:8441/edge/client/v1 CONTROLLER_UNAVAILABLE(software caused connection abort)
(98264)[        0.084]   ERROR ziti-sdk:ziti_ctrl.c:162 ctrl_resp_cb() ctrl[zt.company.de] request failed: -53(software caused connection abort)
2024-02-24 17:42:05,332 - ERROR - could not find identity file: ctx is not a valid python void pointer type
Traceback (most recent call last):
  File "/Users/user/Projects/company/use-cases/export.py", line 411, in <module>
    asyncio.run(main(dry_run=args.dry_run))
  File "/Users/user/.pyenv/versions/3.11.1/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/Users/user/.pyenv/versions/3.11.1/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/user/.pyenv/versions/3.11.1/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/Users/user/Projects/company/use-cases/export.py", line 363, in main
    monkey_patch_openziti(deployment)
  File "/Users/user/Projects/company/use-cases/export.py", line 102, in monkey_patch_openziti
    raise e
  File "/Users/user/Projects/company/use-cases/export.py", line 99, in monkey_patch_openziti
    zitiContext = openziti.load('identity.json')
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/user/.pyenv/versions/3.11.1/lib/python3.11/site-packages/openziti/context.py", line 87, in load_identity
    return ZitiContext.from_path(path)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/user/.pyenv/versions/3.11.1/lib/python3.11/site-packages/openziti/context.py", line 77, in from_path
    return cls(zitilib.load(path))
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/user/.pyenv/versions/3.11.1/lib/python3.11/site-packages/openziti/context.py", line 27, in __init__
    raise TypeError("ctx is not a valid python void pointer type")
TypeError: ctx is not a valid python void pointer type

Here's the code we're using:

    try:
        zitiContext = openziti.load('identity.json')
    except Exception as e:
        logging.error(f'could not find identity file: {e}')
        raise e
 
    cfg = dict(
        ztx=zitiContext,
        service='Test_Github_Action',
    )
    openziti.monkeypatch(bindings={deployment.endpoint: cfg})

We are using v0.8.1 and we're certain that the controller is in fact available by the host because Ziti Desktop Edge works flawlessly on the same device.
We've enrolled the JWT on the controller via ziti edge enroll and copied the JSON.

What are we missing here?

1 Like

Since the error says it can't find the identity file, I would start by giving it a full path. It could also be a permissions issue, but that would be less likely.

Thanks, but it can get the Controller URL from the identity file right?
This was a sign for me that the JSON is being opened correctly. The could not find identity file is just the default error message from the quickstart.

was this Ziti instance created by an older version of quickstart?

It is possible that CA bundle is not correct.
Python SDK is using OpenSSL for TLS connectivity, ZDE is using mbedTLS.

OpenSSL is more strict wrt certificate validation, and older versions of quickstart produced incomplete CA bundles

@dmuensterer Can you try with an identity from a fresh quickstart instance?

Aha, that’s interesting. I can try that. The QuickStart was from September 2022.