Skip to content

Commit e5a58d1

Browse files
authored
Merge pull request #376 from Cysharp/hotfix/IgnoreConnectionAbortedException
Ignore IOException when the stream is disconnected by the client.
2 parents 4867f6b + 995a2c4 commit e5a58d1

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/MagicOnion.Server/Hubs/StreamingHub.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
using Grpc.Core;
22
using MessagePack;
33
using System;
4+
using System.IO;
45
using System.Threading.Tasks;
6+
using Microsoft.AspNetCore.Connections;
57

68
namespace MagicOnion.Server.Hubs
79
{
@@ -92,6 +94,11 @@ public async Task<DuplexStreamingResult<byte[], byte[]>> Connect()
9294
await OnConnecting();
9395
await HandleMessageAsync();
9496
}
97+
catch (IOException ex) when (ex.InnerException is ConnectionAbortedException)
98+
{
99+
// NOTE: If DuplexStreaming is disconnected by the client, IOException will be thrown.
100+
// However, such behavior is expected. the exception can be ignored.
101+
}
95102
finally
96103
{
97104
await OnDisconnected();

0 commit comments

Comments
 (0)