These are chat archives for akkadotnet/akka.net

24th
Apr 2017
Donam Kim
@kdnmih_twitter
Apr 24 2017 01:09
Does anyone well know about Akka.DI.Autofac?
Donam Kim
@kdnmih_twitter
Apr 24 2017 01:33
When I create an actor using DI.Autofac, system.ActorSelection cannot return actor properly. I have to put Thread.Sleep(20);
What is best way to use system.ActorSelection in this case?
Donam Kim
@kdnmih_twitter
Apr 24 2017 01:46

following code raise an error

var workerTask = Task.Run(() => system.ActorSelection("acotr path").ResolveOne(TimeSpan.FromMilliseconds(3000)));
workerTask.Wait();

Unhandled Exception: System.AggregateException: One or more errors occurred. ---> Akka.Actor.ActorNotFoundException: Exception occurred while resolving ActorSelection ---> Akka.Actor.ActorNotFoundException: subject was null

I think Thread.Sleep is very not good approach because I cannot grantee actor create during sleep time
Yip-Yip
@Yip-Yip
Apr 24 2017 05:19
I think your problem is that you have a task thread which is fighting with teh actor system
Michael Chandler
@optiks
Apr 24 2017 05:23
Heyas. We've got a case where we need to create separate processes (exes) per context and remote deploy onto them,
i.e. There could be 10 ActorSystems running, with 5 being for context 1 and 5 being for context 2. We need to remote deploy to just a particular context.
Yip-Yip
@Yip-Yip
Apr 24 2017 05:26
use lighthouse and a cluster with a router
boom!
Michael Chandler
@optiks
Apr 24 2017 05:26
We're going to look into using dynamic roles, as well as a custom router. Do you foresee any issues with using dynamic roles? I could imagine it may create memory leaks?
Are there any examples of that @Yip-Yip?
Yip-Yip
@Yip-Yip
Apr 24 2017 05:51
IMHO i would say that memory leaks are not an issue as .net GC is battle tested compared to c++
Arjen Smits
@Danthar
Apr 24 2017 06:39
@kdnmih_twitter 1st. Do not wrap system.ActorSelection().ResolveOne in a Task. Its pointless. 2th: If you are getting an ActorNotFoundException It means the actor path your requesting does not exist. Make sure the actor lives before trying to access it via an ActorSelection
Arjen Smits
@Danthar
Apr 24 2017 06:45
You might be thinking that because you are using DI, the actor gets created automagically. This is not true. DI is only used for the constructor arguments. The Props if you will. You still need to start the actor yourself
Or have another actor create the actor in question
Donam Kim
@kdnmih_twitter
Apr 24 2017 07:11
@Danthar Thank you for your answer
I just followed by this document. http://getakka.net/docs/Dependency%20injection
however it is not working without Thread.Sleep()
public class Worker: ReceiveActor
{
    public Worker()
    {
        Receive<string>(m => Console.WriteLine("Worker is working"));
    }
}

public class WorkerManager : ReceiveActor
{
    public WorkerManager()
    {
        Receive<string>(m => Console.WriteLine("Manager start supervise"));
    }

    protected override void PreStart()
    {
        Context.ActorOf(Context.DI().Props<Worker>(), "Worker1");
    }
}

