How to cleanly shut down/disassociate a local actor ref for a remote actor

267 views
Skip to first unread message

Erik Nelson

unread,
Jan 10, 2014, 10:27:18 PM1/10/14
to <akka-user@googlegroups.com>
Hi gang,

I've been playing with our remoting connection management library, and ran into a bit of a problem. I want to be able to disconnect and reconnect to a given server, but if I shutdown a local ActorRef that is associated with a remote actor, the remote becomes unable to accept new connections. I assume this is by design - the shutdown happens both locally and remotely(*). But I can't figure out how to just DISASSOCIATE the local actor ref, and I feel like if I don't then I'm going to have a memory leak over time. It's possible that this is only an issue in my test case, since in reality the case is that I only disconnect when the server goes down.

But it Just Feels Wrong to not be able to shut down that remotely associated ActorRef! I can't find anything in the documentation, and the Disassociate class definitely doesn't seem to be something I should be using directly.

This is with 2.2.3, and I'm using actor selection.

(*) What I see actually happening in the debug logging is that when the server gets the Identify and tries to create its reciprocal connection to the client to respond, it gets a connection refused. And then goes ahead sending the Identify, but with a None as the ActorRef. The client has definitely reported listening on the port in question, so I feel like the connection refused is a red herring, and the reality is that it has no ActorRef to respond with because something internal has shut down.

Thanks!

erik


Patrik Nordwall

unread,
Jan 11, 2014, 9:08:18 AM1/11/14
to akka...@googlegroups.com
Hi Erik,

There is no way to shutdown/close a remote connection.
When you say that you shutdown the ActorRef, I guess that you are using system.stop(ref), which stops the actor. Thereafter you can't identify the actor again, because the actor is terminated.

At some point we might implement automatic disassociation of idle connections.

Regards,
Patrik




 erik


--
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: http://akka.io/faq/
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/groups/opt_out.



--

Patrik Nordwall
Typesafe Reactive apps on the JVM
Twitter: @patriknw

Erik Nelson

unread,
Jan 12, 2014, 3:08:36 AM1/12/14
to <akka-user@googlegroups.com>
Thank you!

I will say that, even though I understand why this is the case, it's a bit strange in practice. Given the fact that multiple clients can connect to the same server, the ability to terminate that way is, well... perhaps a bit strange.

I suspect it will not be an issue now that I have figured it out, but this might be something that could use a brief call out in the documentation - even just a single sentence indicating that stopping a remote associated ActorRef will stop the associated actor as well. I know that would have saved me a pretty big chunk of time!

 erik

Patrik Nordwall

unread,
Jan 12, 2014, 4:58:06 AM1/12/14
to akka...@googlegroups.com
On Sun, Jan 12, 2014 at 9:08 AM, Erik Nelson <er...@gravity.com> wrote:
Thank you!

I will say that, even though I understand why this is the case, it's a bit strange in practice. Given the fact that multiple clients can connect to the same server, the ability to terminate that way is, well... perhaps a bit strange.

I suspect it will not be an issue now that I have figured it out, but this might be something that could use a brief call out in the documentation - even just a single sentence indicating that stopping a remote associated ActorRef will stop the associated actor as well.

ActorRef has the same semantics for local and remote actors:

/Patrik

√iktor Ҡlang

unread,
Jan 12, 2014, 5:56:21 AM1/12/14
to Akka User List

Hi Erik,

Akka's semantics of stop I'd say is quite well documented, both in the reference documentation:

http://doc.akka.io/docs/akka/2.2.3/scala/actors.html#Stopping_actors

And in code:

" ActorRef does not have a method for terminating the actor it points to, use akka.actor.ActorRefFactory.stop(ref), or send a akka.actor.PoisonPill, for this purpose" - http://doc.akka.io/api/akka/2.2.3/#akka.actor.ActorRef

" abstract def
stop(actor: ActorRef): Unit
Stop the actor pointed to by the given akka.actor.ActorRef; this is an asynchronous operation, i.e. involves a message send." - http://doc.akka.io/api/akka/2.2.3/#akka.actor.ActorRefFactory

Cheers,
V

Erik Nelson

unread,
Jan 13, 2014, 1:36:38 PM1/13/14
to <akka-user@googlegroups.com>
I still feel like it's somewhat ambiguous in a remoting context, because there is not a one-to-one relationship, but the only remaining issue I really have is that there seems to be no way of preventing a fair amount of scary logs on the server when the client process exits:

[INFO] [01/10/2014 19:43:55.950] [RemoteOperationsServer-11000-akka.actor.default-dispatcher-5] [akka://RemoteOperationsServer-11000/system/transports/akkaprotocolmanager.tcp0/akkaProtocol-tcp%3A%2F%2FRemoteOperationsServer-11000%4010.120.2.49%3A57256-1] Message [akka.remote.transport.ActorTransportAdapter$DisassociateUnderlying] from Actor[akka://RemoteOperationsServer-11000/deadLetters] to Actor[akka://RemoteOperationsServer-11000/system/transports/akkaprotocolmanager.tcp0/akkaProtocol-tcp%3A%2F%2FRemoteOperationsServer-11000%4010.120.2.49%3A57256-1#-800873166] was not delivered. [1] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
akka.remote.EndpointAssociationException: Association failed with [akka.tcp://RemoteOpera...@eriks-macbook.local:3001]
Caused by: akka.remote.transport.netty.NettyTransport$$anonfun$associate$1$$anon$2: Connection refused: eriks-macbook.local/10.120.2.49:3001
]
akka.remote.EndpointAssociationException: Association failed with [akka.tcp://RemoteOpera...@eriks-macbook.local:3001]
Caused by: akka.remote.transport.netty.NettyTransport$$anonfun$associate$1$$anon$2: Connection refused: eriks-macbook.local/10.120.2.49:3001
]
akka.remote.EndpointAssociationException: Association failed with [akka.tcp://RemoteOpera...@eriks-macbook.local:3001]
Caused by: akka.remote.transport.netty.NettyTransport$$anonfun$associate$1$$anon$2: Connection refused: eriks-macbook.local/10.120.2.49:3001
]


I'm a pretty big proponent of there not being things in a log labeled ERROR if there is no error, but if I can't disassociate an actor ref this is inevitable.

Thanks,

 erik
Reply all
Reply to author
Forward
0 new messages