Skip to content

Commit af3a0d3

Browse files
authored
http2: Close idle connections (#4)
Signed-off-by: Sri Krishna <[email protected]>
1 parent 1c70284 commit af3a0d3

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

packages/connect/lib/src/http2/connection.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,13 @@ final class _Http2ClientTransportConnectionManager
5959
Uri uri,
6060
) async {
6161
final socket = await _connectSocket(uri);
62-
return Http2ClientTransportConnection(
63-
http2.ClientTransportConnection.viaSocket(socket),
64-
);
62+
final connection = http2.ClientTransportConnection.viaSocket(socket);
63+
connection.onActiveStateChanged = (active) {
64+
if (!active) {
65+
connection.finish().ignore();
66+
}
67+
};
68+
return Http2ClientTransportConnection(connection);
6569
}
6670

6771
Future<io.Socket> _connectSocket(Uri uri) async {

0 commit comments

Comments
 (0)