@@ -239,21 +239,22 @@ public override async ValueTask DisposeAsync()
239239 }
240240 catch ( OperationCanceledException )
241241 {
242- // Timed out waiting for close handshake.
242+ TraceEvent ( TraceEventType . Warning , 0 , "WebSocketStream.DisposeAsync: Timed out waiting for close handshake" ) ;
243243 }
244244 catch ( ObjectDisposedException )
245245 {
246- // Already disposed.
246+ TraceEvent ( TraceEventType . Warning , 0 , "WebSocketStream.DisposeAsync: Called on disposed socket" ) ;
247247 }
248248 catch ( WebSocketException wse )
249249 when ( wse . WebSocketErrorCode == WebSocketError . ConnectionClosedPrematurely )
250250 {
251251 // Other party closed connection prematurely.
252+ TraceEvent ( TraceEventType . Warning , 0 , "WebSocketStream.DisposeAsync: Socket closed prematurely exception: {0}" , wse ) ;
252253 }
253- catch ( Exception )
254+ catch ( Exception ex )
254255 {
255- // TODO: log the exception.
256256 // Do not throw from DisposeAsync.
257+ TraceEvent ( TraceEventType . Warning , 0 , "WebSocketStream.DisposeAsync: Exception during DisposeAsync: {0}" , ex ) ;
257258 }
258259 }
259260
@@ -369,7 +370,7 @@ public override async Task<int> ReadAsync(byte[] buffer, int offset, int count,
369370 {
370371 // Other party closed connection prematurely.
371372 Close ( ) ;
372- TraceEvent ( TraceEventType . Warning , 0 , "WS.R: Websocket closed prematurely exception" ) ;
373+ TraceEvent ( TraceEventType . Warning , 0 , "WS.R: Socket closed prematurely exception: {0}, SocketState={1}, CloseStatus={2}" , wse , socket . State , socket . CloseStatus ) ;
373374 return 0 ;
374375 }
375376 }
@@ -425,7 +426,7 @@ public override async ValueTask<int> ReadAsync(Memory<byte> buffer, Cancellation
425426 {
426427 // Other party closed connection prematurely.
427428 Close ( ) ;
428- Trace . TraceEvent ( TraceEventType . Warning , 0 , "WS.R: Websocket closed prematurely exception" ) ;
429+ Trace . TraceEvent ( TraceEventType . Warning , 0 , "WS.R: Socket closed prematurely exception: {0}, SocketState={1}, CloseStatus={2}" , wse , socket . State , socket . CloseStatus ) ;
429430 return 0 ;
430431 }
431432 }
0 commit comments