Is there a way to defer the closing of a WebSocket connection? #6784
-
I've written an addon which allows an external process to control mitmproxy’s interception of WebSocket messages. It works as follows:
This works well, except in the case where the server sends a final WebSocket message and then immediately closes the connection. In this case, mitmproxy will close its WebSocket connection with the client before receiving the external process’s reply about what to do with the final WebSocket message. This means that the client does not receive this final message. The behaviour that I would like is the following:
It seems to me that this is not currently possible through the addons API. Is that correct? If so, a couple of questions:
Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Yes.
I would be really curious to hear API suggestions and then evaluate how much time we want to spend on it now. :) A clean API would be nice here, but it's not super easy to design. The immediate thought that comes to my mind that it would be probably be most useful to extend our ASGI support to WebSockets (see wsgi-flask-app.py). If we could get this to support WebSockets, users would have a really powerful API to handle WebSocket connections themselves (with optional upstream communication).
I don't think so, no. The injection mechanism is really quite limited at the moment. |
Beta Was this translation helpful? Give feedback.
Yes.
I would be really curious to hear API suggestions and then evaluate how much time we want to spend on it now. :) A clean API would be nice here, but it's not super easy to design.
The immediate thought that comes to my mind that it would be probably be most useful to extend our ASGI support to WebSockets (see wsgi-flask-app.py). If we could get this to support WebSockets, users would have a really powerful API to handle WebSocket conne…