These are chat archives for akkadotnet/akka.net

8th
Mar 2018
Bjørn Erik Haug
@behaug
Mar 08 2018 09:40
I am writing an application using a windows service acting as a single-node akka.net cluster and it is using DistributedPubSub messaging. I have a client application as a web app that joins the cluster to subscribe to messages. Is this the right approach? I see that if I restart the windows service the web app rejoins the cluster an Tell messages work again, but it is no longer receiving subscribed messages. How do I restore subscriptions in this case?
Bartosz Sypytkowski
@Horusiath
Mar 08 2018 13:06
@behaug if this is your use case, do you even need akka on the first place?
Bjørn Erik Haug
@behaug
Mar 08 2018 13:15
@Horusiath I use akka for the messaging part, not the clustering part. I will run single instance, but I want the message passing with pub/sub. Is there another framework I should look at?
Joshua Garnett
@joshgarnett
Mar 08 2018 13:17
@behaug there was a pub/sub bug fixed in 1.3.5
That said, running distributed pub/sub for a single node does feel a little overkill
I’m assuming when the client connects, it’s re-issuing subscribes?
Bjørn Erik Haug
@behaug
Mar 08 2018 13:19

Thank I will try upgrading to 1.3.5. I am at 1.3.4 now.

When the client starts it will resubscribe, but not if only the server is recycled. How can I implement that?

Joshua Garnett
@joshgarnett
Mar 08 2018 13:20
The client should detect that it needed to reconnect to the server and then re-issue the subscribes. How are you communicating between the client and server?
Bjørn Erik Haug
@behaug
Mar 08 2018 13:20
They join the same cluster
Joshua Garnett
@joshgarnett
Mar 08 2018 13:21
Got it, give 1.3.5 a try and see if that does the trick
You can also look at using deathwatches to detect when other nodes fail
Sebastien Bacquet
@sbacquet
Mar 08 2018 13:21
what is the seed node in your mini-cluster ?
Joshua Garnett
@joshgarnett
Mar 08 2018 13:21
other actors I should say
Bjørn Erik Haug
@behaug
Mar 08 2018 13:22
@sbacquet The seed node is the windows service
for the service it is itself
Sebastien Bacquet
@sbacquet
Mar 08 2018 13:22
Lighthouse ?
Joshua Garnett
@joshgarnett
Mar 08 2018 13:22
You can watch for cluster events too, when a node goes up and down
Sebastien Bacquet
@sbacquet
Mar 08 2018 13:23
ok the service itself
I think you have to install a dedicated seed node
Bjørn Erik Haug
@behaug
Mar 08 2018 13:24
ok cluster events sounds interesting as a possible workaround. Do you have a doc link for this?
Sebastien Bacquet
@sbacquet
Mar 08 2018 13:24
that never crashes
that keep the pub/sub info (suscribers) alive
Bjørn Erik Haug
@behaug
Mar 08 2018 13:24
oh, something that never crashes is hard to guarantee
Sebastien Bacquet
@sbacquet
Mar 08 2018 13:24
a seed node that does nothing is stable
try Lighthouse
it's just a basic node
Bjørn Erik Haug
@behaug
Mar 08 2018 13:26
yes, the code itself is stable, but we may restart the box. This is for in-the-field installs that can get power cycled easily. But all my processing is transient so that part is fine.
What does Lighthouse do?
Sebastien Bacquet
@sbacquet
Mar 08 2018 13:28
it's just a basic cluster node that usually serves as a seed node
other nodes join the cluster through it
you can even run several seed nodes (Lighthouse instances) for failover purpose
Bjørn Erik Haug
@behaug
Mar 08 2018 13:30
ah i see. yes that may work
then i can redeploy or otherwise restart the service or web app, just make sure the lighthouse is up
Sebastien Bacquet
@sbacquet
Mar 08 2018 13:31
yep exactly
Lighthouse can be installed as a Windows service
Bjørn Erik Haug
@behaug
Mar 08 2018 13:32
@joshgarnett do you have any experience triggering resubscription based on the reachability gossip?
Joshua Garnett
@joshgarnett
Mar 08 2018 13:32
Nope, just pointing to what I know about Akka.Cluster :)
Lighthouse sounds like it might be a more sane way to go for you though, so try that out
Bjørn Erik Haug
@behaug
Mar 08 2018 13:33
yep i will. and I'll test upgrading to 1.3.5 first in case it's fixed
Bjørn Erik Haug
@behaug
Mar 08 2018 13:34
thanks :)
Bjørn Erik Haug
@behaug
Mar 08 2018 14:11

