TypeError: unsupported operand type(s) for 'in': 'int' and 'EnumType' in curl_cffi WebSocket
When running an async script using the PyCharacterAI library (which depends on curl_cffi), I encountered a TypeError caused by an invalid enum membership check in the websockets.py file.
This error happen when I take a long time before responding to the bot. For example, after sending a message to a character and waiting a few minutes before replying, the following error is triggered:
TypeError: unsupported operand type(s) for 'in': 'int' and 'EnumType'
File "websockets.py", line 142, in _unpack_close_frame
if code < 3000 and (code not in WsCloseCode or code == 1005):```
It seems like the WebSocket connection times out or closes due to inactivity, and the code is not correctly handling the WebSocket close frame.
Name: curl_cffi Version: 0.11.1 OS: Windows 11
This happens sometimes, curl-cffi is not a perfect library, and c.ai does not always behave consistently. You must handle all errors yourself and repeat method calls again manually. This library does not provide a mechanism for repeating requests automatically, as this would cause unwanted behavior in some cases
This happens sometimes, curl-cffi is not a perfect library, and c.ai does not always behave consistently. You must handle all errors yourself and repeat method calls again manually. This library does not provide a mechanism for repeating requests automatically, as this would cause unwanted behavior in some cases
Thanks fo the response I appreciate it. I've resolved it by upgrading my curl-cffi.