I'm evaluating upgrading to the latest version of ...
# ask-community
a
I'm evaluating upgrading to the latest version of prefect and our services are seeing this error in the logs repeatedly, when running a local flow against a local prefect server (trace is provided via
PREFECT_DEBUG_MODE=1
):
Copy code
00:29:29.713 | WARNING | prefect.events.clients - Unable to connect to '<ws://127.0.0.1:4200/api/events/in>'. Please check your network settings to ensure websocket connections to the API are allowed. Otherwise event data (including task run data) may be lost. Reason: connect() received a ssl argument for a ws:// URI, use a wss:// URI to enable TLS. Set PREFECT_DEBUG_MODE=1 to see the full error.
Traceback (most recent call last):
  File ".venv/lib/python3.12/site-packages/prefect/events/clients.py", line 375, in _reconnect
    self._websocket = await self._connect.__aenter__()
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".venv/lib/python3.12/site-packages/websockets/legacy/client.py", line 635, in __aenter__
    return await self
           ^^^^^^^^^^
  File ".venv/lib/python3.12/site-packages/prefect/events/clients.py", line 141, in _proxy_connect
    super().__init__(self.uri, **self._kwargs)
  File ".venv/lib/python3.12/site-packages/websockets/legacy/client.py", line 480, in __init__
    raise ValueError(
ValueError: connect() received a ssl argument for a ws:// URI, use a wss:// URI to enable TLS
Any idea what might be causing this and what we could do to resolve it?
I tried to repro in a python repl and was unable to:
Copy code
In [1]: import prefect.events.clients

In [2]: c = prefect.events.clients.PrefectEventsClient(api_url='<http://127.0.0.1:4200/api>')

In [3]: await c._reconnect()

In [4]: pong = await c._websocket.ping()

In [5]: await pong
Out[5]: 4.019266250019427

In [6]: c._events_socket_url
Out[6]: '<ws://127.0.0.1:4200/api/events/in>'
It turned out that this was a side effect of setting
PREFECT_API_TLS_INSECURE_SKIP_VERIFY
which we had used in development config. Removing that variable resolves this issue!