I've cloned Lighthouse, changed the cluster name, and updated the akka nugets to the latest. I starts up fine, but when my other service starts up and tries to join I get serialization errors:

Akka.Remote.EndpointWriter: AssociationError [akka.tcp://ClusterSystem@127.0.0.1:4053] <- akka.tcp://ClusterSystem@localhost:8082: Error [Cannot find serializer with id [15]. The most probable reason is that the configuration entry 'akka.actor.serializers' is not in sync between the two systems.]

Neither my service nor Lighthouse have anything in the akka.actor.serializers entry.

Ondrej Pialek
@ondrejpialek
Mar 08 2018 14:12
You need to fallback on default settings of features / packages you are using on all your nodes
dunno if there is a simpler way but in my app all services inherit from the same base class that has the following init code:
        private Config GetBaseConfig()
        {
            var dataPackage = Context.CodePackageActivationContext.GetDataPackageObject("Data");
            var akkaConfigFilename = Path.Combine(dataPackage.Path, "akka.conf");
            var akkaConfigContent = File.ReadAllText(akkaConfigFilename);
            var configFromFile = ConfigurationFactory.ParseString(akkaConfigContent);

            var config = configFromFile.WithFallback(ClusterSingletonManager.DefaultConfig());
            config = config.WithFallback(ClusterSharding.DefaultConfig());
            config = config.WithFallback(DistributedPubSub.DefaultConfig());
            config = config.WithFallback(Persistence.DefaultConfig());

            return config;
        }
Sebastien Bacquet
@sbacquet
Mar 08 2018 14:14
or you disable pub/sub on seed nodes
Bjørn Erik Haug
@behaug
Mar 08 2018 14:15
i tried adding the DistributedPubSubExtensionProvider in Lighthouse but no change. Wouldn't it need this in order to maintain subscriptions for other nodes?
Ondrej Pialek
@ondrejpialek
Mar 08 2018 14:15
@sbacquet I wondered if there is a different way - loading all plugin configs on all nodes seemed a bit weird, since not all nodes used the same features. But it was difficult to figure out the reason for that - so is the DistributedPubSub that complains about the serializers?
Sebastien Bacquet
@sbacquet
Mar 08 2018 14:15
try first to activate pub/sub on nodes other that seed nodes
add :
akka.cluster.pub-sub.role = xxx
akka.cluster.roles = [ xxx ]
on your nodes (except seed)
Bjørn Erik Haug
@behaug
Mar 08 2018 14:21
Lighthouse logs this:
[ERROR][08.03.2018 14:20:25][Thread 0010][[akka://ClusterSystem/system/endpointManager/reliableEndpointWriter-akka.tcp%3A%2F%2FClusterSystem%40localhost%3A8081-1/endpointWriter#1691578347]] Dropping message [Akka.Actor.ActorSelectionMessage] for non-local recipient [[akka.tcp://ClusterSystem@localhost:4053/]] arriving at [akka.tcp://ClusterSystem@localhost:4053] inbound addresses [akka.tcp://ClusterSystem@127.0.0.1:4053]
Cause: Unknown
My service logs this:
[WARNING][08.03.2018 14:20:34][Thread 0006][[akka://ClusterSystem/system/cluster/core/daemon/joinSeedNodeProcess-1#817171708]] Couldn't join seed nodes after [2] attempts, will try again. seed-nodes=[akka.tcp://ClusterSystem@localhost:4053]
Sebastien Bacquet
@sbacquet
Mar 08 2018 14:25
config pb
what is your Lighthouse config ?
Bjørn Erik Haug
@behaug
Mar 08 2018 14:33
seems to work now. I removed all the config massaging in lighthouse startup, and copied the config from my own service. The config is quite simple:
akka {
loglevel = INFO
actor.provider = cluster
remote {
dot-netty.tcp {
port = 4053
hostname = localhost
}
}
cluster {
seed-nodes = ["akka.tcp://ClusterSystem@localhost:4053"]
pub-sub.role = conveyance
roles = [conveyance]
}
extensions = [
"Akka.Cluster.Tools.PublishSubscribe.DistributedPubSubExtensionProvider,Akka.Cluster.Tools",
]
}