{"action":"created","issue":{"url":"https://api.github.com/repos/akkadotnet/akka.net/issues/1405","labels_url":"https://api.github.com/repos/akkadotnet/akka.net/issues/1405/labels{/name}","comments_url":"https://api.github.com/repos/akkadotnet/akka.net/issues/1405/comments","events_url":"https://api.github.com/repos/akkadotnet/akka.net/issues/1405/events","html_url":"https://github.com/akkadotnet/akka.net/issues/1405","id":115162938,"number":1405,"title":"Akka.net ActorSystem.AwaitTermination triggers DeathWatchNotification when no messages are sent on .NET 4.5.2","user":{"login":"CreepyGnome","id":935891,"avatar_url":"https://avatars.githubusercontent.com/u/935891?v=3","gravatar_id":"","url":"https://api.github.com/users/CreepyGnome","html_url":"https://github.com/CreepyGnome","followers_url":"https://api.github.com/users/CreepyGnome/followers","following_url":"https://api.github.com/users/CreepyGnome/following{/other_user}","gists_url":"https://api.github.com/users/CreepyGnome/gists{/gist_id}","starred_url":"https://api.github.com/users/CreepyGnome/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CreepyGnome/subscriptions","organizations_url":"https://api.github.com/users/CreepyGnome/orgs","repos_url":"https://api.github.com/users/CreepyGnome/repos","events_url":"https://api.github.com/users/CreepyGnome/events{/privacy}","received_events_url":"https://api.github.com/users/CreepyGnome/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-11-04T22:23:31Z","updated_at":"2015-11-05T01:43:09Z","closed_at":"2015-11-04T23:29:12Z","body":"This message is written to the console in the simplest of Akka.net sample applications.\r\n\r\n> [INFO][11/3/2015 7:21:06 PM][Thread 0008][akka://TestActorSystem/user]\r\n> Message DeathWatchNotification from akka://TestActorSystem/user to\r\n> akka://TestActorSystem/user was not delivered. 1 dead letters\r\n> encountered.\r\n\r\nThis is the very simple code, where all you do is create an actor, but you NEVER send any messages. \r\n\r\n    using System;\r\n    using Akka.Actor;\r\n    namespace AkkaNetTest {\r\n        class Program {\r\n            static void Main(string[] args) {\r\n                ActorSystem testActorSystem = ActorSystem.Create(\"TestActorSystem\");\r\n                Console.WriteLine(\"Actor system 'TestActorSystem' created\");\r\n                IActorRef testActor = testActorSystem.ActorOf<TestActor>(\"Test\");\r\n                Console.WriteLine(\"Press a key to shutdown the 'TestActorSystem' actor system\");\r\n                Console.ReadKey();\r\n                Console.WriteLine(\"Attempting to shutdown the actor system\");\r\n                testActorSystem.Shutdown();\r\n                Console.WriteLine(\"Waiting for the actor system to terminate.\");\r\n                testActorSystem.AwaitTermination();\r\n                Console.WriteLine(\"Actor system shutdown, press any key to exit\");\r\n                Console.ReadKey(); \r\n            }\r\n        }\r\n        public class TestActor : ReceiveActor { }\r\n    }\r\n\r\nThe environment I am running in is:\r\n\r\n>  - Windows 10 RTM build 10240 \r\n>  - Visual Studio 2013 Update 5 \r\n>  - Akka.Net via NeGet 1.0.4.12 \r\n>  - Target framework .NET 4.5 \r\n>  - Installed framework .NET 4.5.2\r\n>  - Console Application \r\n>  - Any CPU\r\n\r\nWhen you run this simple application the above Akka.net output occurs as soon as the `ActorSystem.AwaitTermination()` call is made.  \r\n\r\nIt occurs in all my Akka.net applications I try to create and I was able to get it to reproduce in this simple application. So if I send messages or I don't send them it always occurs. If you comment out the `IActorRef` line then you will not get the message since no actors where created.\r\n\r\nThis doesn't make any sense why this is happening. If any one can help with explaining why this happens and how to prevent it from happening even when there are no messages that were ever sent then I would appreciate it.\r\n\r\nOriginally posted on StackOverflow\r\nhttp://stackoverflow.com/questions/33507519/akka-net-actorsystem-awaittermination-triggers-deathwatchnotification-when-no-me\r\n"},"comment":{"url":"https://api.github.com/repos/akkadotnet/akka.net/issues/comments/153926751","html_url":"https://github.com/akkadotnet/akka.net/issues/1405#issuecomment-153926751","issue_url":"https://api.github.com/repos/akkadotnet/akka.net/issues/1405","id":153926751,"user":{"login":"Aaronontheweb","id":326939,"avatar_url":"https://avatars.githubusercontent.com/u/326939?v=3","gravatar_id":"","url":"https://api.github.com/users/Aaronontheweb","html_url":"https://github.com/Aaronontheweb","followers_url":"https://api.github.com/users/Aaronontheweb/followers","following_url":"https://api.github.com/users/Aaronontheweb/following{/other_user}","gists_url":"https://api.github.com/users/Aaronontheweb/gists{/gist_id}","starred_url":"https://api.github.com/users/Aaronontheweb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Aaronontheweb/subscriptions","organizations_url":"https://api.github.com/users/Aaronontheweb/orgs","repos_url":"https://api.github.com/users/Aaronontheweb/repos","events_url":"https://api.github.com/users/Aaronontheweb/events{/privacy}","received_events_url":"https://api.github.com/users/Aaronontheweb/received_events","type":"User","site_admin":false},"created_at":"2015-11-05T01:43:09Z","updated_at":"2015-11-05T01:43:09Z","body":"> From a user/developer perspective I should not be getting any messages on my console from Akka about anything unless I write them to the console myself, or I tell Akka I want it to do this via giving it a logger or something.\r\n\r\nThis is what you have in the default configuration options\r\n\r\n```json\r\nakka {\r\n  # Akka version, checked against the runtime version of Akka.\r\n  version = \"0.0.1 Akka\"\r\n \r\n  # Home directory of Akka, modules in the deploy directory will be loaded\r\n  home = \"\"\r\n \r\n  # Loggers to register at boot time (akka.event.Logging$DefaultLogger logs\r\n  # to STDOUT)\r\n  loggers = [\"Akka.Event.DefaultLogger\"]\r\n \r\n  # Loggers are created and registered synchronously during ActorSystem\r\n  # start-up, and since they are actors, this timeout is used to bound the\r\n  # waiting time\r\n  logger-startup-timeout = 5s\r\n \r\n  # Log level used by the configured loggers (see \"loggers\") as soon\r\n  # as they have been started; before that, see \"stdout-loglevel\"\r\n  # Options: OFF, ERROR, WARNING, INFO, DEBUG\r\n  loglevel = \"INFO\"\r\n \r\n  # Log level for the very basic logger activated during AkkaApplication startup\r\n  # Options: OFF, ERROR, WARNING, INFO, DEBUG\r\n  stdout-loglevel = \"WARNING\"\r\n \r\n  # Log the complete configuration at INFO level when the actor system is started.\r\n  # This is useful when you are uncertain of what configuration is used.\r\n  log-config-on-start = off\r\n \r\n  # Log at info level when messages are sent to dead letters.\r\n  # Possible values:\r\n  # on: all dead letters are logged\r\n  # off: no logging of dead letters\r\n  # n: positive integer, number of dead letters that will be logged\r\n  log-dead-letters = 10\r\n \r\n  # Possibility to turn off logging of dead letters while the actor system\r\n  # is shutting down. Logging is only done when enabled by 'log-dead-letters'\r\n  # setting.\r\n  log-dead-letters-during-shutdown = on\r\n}\r\n```\r\n\r\nTurn this to `akka.log-dead-letters-during-shutdown = off` if you don't want to see them.\r\n\r\n>Also from a user/developer perspective I would think that if I never send a message I should never get an anything stating it could not deliver a message.\r\n\r\nThat's because these are system messages that Akka uses to control the actor hierarchy. You didn't send them, but when you called `ActorSystem.Shutdown` then a series of `Stop` commands are automatically sent down the entire hierarchy so every actor can attempt to shutdown. This includes built-in actors.\r\n\r\n> Also this doesn't happen because of the Shutdown call it happens because of the AwaitTermination call. Which as I understand it should only block until everything is actually shutdown and terminated.\r\n\r\nThe `AwaitTermination` forces the system to wait until the `RootGuardianSupervisor` receives at least one `DeathWatchNotification` - either from the root `SystemGuardian` or the `UserGuardian` actors. You don't normally see this if you just call `Shutdown` in trivial applications because the system doesn't block until this message gets received and the program just exits. The behavior is different because you're basically waiting to get confirmation that everything has actually shutdown - in Akka.Remote for instance all network transports get closed between `ActorSystem.Shutdown` being called and `ActorSystem.AwaitTermination` returning true.\r\n\r\n> Also why does this ONLY happen in very specific .NET versions and not others?\r\n\r\nShutting down the system includes inherently racy behavior - you could get different results with the same platform. As for why it varies across different .NET runtimes. If you're using RyuJit or .NET 4.5.2 IL that's optimized differently then sure - this might come up. We develop and test for .NET 4.5  using LegacyJIT - we make no guarantees for anything else.\r\n\r\n> I still think there is a bug here, so a little premature to close in my opinion.\r\n\r\nThe docs I linked to explain this pretty clearly. \r\n"}}