These are chat archives for akkadotnet/akka.net

13th
Oct 2016
Wuttipat
@PlanCZero
Oct 13 2016 05:23
Hi. I'm wondering how to check that all chaild actor has done their jobs? Please advise.
I'm using akka.net in c#
Peter Bergman
@peter-bannerflow
Oct 13 2016 06:35
@PlanCZero I think it depends on what a job is to your application and when it is considered as done. But perhaps you could have the child report that work is done to its parent. Then the parent could keep track of this.
Bartosz Sypytkowski
@Horusiath
Oct 13 2016 06:36
@PlanCZero you may want to take a look at the Aggregator pattern
Wuttipat
@PlanCZero
Oct 13 2016 06:50
@peter-bannerflow @Horusiath Thank you for advise. I think Aggregator pattern is what I'm looking for but I'm not sure. I'm newby in akka.
I found some question on StackOverflow, but don't know how to write it in csharp.
Francis Paulin
@paulinfrancis
Oct 13 2016 10:15

If I have a system that looks like this:

ASP .NET with lightweight actor system to talk with SignalR

  • Get remote IActorRef to Actor1 using ActorSelection

Windows Service to do the bulk of the work, and keep state

  • Actor 1, Tells Actor 2
    • Actor 2 tells Sender (Actor 1) when it has finished doing its thing
  • Actor 1 would now like Tell the actor in the ASP .NET app. What is the best way to get an IActorRef to Tell to? It seems strange to use ActorSelection in both ends, but that is maybe the only option?
Bartosz Sypytkowski
@Horusiath
Oct 13 2016 10:55
@paulinfrancis
  • in general using actor selection is usually bad (as it's slower and you don't even know if selected actor is alive). It's better to retrieve IActorRef from actor selection by using either ResolveOne method or by sending Identify request to actor selection and await for ActorIdentity response.
  • depending on your needs you don't always need to call sender back. I've written a blog post, where I described how to make immediate response to initial caller.
  • if for some reason you need to send response to Actor 1 to continue processing, you can always "remember" original sender or carry it as part of the message (IActorRef can be serialized and deserialized within actor system boundaries)
Francis Paulin
@paulinfrancis
Oct 13 2016 10:56
Thanks!
Francis Paulin
@paulinfrancis
Oct 13 2016 11:16

