These are chat archives for akkadotnet/

Nov 2017
Arsene T. Gandote
Nov 17 2017 07:25
Hello is it recommended for C#7 users to use UntypedActor instead of ReceiveActor
can someone explain me why?
Ismael Hamed
Nov 17 2017 08:13
This is killing one of our nodes. Do you guys have any clue of what might be happening? That Mailbox in the stacktrace...
Failed to stop service. System.InvalidOperationException: An unhandled exception was detected ---> System.ArgumentOutOfRangeException: Delay must be >=0. It was -8.01:03:19.6760000
Parameter name: parameterName
   at Akka.Actor.SchedulerBase.ValidateDelay(TimeSpan delay, String parameterName)
   at Akka.Actor.SchedulerBase.Akka.Actor.ITellScheduler.ScheduleTellOnce(TimeSpan delay, ICanTell receiver, Object message, IActorRef sender, ICancelable cancelable)
   at Akka.Actor.ActorCell.CheckReceiveTimeout()
   at Akka.Actor.ActorCell.Invoke(Envelope envelope)
   at Akka.Dispatch.Mailbox.ProcessMailbox(Int32 left, Int64 deadlineTicks)
   at Akka.Dispatch.Mailbox.ProcessMailbox()
   at Akka.Actor.ActorCell.UseThreadContext(Action action)
   at Akka.Dispatch.Mailbox.Run()
   at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   --- End of inner exception stack trace ---
   at Topshelf.Runtime.Windows.WindowsServiceHost.O...
Bart de Boer
Nov 17 2017 08:14

Yes, you're scheduling smth in the past (datetimeoffset) or with a negative delay - that's not supported and will lead to this

This is killing one of our nodes. Do you guys have any clue of what might be happening? That Mailbox in the stacktrace...

In your case, 8 days in the past. But in general this design is the reason you should never use the 'datetime' version of ScheduleTellOnce (etc), because you can never be sure what exact datetime the scheduler will be comparing your time to.
IMO it should just round it up to 'immediately', but that's just me. I end up writing the same code all the time:
var delay = whenItShouldHappen - Scheduler.Now;
if (delay.Ticks < 0) delay = TimeSpan.Zero;
Scheduler.ScheduleTellOnce( delay, ....);
instead of Scheduler.ScheduleTellOnce( whenItShouldHappen, ...);
Bartosz Sypytkowski
Nov 17 2017 08:39
@Tochemey with C# 7 you can do switch(msg) { case MessageType t: }. You can pattern match using language primitives directly instead of using Akka.NET methods.
Arsene T. Gandote
Nov 17 2017 08:41
@Horusiath Thanks I tought as well.
Ismael Hamed
Nov 17 2017 08:50
@boekabart Makes sense, thanks!
Nov 17 2017 12:37
@Horusiath Thanks for the answer. It would be nice i.m.h.o. if documentation would mention it.
But then again, I am a beginner.
Nov 17 2017 12:43
@Horusiath Will Akka.Net migrate to C# 7 any time soon? We also need string interpolation for lean logging code.
cyril andreichuk
Nov 17 2017 13:35
@Horusiath regarding an example for the issue 3188: yes, i'll add an example later -- this week was and is very busy
Bartosz Sypytkowski
Nov 17 2017 14:00
@HermansG Akka.Net is already written in C# 7. You can use string interpolation for log messages. It's just not optimial if your log level won't accept this string, as string interpolation generates new string each time, producing potential garbage.
Nov 17 2017 14:07
@Horusiath You are right, my mistake. We noticed that ILoggingAdapter Logger = Context.GetLogger() gave a kind of garbarge in Seq, but we think because the internals needs the objects of parameter param[]?
Arjen Smits
Nov 17 2017 14:24
@HermansG Serilog integration has some additional helpers for that. See:
Nov 17 2017 14:38
@Danthar Bedankt, interessant ik ga er naar kijken. == I will have a look, thank you.
Stijn Herreman
Nov 17 2017 17:00
I'm doing (manual) integration tests for an actor system, and I'm not sure how to set up the "entry point". Long term this should be an always-running service, but currently it's an executable launched on demand. I send a message with Tell() to one of the configured top-level actors and then do await system.WhenTerminated;, so Sender is akka://System/deadLetters. I'm thinking of creating a catch-all client actor, and passing that actor as the sender for the entry point message. Does that sound right? What's usually done in this case?
If this is mentioned in the documentation, my apologies, I couldn't find it :)
Joshua Garnett
Nov 17 2017 20:08
hmm, I’m running into an issue with Become
2017-11-17 15:01:19.100 ERROR OneForOneStrategy - You may only call Receive-methods when constructing the actor and inside Become(). 
System.InvalidOperationException: You may only call Receive-methods when constructing the actor and inside Become().
  at Akka.Actor.ReceiveActor.EnsureMayConfigureMessageHandlers () [0x0000e] in <388272c00ff54cb2808e25c3aa633b3f>:0 
  at Akka.Actor.ReceiveActor.Receive[T] (System.Action`1[T] handler, System.Predicate`1[T] shouldHandle) [0x00000] in <388272c00ff54cb2808e25c3aa633b3f>:0 
  at Foo.SomeReceive (System.Object message) [0x00014] in <787950a78e0749b9aaa29f6f58c5dc4e>:0 
  at Akka.Actor.ActorCell+<>c__DisplayClass106_0.<Akka.Actor.IUntypedActorContext.Become>b__0 (System.Object m) [0x00000] in <388272c00ff54cb2808e25c3aa633b3f>:0 
  at Akka.Actor.ActorBase.AroundReceive (Akka.Actor.Receive receive, System.Object message) [0x00000] in <388272c00ff54cb2808e25c3aa633b3f>:0 
  at Akka.Actor.ActorCell.ReceiveMessage (System.Object message) [0x00011] in <388272c00ff54cb2808e25c3aa633b3f>:0 
  at Akka.Actor.ActorCell.Invoke (Akka.Actor.Envelope envelope) [0x00057] in <388272c00ff54cb2808e25c3aa633b3f>:0
It’s saying I can only call Receive methods from within a constructor or Become, but as you can see form that stack, I’m calling it through Become
Joshua Garnett
Nov 17 2017 20:20
Looks like it might just be a documentation problem
// Become(Angry) doesn’t work
private void Angry(object message)

// Become(Happy) does work
private void Happy()
Bart de Boer
Nov 17 2017 21:37
What object would you expect to be passed in to a new Behaviour setup (the method you pass into Become )
Joshua Garnett
Nov 17 2017 21:37
No clue, I was just following the documentation :)
Bart de Boer
Nov 17 2017 22:26
Interesting, never noticed that version (nor that it doesn't actually work) - maybe outdated/deprecated version (and indeed, stale dox)
Jesse Connor
Nov 17 2017 23:57
Question, I need to get a large amount of init data from a remote actor that is called from an api, however due to message sizes I can't just send it all at once. Are there any other options other than building an actor locally and having it consolidate messages from the remote actor? Previously I was sending it down in chunks over websockets, but I've found them to be less than reliable when needing large amounts of init data.