Closed dmontagu closed 8 months ago
Hey @dmontagu 👋
Good catch indeed. I think the reason why I didn't implement Ping/Pong handling in the transport is because it's not part of the ASGI specification.
I even have a unit test that was relying on Ping message to check the UnhandledWebSocketEvent
exception 😅
The easiest solution right now is to set the keepalive_ping_interval_seconds
parameter to None
on the client to disable the keepalive ping, which should be okay in a CI context.
That being said, as it's enabled by default, it's true that it provokes surprising errors with the ASGI transport. I think it would probably better to automatically disable it if we detect that we work with the ASGI transport rather than trying to handle the ping. What do you think?
Out of curiosity, in which project are you using it? 🙂
That being said, as it's enabled by default, it's true that it provokes surprising errors with the ASGI transport. I think it would probably better to automatically disable it if we detect that we work with the ASGI transport rather than trying to handle the ping. What do you think?
Yes.
Out of curiosity, in which project are you using it? 🙂
😉
I made a PR with my proposed solution: https://github.com/frankie567/httpx-ws/pull/63
If that looks good for you, then I'll merge it, and we can close the current one.
So, I close this in favor of #63. Will make a release in a moment.
@all-contributors add @dmontagu for bug
@frankie567
I've put up a pull request to add @dmontagu! :tada:
We've been occasionally hitting errors in CI apparently due to our ASGI app receiving Ping events in our tests, and hitting the error just below the lines added in this PR.
I don't know if there's a reason not to make this change but figured I would propose it. If there's a better solution than what is proposed here, any insight would be appreciated.