@@ -2842,6 +2842,37 @@ public async Task WebSocketConnectionClosingTriggersConnectionClosedToken()
2842
2842
}
2843
2843
}
2844
2844
2845
+ [ Fact ]
2846
+ public async Task ServerClosingClosesWebSocketConnection ( )
2847
+ {
2848
+ using ( StartVerifiableLog ( ) )
2849
+ {
2850
+ var manager = CreateConnectionManager ( LoggerFactory ) ;
2851
+ var connection = manager . CreateConnection ( ) ;
2852
+
2853
+ var dispatcher = CreateDispatcher ( manager , LoggerFactory ) ;
2854
+ var services = new ServiceCollection ( ) ;
2855
+ services . AddSingleton < TestConnectionHandler > ( ) ;
2856
+ var context = MakeRequest ( "/foo" , connection , services ) ;
2857
+ SetTransport ( context , HttpTransportType . WebSockets ) ;
2858
+
2859
+ var builder = new ConnectionBuilder ( services . BuildServiceProvider ( ) ) ;
2860
+ builder . UseConnectionHandler < TestConnectionHandler > ( ) ;
2861
+ var app = builder . Build ( ) ;
2862
+ var options = new HttpConnectionDispatcherOptions ( ) ;
2863
+ options . WebSockets . CloseTimeout = TimeSpan . FromSeconds ( 1 ) ;
2864
+
2865
+ var executeTask = dispatcher . ExecuteAsync ( context , options , app ) ;
2866
+
2867
+ // "close" server, since we're not using a server in these tests we just simulate what would be called when the server closes
2868
+ await connection . DisposeAsync ( ) . DefaultTimeout ( ) ;
2869
+
2870
+ await connection . ConnectionClosed . WaitForCancellationAsync ( ) . DefaultTimeout ( ) ;
2871
+
2872
+ await executeTask . DefaultTimeout ( ) ;
2873
+ }
2874
+ }
2875
+
2845
2876
public class CustomHttpRequestLifetimeFeature : IHttpRequestLifetimeFeature
2846
2877
{
2847
2878
public CancellationToken RequestAborted { get ; set ; }
0 commit comments