Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ZoolWay/2af4eb1815c6a5c41cdeb440dd0cd36b to your computer and use it in GitHub Desktop.
Save ZoolWay/2af4eb1815c6a5c41cdeb440dd0cd36b to your computer and use it in GitHub Desktop.
An ASP.NET Core node which is not correctly leaving its Akka.NET Cluster
INFO 13:53:51 [ 1] vices.WebApi.Program - samcs.WebApi starting
DEBUG 13:53:51 [ 1] vices.WebApi.Startup - Configure services
DEBUG 13:53:52 [ 1] vices.WebApi.Startup - Providing ActorSystem
DEBUG 13:53:52 [ 1] vices.WebApi.Startup - Initializing actor system with config from 'C:\Users\blankenaufulland\Source\Repos\samnext\foundation\samcs\src\samcs.WebApi\akka.hocon'
INFO 13:53:52 [11] lassForStringSources - Starting remoting
INFO 13:53:52 [ 3] lassForStringSources - Remoting started; listening on addresses : [akka.tcp://samgroup@127.0.0.1:12300]
INFO 13:53:52 [ 8] lassForStringSources - Remoting now listens on addresses: [akka.tcp://samgroup@127.0.0.1:12300]
INFO 13:53:52 [ 3] lassForStringSources - Cluster Node [akka.tcp://samgroup@127.0.0.1:12300] - Starting up...
INFO 13:53:52 [11] lassForStringSources - Cluster Node [akka.tcp://samgroup@127.0.0.1:12300] - Started up successfully
DEBUG 13:53:52 [ 1] vices.WebApi.Startup - Configure
INFO 13:53:52 [ 1] vices.WebApi.Startup - Activated actor system named 'samgroup'
DEBUG 13:53:52 [ 1] vices.WebApi.Program - Run webhost
Hosting environment: Development
Content root path: C:\Users\blankenaufulland\Source\Repos\samnext\foundation\samcs\src\samcs.WebApi
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.
INFO 13:53:53 [ 8] er.ClusterCoreDaemon - Welcome from [akka.tcp://samgroup@127.0.0.1:4053]
INFO 13:55:24 [ 1] vices.WebApi.Startup - ASP.NET application stopped
DEBUG 13:55:24 [ 1] vices.WebApi.Startup - Marking ourself as DOWN
DEBUG 13:55:24 [ 1] vices.WebApi.Startup - Leaving cluster
DEBUG 13:55:24 [ 1] vices.WebApi.Startup - Waiting for ourself to be removed and terminated
INFO 13:55:24 [ 3] r+RemotingTerminator - Shutting down remote daemon.
INFO 13:55:24 [ 3] er.ClusterCoreDaemon - Marking node [akka.tcp://samgroup@127.0.0.1:12300] as [Down]
INFO 13:55:24 [ 8] r+RemotingTerminator - Remote daemon shut down; proceeding with flushing remote transports.
ERROR 13:55:24 [ 3] ios.TcpClientHandler - Error caught channel [[::ffff:127.0.0.1]:12301->[::ffff:127.0.0.1]:4053](Id=ChannelId(1600056064))
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Net.Sockets.Socket'.
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, SocketError& errorCode)
at Helios.Channels.Sockets.TcpSocketChannel.DoReadBytes(IByteBuf buf)
at Helios.Channels.Sockets.AbstractSocketByteChannel.SocketByteChannelUnsafe.FinishRead(SocketChannelAsyncOperation operation)
ERROR 13:55:24 [ 3] ios.TcpServerHandler - Error caught channel [[::ffff:127.0.0.1]:12300->[::ffff:127.0.0.1]:12311](Id=ChannelId(-18529280))
System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'System.Net.Sockets.Socket'.
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags, SocketError& errorCode)
at Helios.Channels.Sockets.TcpSocketChannel.DoReadBytes(IByteBuf buf)
at Helios.Channels.Sockets.AbstractSocketByteChannel.SocketByteChannelUnsafe.FinishRead(SocketChannelAsyncOperation operation)
INFO 13:55:24 [ 3] .Actor.LocalActorRef - Message Disassociated from akka://samgroup/system/transports/akkaprotocolmanager.tcp.0/akkaProtocol-tcp%3a%2f%2fsamgroup%40127.0.0.1%3a4053-1 to akka://samgroup/system/endpointManager/reliableEndpointWriter-akka.tcp%3a%2f%2fsamgroup%40127.0.0.1%3a4053-1/endpointWriter/endpointReader-akka.tcp%3a%2f%2fsamgroup%40127.0.0.1%3a4053-1 was not delivered. 1 dead letters encountered.
INFO 13:55:24 [ 3] teDeadLetterActorRef - Message DeadLetter from akka://samgroup/system/endpointManager/reliableEndpointWriter-akka.tcp%3a%2f%2fsamgroup%40127.0.0.1%3a4053-1 to akka://samgroup/deadLetters was not delivered. 2 dead letters encountered.
INFO 13:55:24 [ 3] teDeadLetterActorRef - Message DeadLetter from akka://samgroup/system/endpointManager/reliableEndpointWriter-akka.tcp%3a%2f%2fsamgroup%40localhost%3a12309-2 to akka://samgroup/deadLetters was not delivered. 3 dead letters encountered.
INFO 13:55:24 [ 3] .Actor.LocalActorRef - Message Disassociated from akka://samgroup/system/transports/akkaprotocolmanager.tcp.0/akkaProtocol-tcp%3a%2f%2fsamgroup%40%3a%3affff%3a127.0.0.1%3a12311-2 to akka://samgroup/system/endpointManager/reliableEndpointWriter-akka.tcp%3a%2f%2fsamgroup%40localhost%3a12309-2/endpointWriter/endpointReader-akka.tcp%3a%2f%2fsamgroup%40localhost%3a12309-1 was not delivered. 4 dead letters encountered.
INFO 13:55:24 [ 3] .Actor.LocalActorRef - Message Disassociated from NoSender to akka://samgroup/system/transports/akkaprotocolmanager.tcp.0/akkaProtocol-tcp%3a%2f%2fsamgroup%40127.0.0.1%3a4053-1 was not delivered. 5 dead letters encountered.
INFO 13:55:24 [ 3] .Actor.LocalActorRef - Message Disassociated from NoSender to akka://samgroup/system/transports/akkaprotocolmanager.tcp.0/akkaProtocol-tcp%3a%2f%2fsamgroup%40%3a%3affff%3a127.0.0.1%3a12311-2 was not delivered. 6 dead letters encountered.
INFO 13:55:24 [ 3] .Actor.LocalActorRef - Message Disassociated from NoSender to akka://samgroup/system/transports/akkaprotocolmanager.tcp.0/akkaProtocol-tcp%3a%2f%2fsamgroup%40%3a%3affff%3a127.0.0.1%3a12311-2 was not delivered. 7 dead letters encountered.
INFO 13:55:24 [ 3] .Actor.LocalActorRef - Message Disassociated from NoSender to akka://samgroup/system/transports/akkaprotocolmanager.tcp.0/akkaProtocol-tcp%3a%2f%2fsamgroup%40127.0.0.1%3a4053-1 was not delivered. 8 dead letters encountered.
INFO 13:55:24 [ 3] teDeadLetterActorRef - Message DeadLetter from akka://samgroup/system/transports/akkaprotocolmanager.tcp.0 to akka://samgroup/deadLetters was not delivered. 9 dead letters encountered.
INFO 13:55:24 [ 3] lassForStringSources - Remoting shut down
INFO 13:55:24 [ 3] r+RemotingTerminator - Remoting shut down.
INFO 13:55:24 [10] vices.WebApi.Startup - Shutting down actor system
DEBUG 13:55:24 [11] vices.WebApi.Startup - ActorSystem terminated
DEBUG 13:55:24 [ 1] vices.WebApi.Startup - ActorSystem termination signal received
INFO 13:55:24 [ 1] vices.WebApi.Program - Webhost completed
Press [Enter] to exit
{
"dependencies": {
"Akka": "1.1.0",
"Akka.Cluster": "1.1.0",
"Akka.Logger.log4net": "1.0.8",
"Akka.Remote": "1.1.0",
"Akka.Serialization.Wire": "1.0.9.227-beta",
"Google.ProtocolBuffers": "2.4.1.555",
"Helios": "2.1.1",
"log4net": "2.0.5",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Newtonsoft.Json": "9.0.1",
"samcs.Shared": "1.0.0-*",
"samcs.Shared.ApiClient": "1.0.0-*"
},
"tools": {
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel --server.urls=http://*:8999/"
},
"frameworks": {
"net461": { }
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true,
"copyToOutput": [
"akka.hocon",
"appsettings.json"
]
},
"runtimeOptions": {
"gcServer": true
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"akka.hocon",
"appsettings.json",
"web.config"
]
},
"scripts": {
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
public class Startup
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);
private ActorSystem actorSystem;
private readonly ManualResetEvent asTerminatedEvent = new ManualResetEvent(false);
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
.AddEnvironmentVariables();
Configuration = builder.Build();
}
public IConfigurationRoot Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
//...
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ActorSystem actorSystem, ILoggerFactory loggerFactory, IApplicationLifetime applicationLifetime)
{
applicationLifetime.ApplicationStopped.Register(HandleStopped);
// ...
}
private void HandleStopped()
{
log.Info("ASP.NET application stopped");
if (this.actorSystem != null)
{
var cluster = Akka.Cluster.Cluster.Get(this.actorSystem);
cluster.RegisterOnMemberRemoved(MemberRemoved);
//log.Debug("Marking ourself as DOWN");
//cluster.Down(cluster.SelfAddress);
log.Debug("Leaving cluster");
cluster.Leave(cluster.SelfAddress);
log.Debug("Waiting for ourself to be removed and terminated");
this.asTerminatedEvent.WaitOne();
log.Debug("ActorSystem termination signal received");
}
else
{
log.Debug("ActorSystem not initialized so no termination sequence");
}
}
private async void MemberRemoved()
{
log.Info("Shutting down actor system");
await this.actorSystem.Terminate();
log.Debug("ActorSystem terminated");
this.asTerminatedEvent.Set();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment