ninenines / gun

HTTP/1.1, HTTP/2, Websocket client (and more) for Erlang/OTP.
ISC License
891 stars 232 forks source link

HTTP2 gun_down event only delivered the connection owner but not to streams #307

Closed RoadRunnr closed 1 year ago

RoadRunnr commented 1 year ago

When using HTTP2, multiple streams can be open on the same transport connections. The processes that have those streams open do not needs to be related to the process that initiated and therefore owns the transport connection.

When the transport connection fails, only the original owner is notified. Processes that have asynchronous streams open on that connection do not get any indication of the down event.

This is especially problematic when using gun_pool. The owner of the transport connection is the pool manager. Client doing requests get handed the connection pid and will get a streamref. But neither gun_http2 nor gun_pool will inform them about the any gun_down event.

To me, it seem the most sensible approach would be to have gun_http2:down/1 send a down even to all streams on their reply_to pid.

essen commented 1 year ago

I do not think downs should be sent to all processes. However if a connection goes down all existing streams should receive a stream_error. Is that not currently the case?

RoadRunnr commented 1 year ago

You are right, the streams do get an error. I'm not sure how, but I must have missed that in my tests.