class Program
{
    static void Main(string[] args)
    {
        ContainerBuilder builder = new ContainerBuilder();
        builder.RegisterType<WorkerManager>();
        builder.RegisterType<Worker>();

        var system = ActorSystem.Create("DiTestSystem");

        IContainer container = builder.Build();
        IDependencyResolver resolver = new AutoFacDependencyResolver(container, system);

        var manageRef = system.ActorOf(system.DI().Props<WorkerManager>(), "Manager1");

        Thread.Sleep(30); // ADDED THIS LINE
        manageRef.Tell("Hello");
        system.ActorSelection("/user/Manager1/Worker1").Tell("Hello");

        Console.ReadLine();
    }
}
I am quite curious how can i verify that actor is created before use ActorSelection()?
Marc Piechura
@marcpiechura
Apr 24 2017 07:39
@kdnmih_twitter you can use ActorSelection even if the path does not exist, the problem is ResolveOne. So what you can do, use ActorSelection.Ask<ActorRef>(Identity.Instance) in a loop until it returns something that is != Nobody.Instance
Identity is a system message, so you don't need to handle it by yourself, an Actor automatically replies with his own ActorRef or Nobody if the actor does not exist
Michael Chandler
@optiks
Apr 24 2017 08:25
@Yip-Yip by memory leak I meant Akka holding onto roles which are no longer used. Think a good in the role name which has a short lifetime.
Alvaro
@pwntester
Apr 24 2017 09:36
Hi, I work as a Security Researcher with HPE Application Security group and found a vulnerability in Akka.Net. I would like to discuss privately with someone from the team, but could not find any security email alias to report the details. Who should I contact?
Arjen Smits
@Danthar
Apr 24 2017 10:17
Best would be to contact @Aaronontheweb
Donam Kim
@kdnmih_twitter
Apr 24 2017 10:20
@Silv3rcircl3 Thank you so much. Finally I learn how to check actor creation
Alvaro
@pwntester
Apr 24 2017 10:21
@Danthar thanks
Yip-Yip
@Yip-Yip
Apr 24 2017 10:59
@optiks you can put a watchdog on an actor so try the same for a role .. if you are talking about 1000's it wouldnt be a issue as the footprint is so small .. if u r talking 100000's then rework ur design
Donam Kim
@kdnmih_twitter
Apr 24 2017 12:20
@Silv3rcircl3 Where is ActorRef and Identity.Istance?
based on your comment I made like this, but it keep fail to ActorSelection
while(true)
{
    var workerFind = system.ActorSelection("/user/Manager1/Worker1").Ask<IActorRef>(Identity<WorkerManager>.Instance);
    workerFind.Wait();

    if (workerFind.Result != Nobody.Instance)
    {
        workerFind.Result.Tell("Hello");
    }
}
Marc Piechura
@marcpiechura
Apr 24 2017 17:04
@kdnmih_twitter I think the generic Instance class is wrong, there should be one without the type parameter
Marc Piechura
@marcpiechura
Apr 24 2017 17:23
@kdnmih_twitter it's Identify not Identity
And you get a ActorIdentity message back not ActorRef :)
BartekSTRX
@BartekSTRX
Apr 24 2017 18:25
Hi, I have a question: how do I unit test persistent actor? I want to write unit test that verifies that actor persists certain events when it receives message of a given type. I cant find any examples or documentation on this topic.
Mike Johnson
@softwaremike
Apr 24 2017 20:28
Just updated my project to Akka.Net 1.2. I get a TON of new things added to my packages.config and my web.config/app.config! Lots of "System" packages were added, like the following:
    <Reference Include="System.AppContext, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..\..\nuget-packages\System.AppContext.4.3.0\lib\net46\System.AppContext.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="System.Collections.Immutable, Version=1.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..\..\nuget-packages\System.Collections.Immutable.1.3.1\lib\portable-net45+win8+wp8+wpa81\System.Collections.Immutable.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="System.ComponentModel.Composition" />
    <Reference Include="System.ComponentModel.DataAnnotations" />
    <Reference Include="System.Console, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..\..\nuget-packages\System.Console.4.3.0\lib\net46\System.Console.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="System.Core" />
    <Reference Include="System.Diagnostics.DiagnosticSource, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
      <HintPath>..\..\nuget-packages\System.Diagnostics.DiagnosticSource.4.3.0\lib\net46\System.Diagnostics.DiagnosticSource.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="System.Globalization.Calendars, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..\..\nuget-packages\System.Globalization.Calendars.4.3.0\lib\net46\System.Globalization.Calendars.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="System.IO.Compression, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
      <HintPath>..\..\nuget-packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="System.IO.Compression.FileSystem" />
    <Reference Include="System.IO.Compression.ZipFile, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
      <HintPath>..\..\nuget-packages\System.IO.Compression.ZipFile.4.3.0\lib\net46\System.IO.Compression.ZipFile.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="System.IO.FileSystem, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..\..\nuget-packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="System.IO.FileSystem.Primitives, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..\..\nuget-packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="System.Net.Http, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..\..\nuget-packages\System.Net.Http.4.3.0\lib\net46\System.Net.Http.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="System.Net.Sockets, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..\..\nuget-packages\System.Net.Sockets.4.3.0\lib\net46\System.Net.Sockets.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="System.Numerics" />
    <Reference Include="System.Runtime.InteropServices.RuntimeInformation, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
