After setting the following environment variables:
$env:CCP_CODEX_TRANSPORT = "websocket"
$env:CCP_CODEX_PREVIOUS_RESPONSE_ID = "1"
new connections eventually fail to establish after the application has been running for some time. The issue is easy to reproduce and occurs particularly frequently in UltraCode mode.
I suspect there may be limits on the OpenAI side regarding either the number of simultaneous WebSocket connections or the number of connection attempts made within a short period.
In any case, the issue no longer occurs after I introduced the following restrictions on WebSocket connections:
- When opening a new connection, if there are already more than 50 active connections, close the 10 least recently active connections, reducing the total to 40.
- Ensure an interval of at least one second between connection attempts.
- When a connection attempt returns a 403 response, wait three seconds and retry once.
I plan to open a related PR later. If you have any feedback or suggestions on how to make the proposed changes more suitable for general use cases, please feel free to let me know.
After setting the following environment variables:
new connections eventually fail to establish after the application has been running for some time. The issue is easy to reproduce and occurs particularly frequently in UltraCode mode.
I suspect there may be limits on the OpenAI side regarding either the number of simultaneous WebSocket connections or the number of connection attempts made within a short period.
In any case, the issue no longer occurs after I introduced the following restrictions on WebSocket connections:
I plan to open a related PR later. If you have any feedback or suggestions on how to make the proposed changes more suitable for general use cases, please feel free to let me know.