Output from service
[INFO][13.10.2016 11:06:30][Thread 0001][remoting] Remoting now listens on addresses: [akka.tcp://SimulatorSystem@127.0.0.1:8091]
[DEBUG][13.10.2016 11:06:31][Thread 0008][akka://SimulatorSystem/user] now supervising akka://SimulatorSystem/user/Simulator

In the startup of my ASP .NET client actor system:
ActorReferences.Simulator = _actorSystem.ActorSelection("akka.tcp://SimulatorSystem@127.0.0.1:8091/user/Simulator")
.ResolveOne(TimeSpan.FromSeconds(3))
.Result;

Throws:
{"Exception occurred while resolving ActorSelection"}
InnerException: {"subject was null"}

Any quick ideas as to what I might be missing? I have installed Akka.Remote in both projects, and set up hocon to enable remoting in both too.

Bartosz Sypytkowski
@Horusiath
Oct 13 2016 11:18
on which end does that exception occur?
Francis Paulin
@paulinfrancis
Oct 13 2016 11:18
my ASP .NET client
_actorSystem.ActorSelection(...
Bartosz Sypytkowski
@Horusiath
Oct 13 2016 11:20
did you set up this Simulator actor before sending ResolveOne request?
"subject was null" suggests that both ends (both actor systems) have connected successfully, but the one that received the identification request, couldn't find an actor under provided path
Francis Paulin
@paulinfrancis
Oct 13 2016 11:22
yes, it's a topshelf service that I have started (as a console app, without installing the service, for simplicity), and I make sure I see the output indicates that the actor has successfully started before I launch the web app
Bartosz Sypytkowski
@Horusiath
Oct 13 2016 11:23
@Aaronontheweb any ideas?
Francis Paulin
@paulinfrancis
Oct 13 2016 11:40
It's probably worth mentioning that I'm using ASP .NET Core, but targeting 4.6.1. The project does have a web.config, and I was under the impression that it should be possible to use it for hocon, in parallel with the presence of project.json.
Bartosz Sypytkowski
@Horusiath
Oct 13 2016 11:40
I know that akka.remote is not yet compatible with .net core
Francis Paulin
@paulinfrancis
Oct 13 2016 11:41
Should it not be OK though, when using the full framework?
Bartosz Sypytkowski
@Horusiath
Oct 13 2016 11:41
I don't know
Arsene Tochemey GANDOTE
@Tochemey
Oct 13 2016 12:00
Hello Guys can someone show how to define PreStart and PostStop in F# API
Damian Reeves
@DamianReeves
Oct 13 2016 12:04
@paulinfrancis try loading your Hocon by another means... I believe in ASP.NET core web.config is only involved in IIS invocation not in application lifecycle
Vagif Abilov
@object
Oct 13 2016 12:06
@Tochemey F# API doesn't have one-to-one match with C# API, actors in F# are functions, not types, so there are no such overrdes like PreStart and PostStop. If you need to execute some code before actor starts processing messages, just place it in the beginning of the function, prior to the recursive message handler function. And for PostStop you can use mailbox.Defer() and pass it a list of deferrables (disposables) that need to be executed when actor stops.
Francis Paulin
@paulinfrancis
Oct 13 2016 12:16
@DamianReeves Great success!
var config = ConfigurationFactory.ParseString(@"
    akka {
        loglevel = DEBUG

        actor {
            provider = ""Akka.Remote.RemoteActorRefProvider, Akka.Remote""
            debug {
                receive = on
                autoreceive = on
                lifecycle = on
                event-stream = on
                unhandled = on
            }
        }

        remote {
            helios.tcp {
                transport-class = ""Akka.Remote.Transport.Helios.HeliosTcpTransport, Akka.Remote""
                transport-protocol = tcp
                port = 0
                hostname = ""127.0.0.1""
            }
        }
    }");

_actorSystem = ActorSystem.Create("SimulatorSystem", config);
I'll move the config to appsettings.json now, but good to see remoting works with ASP .NET Core targeting full framework :)
Damian Reeves
@DamianReeves
Oct 13 2016 12:41
:thumbsup:
There's a part of me that really wants to build a Microsoft.Extensions.Configuration extension for HOCON. What is the status of HOCON outside of the Akka.NET repo, is https://github.com/akkadotnet/HOCON/commits/master still a thing being worked on?
Andrew Buttigieg
@andrewbuttigieg
Oct 13 2016 13:27
in http://getakka.net/docs/clustering/cluster-client, how do I get a reference to ClusterReceptionist please?
ignore, you need to add Akka.Cluster.Tools via nuget.
verilocation
@verilocation
Oct 13 2016 13:36
Quick question... I have a cluster which deploys geocode actors that will perform geocodes against Google. This is all great BUT google only lets us do 50requests a second. Is there any way I can communicate efficiently between the actors to figure out how many requests have been made per second and to throttle accordingly?
verilocation
@verilocation
Oct 13 2016 14:05
Also.. is there an Akka.net equivalent of this? It'd be really nice to be able to see throughput and such
verilocation
@verilocation
Oct 13 2016 14:31
Also.. in the examples when addressing a clustered router we ask for the routees and check there are any before continuing... this seems like it could be a performance issue.. is this the recommended pre-check?
var routees = await this.GeocodeActor.Ask<Routees>(new GetRoutees());
if (routees.Members.Any()) { /* Do things */ }
Arjen Smits
@Danthar
Oct 13 2016 14:42
@verilocation i think the webcrawler sample has something like that for communicating with the github api. (request throttling)
you might want to look there
verilocation
@verilocation
Oct 13 2016 15:52
@Danthar Hey, thanks, I cant seem to find any mention of throttling or github within that project, any pointers as to where or what to look for?
Daniel D'Agostino
@dandago2_twitter
Oct 13 2016 17:34
Creating a child actor via ActorOf() and Props is a bit of a pain since it takes params object[], which means technically you can pass anything, and you need to make sure you're passing in the right dependencies, or you'll have runtime issues. Is there a clean way to instantiate actors that guarantees compile-time safety?
Damian Reeves
@DamianReeves
Oct 13 2016 17:41
I have a worker executable that I want to do work and shutdown: Is it a bad ID for that worker to join my cluster?
Garrard Kitchen
@garrardkitchen
Oct 13 2016 18:15
Hi @corneliutusnea, were you ever able to form cluster with web app in Azure App Services? I've put the seed in a webjob to run continuously and deploy both webjob and web app in same place (deployed via vsts) and both are running but unfortunately they are not seeing each other. akka messages show no errors (thanks to @andreyleskov). I can see both are running on diff w3wp.exe's. I'm using localhost as hostname on both [webjob + web app] and diff ports.
Damian Reeves
@DamianReeves
Oct 13 2016 18:19
How do I gracefully leave a cluster when my actor system is terminating?
Francis Paulin
@paulinfrancis
Oct 13 2016 18:20

I need to send a largish object with remoting, and an Akka.Remote.OversizedPayloadException is thrown:

Akka.Remote.OversizedPayloadException: Discarding oversized payload sent to [akka.tcp://SimulatorSystem@127.0.0.1:20228/]: max allowed size 128000 bytes, actual size of encoded PPSim.ActorModel.Messages.DiagramLoadedMessage was 723509 bytes.

I've tried setting maximum-frame-size = 4000000b (arbitrary number substantially larger than my message) in both ends:

remote {
    helios.tcp {
        transport-class = ""Akka.Remote.Transport.Helios.HeliosTcpTransport, Akka.Remote""
        transport-protocol = tcp
        port = 0
        hostname = ""127.0.0.1""
        maximum-frame-size = 4000000b
    }
}
Are there other settings I need to set to enable larger messages?
Bartosz Sypytkowski
@Horusiath
Oct 13 2016 18:30
@paulinfrancis sending 700MB message is definitely not a good idea
Francis Paulin
@paulinfrancis
Oct 13 2016 18:36
Shouldn't that be 0.723MB?
Arjen Smits
@Danthar
Oct 13 2016 20:31
@verilocation ah sorry, i was wrong its not in that project. I distinctly remember it being in some sample project. Let me check
Arjen Smits
@Danthar
Oct 13 2016 20:36
@verilocation Cant seem to find what i was looking for. I thought the sample stuff in the bootcamp for communicating with github had some throttling. And it has, but its to basic.
However there are various way you can throttle with Akka. One pattern is described here: http://letitcrash.com/post/28901663062/throttling-messages-in-akka-2 its from the JVM version. but the same principle applies. And should be fairly easy to port to .net.
Alternative is to use the Akka.Streams API
that has throttling mechanisms as well
On a side note. The TimerBasedThrottler could be something that we could offer OOB under the patterns namespace
Akka streams has an throttle operator which you can use
So what you could do is have one actor act as the source of your stream definition, and the google geocode API as your sink
with message mapping and throttling in between
Check the docs: http://getakka.net/docs/streams/quickstart for a good starting point
Arjen Smits
@Danthar
Oct 13 2016 20:42
If you have specific questions regarding Akka.Streams we have an AkkaStreams gitter chat full with capable ppl :)
Marc Piechura
@marcpiechura
Oct 13 2016 20:44
@dandago2_twitter you can also use the factory func and call the constructor of the child actor directly
Damian Reeves
@DamianReeves
Oct 13 2016 20:46
When a node leaves my cluster, the cluster continuously throws exceptions which are being logged... how can I stop that (I know I just not log remote lifecycle events, but that endless cycle of trying to connect to a node seems wasteful)
Bartosz Sypytkowski
@Horusiath
Oct 13 2016 20:51
@paulinfrancis sorry, my mistake. maximum-frame-size should be enough
@DamianReeves maybe you can set auto downing of unreachable actors?
Francis Paulin
@paulinfrancis
Oct 13 2016 20:52
Interesting! I noticed that my collections were null after changing to remoting. I tested a couple of different options, and discovered this:
public class TestMessage
{
    public TestMessage(string message, IEnumerable<string> collection)
    {
        Message = message;
        Collection = collection;
    }

    public string Message { get; } //OK
    public IEnumerable<string> Collection { get; } //null after remoting
}

public class TestMessage
{
    public TestMessage(string message, IEnumerable<string> collection)
    {
        Message = message;
        Collection = collection;
    }

    public string Message { get; private set; } //OK
    public IEnumerable<string> Collection { get; private set;  } //OK
}
Bartosz Sypytkowski
@Horusiath
Oct 13 2016 20:53
@paulinfrancis check if you have referenced newtonsoft.json v8 or higher
Francis Paulin
@paulinfrancis
Oct 13 2016 20:54
@Horusiath I was wrong too - something else was amiss with my configuration, and when I sorted it out then maximum-frame-size did the trick :)
Bartosz Sypytkowski
@Horusiath
Oct 13 2016 20:54
versions below 8 had some problems with C# 7 readonly getters
Francis Paulin
@paulinfrancis
Oct 13 2016 20:56
blob
This message was deleted
Bartosz Sypytkowski
@Horusiath
Oct 13 2016 20:57
maybe it's time to send them an issue ;) beside that I would set Wire as a default serializer if I were you
Francis Paulin
@paulinfrancis
Oct 13 2016 20:58
It's bed tome now, but I'll try and serialize/deserialize an object with a collection { get; } using json.net 9.0.1 tomorrow and see if I can repro
Wire is a lot faster and covers more scenarios
Francis Paulin
@paulinfrancis
Oct 13 2016 20:59
I'll look into Wire - thanks a lot :)
Bartosz Sypytkowski
@Horusiath
Oct 13 2016 20:59
np. see you later
Francis Paulin
@paulinfrancis
Oct 13 2016 21:00
Great! I started with Akka this Monday, and it's been a fun and educational journey so far - especially because of the great community; you guys :)
Corneliu
@corneliutusnea
Oct 13 2016 22:52
@garrardkitchen No, I didn't manage to get the cluster working on App Services. I talked to some MS guys and support and the app is running in a sandbox so you can't open server ports so you can't listen for incoming sockets. https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox
Best I can think we can do is get Akka to use WebSockets instead of Helios
but that's a slightly bigger job than I can take right now
Aaron Stannard
@Aaronontheweb
Oct 13 2016 22:53
@corneliutusnea navigating Azure's managed services is a bit of a minefield
from that perspective
I feel your pain
Corneliu
@corneliutusnea
Oct 13 2016 22:58
@Aaronontheweb yes, but the Azure App Services is great and scales and is minimal maintenance so I think it's really the future :) and that means for me I need a way to make it work
Aaron Stannard
@Aaronontheweb
Oct 13 2016 23:00
makes sense to take ownership of as few things as possible
that's why you won't see me running around wiring up racks
got some interesting results on those polls I did from the webinar
by a country mile most of the people who attended want to know how to run Akka.Cluster in their own data centers ("on-premise")
not at all what I would have guessed
would have assumed a public cloud environment
expected it to be either ARM or Service Fabric
although to be fair it was multiple choice and people did select many things
but the clear majority winner was on-prem
MrR0b0t
@MMrR0b0TT
Oct 13 2016 23:02

guys, I got this error in my log:

2016-10-13 22:48:11.1893|ERROR|Akka.Actor.OneForOneStrategy|An error occurred while updating the entries. See the inner exception for details.

Aaron Stannard
@Aaronontheweb
Oct 13 2016 23:03
huh, weird
MrR0b0t
@MMrR0b0TT
Oct 13 2016 23:03
How should I do to make akka.net print the detailed error always for me
Aaron Stannard
@Aaronontheweb
Oct 13 2016 23:03
is that a custom error message of yours?
MrR0b0t
@MMrR0b0TT
Oct 13 2016 23:03
That's the point, I don't
I dont know
where it came out
is it seem?
Aaron Stannard
@Aaronontheweb
Oct 13 2016 23:03
in general the default logger will always print out the full stack trace
from wherever it was thrown
MrR0b0t
@MMrR0b0TT
Oct 13 2016 23:04
Sure, I will look for then
Thank Aaron
Aaron Stannard
@Aaronontheweb
Oct 13 2016 23:04
no problem man
feels good to be back in Gitter chat
was on vacation for a bit and then been working nonstop on an Akka.NET project here in the UK
wrapped up the first stage of that today and coming back to USA tomorrow
Akka.Streams is bad ass
spent a lot of time with that on this project
some of the concepts built into it, like materialization, are things I'm still wrapping my head around
MrR0b0t
@MMrR0b0TT
Oct 13 2016 23:06
I'm in Brazil. I starting using Akka.net has 4 months ago. I enjoy it a lot
Aaron Stannard
@Aaronontheweb
Oct 13 2016 23:07
@MMrR0b0TT :+1: welcome to the team
alright, it's late as hell here
MrR0b0t
@MMrR0b0TT
Oct 13 2016 23:07
thanks! @Aaronontheweb
Aaron Stannard
@Aaronontheweb
Oct 13 2016 23:07
off to bed
MrR0b0t
@MMrR0b0TT
Oct 13 2016 23:30
Aaron, can be something in the NLog?
I didn't find any place I could be treating that message
Andrew Young
@ayoung
Oct 13 2016 23:48
are there any resources or documentation about how to deal with cluster node failures and recovery?