Skip to content

Commit

Permalink
Fixed the race condition in StreamingWebSocketClient...
Browse files Browse the repository at this point in the history
made StopAsync and StartAsync thread-safe. Implemented the fix for Nethereum#738. Fixed the problem where the _listener task completed immediately. Also, the listener now quits when the WebSocket disconnects.
  • Loading branch information
snake-4 committed Nov 20, 2021
1 parent 7a8e150 commit ea6da1a
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 189 deletions.
10 changes: 2 additions & 8 deletions consoletests/Nethereum.WebSocketsStreamingTest/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,6 @@ public static async Task SubscribeAndRunAsync()
Console.WriteLine("Logs error info:" + exception.Message);
});





await client.StartAsync();

blockHeaderSubscription.SubscribeAsync().Wait();
Expand All @@ -150,10 +146,10 @@ public static async Task SubscribeAndRunAsync()

//await ethLogsTokenTransfer.SubscribeAsync(filterTransfers);

//Thread.Sleep(30000);
//await Task.Delay(30000);
//pendingTransactionsSubscription.UnsubscribeAsync().Wait();

//Thread.Sleep(20000);
//await Task.Delay(20000);

//blockHeaderSubscription.UnsubscribeAsync().Wait();

Expand All @@ -166,8 +162,6 @@ public static async Task SubscribeAndRunAsync()
private static async void Client_Error(object sender, Exception ex)
{
Console.WriteLine("Client Error restarting...");
// ((StreamingWebSocketClient)sender).Error -= Client_Error;
((StreamingWebSocketClient)sender).Dispose();
await SubscribeAndRunAsync();
}

Expand Down

0 comments on commit ea6da1a

Please sign in to comment.