Skip to content

Commit

Permalink
Handling the case when remote node abruptly goes down (akkadotnet#2460)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxcherednik committed Jan 20, 2017
1 parent d997c27 commit 32da8ca
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/core/Akka.Remote/Transport/Helios/HeliosTcpTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,19 @@ public override void ChannelRead(IChannelHandlerContext context, object message)
public override void ExceptionCaught(IChannelHandlerContext context, Exception exception)
{
var se = exception as SocketException;

if (se?.SocketErrorCode == SocketError.OperationAborted)
{
Log.Info("Socket read operation aborted. Connection is about to be closed. Channel [{0}->{1}](Id={2})",
context.Channel.LocalAddress, context.Channel.RemoteAddress, context.Channel.Id);

NotifyListener(new Disassociated(DisassociateInfo.Shutdown));
}
else if (se?.SocketErrorCode == SocketError.ConnectionReset)
{
Log.Warning("Connection was reset by the remote peer. Channel [{0}->{1}](Id={2})",
context.Channel.LocalAddress, context.Channel.RemoteAddress, context.Channel.Id);

NotifyListener(new Disassociated(DisassociateInfo.Shutdown));
}
else
Expand Down Expand Up @@ -290,13 +301,13 @@ protected override async Task<AssociationHandle> AssociateInternal(Address remot

var associate = await clientBootstrap.ConnectAsync(socketAddress);

var handler = (TcpClientHandler) associate.Pipeline.Last();
var handler = (TcpClientHandler)associate.Pipeline.Last();
return await handler.StatusFuture;
}
catch (AggregateException e) when (e.InnerException is ConnectException)
{
var heliosException = (ConnectException) e.InnerException;
var socketException = heliosException?.InnerException as SocketException;
var heliosException = (ConnectException)e.InnerException;
var socketException = heliosException.InnerException as SocketException;

if (socketException?.SocketErrorCode == SocketError.ConnectionRefused)
{
Expand Down

0 comments on commit 32da8ca

Please sign in to comment.