There are more than this... chat message limit. Anyone have an idea what happened? Here's my packages.config additions after running 'update-package Akka.Remote':
  <package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="net46" />
  <package id="NETStandard.Library" version="1.6.1" targetFramework="net46" />
  <package id="System.AppContext" version="4.3.0" targetFramework="net46" />
  <package id="System.Collections" version="4.3.0" targetFramework="net46" />
  <package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net46" />
  <package id="System.Collections.Immutable" version="1.3.1" targetFramework="net46" />
  <package id="System.ComponentModel" version="4.3.0" targetFramework="net46" />
  <package id="System.Console" version="4.3.0" targetFramework="net46" />
  <package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net46" />
  <package id="System.Diagnostics.DiagnosticSource" version="4.3.0" targetFramework="net46" />
  <package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="net46" />
  <package id="System.Diagnostics.Tracing" version="4.3.0" targetFramework="net46" />
  <package id="System.Globalization" version="4.3.0" targetFramework="net46" />
  <package id="System.Globalization.Calendars" version="4.3.0" targetFramework="net46" />
  <package id="System.IO" version="4.3.0" targetFramework="net46" />
  <package id="System.IO.Compression" version="4.3.0" targetFramework="net46" />
  <package id="System.IO.Compression.ZipFile" version="4.3.0" targetFramework="net46" />
  <package id="System.IO.FileSystem" version="4.3.0" targetFramework="net46" />
  <package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net46" />
  <package id="System.Linq" version="4.3.0" targetFramework="net46" />
  <package id="System.Linq.Expressions" version="4.3.0" targetFramework="net46" />
  <package id="System.Net.Http" version="4.3.0" targetFramework="net46" />
  <package id="System.Net.Primitives" version="4.3.0" targetFramework="net46" />
  <package id="System.Net.Sockets" version="4.3.0" targetFramework="net46" />
  <package id="System.ObjectModel" version="4.3.0" targetFramework="net46" />
  <package id="System.Reflection" version="4.3.0" targetFramework="net46" />
  <package id="System.Reflection.Extensions" version="4.3.0" targetFramework="net46" />
  <package id="System.Reflection.Primitives" version="4.3.0" targetFramework="net46" />
  <package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net46" />
  <package id="System.Runtime" version="4.3.0" targetFramework="net46" />
  <package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net46" />
  <package id="System.Runtime.Handles" version="4.3.0" targetFramework="net46" />
  <package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net46" />
  <package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net46" />
  <package id="System.Runtime.Numerics" version="4.3.0" targetFramework="net46" />
  <package id="System.Security.Cryptography.Algorithms" version="4.3.0" targetFramework="net46" />
  <package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net46" />
  <package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net46" />
  <package id="System.Security.Cryptography.X509Certificates" version="4.3.0" targetFramework="net46" />
  <package id="System.Text.Encoding" version="4.3.0" targetFramework="net46" />
  <package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="net46" />
  <package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="net46" />
  <package id="System.Threading" version="4.3.0" targetFramework="net46" />
  <package id="System.Threading.Tasks" version="4.3.0" targetFramework="net46" />
  <package id="System.Threading.Timer" version="4.3.0" targetFramework="net46" />
  <package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="net46" />
Nick Chamberlain
@heynickc
Apr 24 2017 20:35
This is potentially the result of a dependency that has ported to .NET Standard. I've seen this upgrading a project from xunit 2.1.0 to xunit 2.2.0. Just a guess, but I see that <package id="NETStandard.Library" version="1.6.1" targetFramework="net46" /> which is a hint that .NET Standard is the culprit.
IIRC, there were required upgrades to System.Collections.Immutable - might be the source of the introduction of the .NET Standard model to the package dependencies
Mike Johnson
@softwaremike
Apr 24 2017 20:44
I'd agree. So the inclusion of all those "System.*" packages scares me - since I'm already targeting .NET framework 4.6, why would the updater include all those System.Runtime, System.Security, System.Threading, etc packages?
Nick Chamberlain
@heynickc
Apr 24 2017 20:57
Yea that'd be a question for how .NET Standard 1.6 is implemented by any library that gets ported to it. It might be just a consequence of the library cross-compiling to different .NET Standards like .NET Core. Even though it seems like you're pulling in all these packages, if System.Collections.Immutable targets both .NET Core and .NET 4.6 your packages.config will always end up looking like this when you install it.