Akka Remote Actor - ClosedChannelException

353 views
Skip to first unread message

max

unread,
Dec 30, 2011, 6:02:18 AM12/30/11
to Akka User List
Hello everyone,

I wanted to do some testing with akka but I ran into a problem.

I register a remote server actor. This remote server actor sends a
message with an network actor to the client. The network actor was
created on the server and started there. The client then sends a
message to the network actor but I get the following exception when
the serialized network actor is send from the server:

test remote server:
[GENERIC] [12/30/11 11:31 AM]
[RemoteServerStarted(akka.remote.netty.NettyRemoteSupport@63cd66ea)]
[GENERIC] [12/30/11 11:32 AM]
[RemoteServerClientConnected(akka.remote.netty.NettyRemoteSupport@63cd66ea,Some(/
10.10.10.139:50960))]
SERVER: GOT MESSAGE test.TestServer$SomeMessage@45e67e6aon
test.TestServer@1f758500
[GENERIC] [12/30/11 11:32 AM]
[RemoteClientError(java.net.ConnectException: Connection
refused,akka.remote.netty.NettyRemoteSupport@63cd66ea,/
10.10.10.139:2552)]
[GENERIC] [12/30/11 11:32 AM]
[RemoteClientError(java.net.ConnectException: Connection
refused,akka.remote.netty.NettyRemoteSupport@63cd66ea,/
10.10.10.139:2552)]
[GENERIC] [12/30/11 11:32 AM]
[RemoteClientError(java.nio.channels.ClosedChannelException,akka.remote.netty.NettyRemoteSupport@63cd66ea,/
10.10.10.139:2552)]
SERVER: GOT MESSAGE test.TestServer$RequestMessage@68302e67on
test.TestServer@1f758500
[GENERIC] [12/30/11 11:32 AM] [RemoteClientWriteFailed(uuid {
high: 9536806518902559201
low: 12687484738590420383
}
actorInfo {
uuid {
high: 9535775726751519201
low: 12687484738590420383
}
target: "test.TestClient"
timeout: 5000
actorType: SCALA_ACTOR
id: "uuid:84130c20-32d1-11e1-ab7d-002608df2d9f"
}
oneWay: true
message {
serializationScheme: JAVA
message: "\254\355\000\005sr\000\035test.TestServer$ReturnMessage
\303\334\370\264\230\027O\002\000\000xp"
}
sender {
classOrServiceName: "uuid:8148efa0-32d1-11e1-b013-002608df2d9f"
actorClassname: "test.TestServer"
homeAddress {
hostname: "10.10.10.139"
port: 12345
}
timeout: 5000
}
,java.nio.channels.ClosedChannelException,akka.remote.netty.NettyRemoteSupport@63cd66ea,/
10.10.10.139:2552)]
[GENERIC] [12/30/11 11:32 AM]
[RemoteClientError(java.nio.channels.ClosedChannelException,akka.remote.netty.NettyRemoteSupport@63cd66ea,/
10.10.10.139:2552)]
[ERROR] [12/30/11 11:32 AM] [akka:event-driven:dispatcher:global-3]
[LocalActorRef] null
java.nio.channels.ClosedChannelException
at
org.jboss.netty.channel.socket.nio.NioWorker.cleanUpWriteBuffer(NioWorker.java:
643)
at
org.jboss.netty.channel.socket.nio.NioWorker.writeFromUserCode(NioWorker.java:
370)
at
org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink.eventSunk(NioClientSocketPipelineSink.java:
117)
at org.jboss.netty.channel.Channels.write(Channels.java:632)
at
org.jboss.netty.handler.codec.oneone.OneToOneEncoder.handleDownstream(OneToOneEncoder.java:
70)
at org.jboss.netty.channel.Channels.write(Channels.java:632)
at
org.jboss.netty.handler.codec.oneone.OneToOneEncoder.handleDownstream(OneToOneEncoder.java:
70)
at org.jboss.netty.channel.Channels.write(Channels.java:611)
at org.jboss.netty.channel.Channels.write(Channels.java:578)
at org.jboss.netty.channel.AbstractChannel.write(AbstractChannel.java:
251)
at akka.remote.netty.RemoteClient.send(NettyRemoteSupport.scala:292)
at akka.remote.netty.RemoteClient.send(NettyRemoteSupport.scala:252)
at akka.remote.netty.NettyRemoteClientModule$$anonfun$send
$1.apply(NettyRemoteSupport.scala:109)
at akka.remote.netty.NettyRemoteClientModule$$anonfun$send
$1.apply(NettyRemoteSupport.scala:109)
at akka.remote.netty.NettyRemoteClientModule
$class.withClientFor(NettyRemoteSupport.scala:134)
at
akka.remote.netty.NettyRemoteSupport.withClientFor(NettyRemoteSupport.scala:
647)
at akka.remote.netty.NettyRemoteClientModule
$class.send(NettyRemoteSupport.scala:109)
at akka.remote.netty.NettyRemoteSupport.send(NettyRemoteSupport.scala:
647)
at akka.actor.RemoteActorRef.postMessageToMailbox(ActorRef.scala:
1255)
at akka.actor.ScalaActorRef$class.$bang(ActorRef.scala:1419)
at akka.actor.RemoteActorRef.$bang(ActorRef.scala:1224)
at akka.actor.ActorRef$class.reply(ActorRef.scala:398)
at akka.actor.LocalActorRef.reply(ActorRef.scala:605)
at test.TestServer.onReceive(Unknown Source)
at akka.actor.UntypedActor$$anonfun$receive
$1.apply(UntypedActor.scala:125)
at akka.actor.UntypedActor$$anonfun$receive
$1.apply(UntypedActor.scala:124)
at akka.actor.Actor$class.apply(Actor.scala:545)
at akka.actor.UntypedActor.apply(UntypedActor.scala:57)
at akka.actor.LocalActorRef.invoke(ActorRef.scala:910)
at akka.dispatch.MessageInvocation.invoke(MessageHandling.scala:25)
at akka.dispatch.ExecutableMailbox
$class.processMailbox(ExecutorBasedEventDrivenDispatcher.scala:223)
at akka.dispatch.ExecutorBasedEventDrivenDispatcher$$anon
$4.processMailbox(ExecutorBasedEventDrivenDispatcher.scala:123)
at akka.dispatch.ExecutableMailbox
$class.run(ExecutorBasedEventDrivenDispatcher.scala:195)
at akka.dispatch.ExecutorBasedEventDrivenDispatcher$$anon
$4.run(ExecutorBasedEventDrivenDispatcher.scala:123)
at java.util.concurrent.ThreadPoolExecutor
$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor
$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
at akka.dispatch.MonitorableThread.run(ThreadPoolBuilder.scala:192)


I don't know how to solve this problem. The serialization of the actor
is done flowing the instruction at
http://akka.io/docs/akka/1.3-RC4/scala/serialization.html#serialization-of-a-remoteactorref
.

Currently I use the default akka configuration.
The source code and instructions to reproduce the error you will find
in the google code project https://code.google.com/p/akka-remote-error-example/

The project was tested with akka version 1.3 rc4 and 1.2. In the
project you have the instructions for 3 different test cases. The
first one don't uses any remote stuff but with this test case you can
see that the actors are working properly. The second test case uses
the remote stuff but everything is in the same vm. The third test case
you have to run in tow different terminals and here the error occurs.

Thanks for any help

Max

√iktor Ҡlang

unread,
Dec 30, 2011, 6:11:09 AM12/30/11
to akka...@googlegroups.com
Hi Max,

have you've started remote on all nodes?
Are all nodes DNS-resolve-reachable from eachother?

Cheers,



Max

--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.




--
Viktor Klang

Akka Tech Lead
Typesafe - Enterprise-Grade Scala from the Experts

Twitter: @viktorklang

max

unread,
Dec 31, 2011, 4:40:06 AM12/31/11
to Akka User List
Hello Viktor,

yes I have started the remote service and registered the server.

Currently my setup is the following:

Virtual Machine for the server:
Actors.remote().start("localhost", 12345);
Actors.remote().register("TEST_SERVER",
Actors.actorOf(TestServer.class));

Virtual Machine for the client:
ActorRef server = Actors.remote().actorFor("TEST_SERVER",
"localhost", 12345);

ActorRef client = Actors.actorOf(TestClient.class);
client.start();

server.tell(new TestServer.SomeMessage(), client);
server.tell(new TestServer.RequestMessage(), client);

As you can see the server receives the first message from the client
but fails to reply. If I run the commands in the same virtual machine
everything works fine. I also did a test over a real network were
server and client are on different machines. Here I get the same
problem.

Cheers

Max
> > [RemoteClientError(java.nio.channels.ClosedChannelException,akka.remote.netty.NettyRemoteSupport@63cd66ea
> > ,/
> >http://akka.io/docs/akka/1.3-RC4/scala/serialization.html#serializati...
> > .
>
> > Currently I use the default akka configuration.
> > The source code and instructions to reproduce the error  you will find
> > in the google code project
> >https://code.google.com/p/akka-remote-error-example/
>
> > The project was tested with akka version 1.3 rc4 and 1.2. In the
> > project you have the instructions for 3 different test cases. The
> > first one don't uses any remote stuff but with this test case you can
> > see that the actors are working properly.  The second test case uses
> > the remote stuff but everything is in the same vm. The third test case
> > you have to run in tow different terminals and here the error occurs.
>
> > Thanks for any help
>
> > Max
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Akka User List" group.
> > To post to this group, send email to akka...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > akka-user+...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/akka-user?hl=en.
>
> --
> Viktor Klang
>
> Akka Tech Lead
> Typesafe <http://www.typesafe.com/> - Enterprise-Grade Scala from the
> Experts
>
> Twitter: @viktorklang

rkuhn

unread,
Dec 31, 2011, 5:13:26 AM12/31/11
to akka...@googlegroups.com
Hi Max,

What Viktor meant was: Actors.remote().start() must be called on _all_ nodes, also the client. The reason is that .tell() replies do not reuse the inbound connection on the server in Akka 1.x (this is one of the enhancements in 2.0).

Regards,

Roland


Am Samstag, 31. Dezember 2011 10:40:06 UTC+1 schrieb max:
Hello Viktor,

yes I have started the remote service and registered the server.

Currently my setup is the following:

Virtual Machine for the server:
  Actors.remote().start("localhost", 12345);
  Actors.remote().register("TEST_SERVER",
Actors.actorOf(TestServer.class));

Virtual Machine for the client:
  ActorRef server = Actors.remote().actorFor("TEST_SERVER",
"localhost", 12345);

  ActorRef client = Actors.actorOf(TestClient.class);
  client.start();

  server.tell(new TestServer.SomeMessage(), client);
  server.tell(new TestServer.RequestMessage(), client);

As you can see the server receives the first message from the client
but fails to reply. If I run the commands in the same virtual machine
everything works fine. I also did a test over a real network were
server and client are on different machines. Here I get the same
problem.

Cheers

Max

max

unread,
Dec 31, 2011, 5:45:58 AM12/31/11
to Akka User List
Hello Roland,

thanks for the clarification. Now everything works. I have read the
the documentation carefully before I started to ask questions but I
couldn't find a hint to that solution.

Maybe you should make it more clear by extending the documentation on
remote actors. E.g. the client side usages in
http://akka.io/docs/akka/1.3-RC4/java/remote-actors.html#client-side-usage
and
http://akka.io/docs/akka/1.3-RC4/scala/remote-actors.html#client-side-usage
.

But again thanks for the answer.

Cheers

Max
> ...
>
> read more »

√iktor Ҡlang

unread,
Dec 31, 2011, 6:01:57 AM12/31/11
to akka...@googlegroups.com
Hi Max,

glad that it works now.

Cheers,
Typesafe - Enterprise-Grade Scala from the Experts

Twitter: @viktorklang

rkuhn

unread,
Dec 31, 2011, 7:56:34 AM12/31/11
to akka...@googlegroups.com
I included the missing line in the code samples for 1.3.

Regards,

Roland
> > > > To post to this group, send email to akk...@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > akka-u...@googlegroups.com.

√iktor Ҡlang

unread,
Dec 31, 2011, 8:12:23 AM12/31/11
to akka...@googlegroups.com

Thx Roland

To view this discussion on the web visit https://groups.google.com/d/msg/akka-user/-/rO25epLjixYJ.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.

Christophe Pache

unread,
Jan 31, 2012, 6:54:36 AM1/31/12
to Akka User List
Sorry about that but I just can't create a tiny remote connection
example between two Akka nodes. I read carefully the documentation,
but I may have miss some behavioral point.

I always get some "java.nio.channels.ClosedChannelException", even if
I start remote actor on both nodes. I have not find any port 2552 open
during my tests, is this the reason?

I use the 1.3-RC5 version for the moment.

the code is pasted here : http://pastebin.com/akwLEmmf

Many thanks in advance for any help

√iktor Ҡlang

unread,
Jan 31, 2012, 7:10:20 AM1/31/12
to akka...@googlegroups.com
Hi Christophe,

Right at the first code example I can see you're not following the docs.

Cheers,


--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.




--
Viktor Klang

Akka Tech Lead
Typesafe - The software stack for applications that scale

Twitter: @viktorklang

Christophe Pache

unread,
Jan 31, 2012, 7:12:05 AM1/31/12
to Akka User List
The remote actor might also be stopped, but why and how to keep it
alive then?

here are my logs : http://pastebin.com/sFf8ppta

Christophe Pache

unread,
Jan 31, 2012, 7:29:33 AM1/31/12
to Akka User List
Thanks
I got it, I was not thinking in server/client behavior, I need to
start the remote nodes on the right(same) address.


On Jan 31, 1:10 pm, √iktor Ҡlang <viktor.kl...@gmail.com> wrote:
> Hi Christophe,
>
> follow the docs:http://akka.io/docs/akka/1.3/scala/remote-actors.html
> Right at the first code example I can see you're not following the docs.
>
> Cheers,
> √
>
> On Tue, Jan 31, 2012 at 12:54 PM, Christophe Pache <chpa...@gmail.com>wrote:
>
>
>
>
>
>
>
>
>
> > Sorry about that but I just can't create a tiny remote connection
> > example between two Akka nodes. I read carefully the documentation,
> > but I may have miss some behavioral point.
>
> > I always get some "java.nio.channels.ClosedChannelException", even if
> > I start remote actor on both nodes. I have not find any port 2552 open
> > during my tests, is this the reason?
>
> > I use the 1.3-RC5 version for the moment.
>
> > the code is pasted here :http://pastebin.com/akwLEmmf
>
> > Many thanks in advance for any help
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Akka User List" group.
> > To post to this group, send email to akka...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > akka-user+...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/akka-user?hl=en.
>
> --
> Viktor Klang
>
> Akka Tech Lead
> Typesafe <http://www.typesafe.com/> - The software stack for applications
> that scale
>
> Twitter: @viktorklang

√iktor Ҡlang

unread,
Jan 31, 2012, 7:30:29 AM1/31/12
to akka...@googlegroups.com
Happy hAkking! :-)

Cheers,
Typesafe - The software stack for applications that scale

Twitter: @viktorklang

Christophe Pache

unread,
Feb 10, 2012, 3:54:01 PM2/10/12
to Akka User List
Hello again

I think I understood pretty well the doc now, but I still get a
problem. I'm able to connect to an Actor from a TypedActor, but when
accessing a typedactor from an untyped, I get a NullPointerException.
I just can't find any explanation, I think the typedactor is not well
stored in the remote registry, but I dont know why. I control and I
have the right trait in both node, both remote servers are connected
and none is stopped while testing.

Any help would be great (working with akka 1.3-RC3)

code : http://pastebin.com/VtdQbHYA

Many thanks

Cheers,
Christophe

rkuhn

unread,
Feb 10, 2012, 4:48:20 PM2/10/12
to akka...@googlegroups.com
I’m not an expert on this special part of the 1.3 remoting, and my brain is a bit foggy, but it looks to me like Akka has some trouble finding the method you are trying to call. Might that have something to do with your rather queer inheritance from EndpointManager to EndpointManager?

Regards,

Roland
> > > > akka-user+unsubscribe@googlegroups.com.
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/akka-user?hl=en.
>
> > > --
> > > Viktor Klang
>
> > > Akka Tech Lead
> > > Typesafe <http://www.typesafe.com/> - The software stack for
> > applications
> > > that scale
>
> > > Twitter: @viktorklang
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Akka User List" group.
> > To post to this group, send email to akka...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > akka-user+unsubscribe@googlegroups.com.

Christophe Pache

unread,
Feb 11, 2012, 3:39:59 AM2/11/12
to Akka User List
Sorry about that, i did two mistakes in my pastie:
Class EndpointManagerImpl
The connection is done in both senses as the dispatcher is got using
remote.actorFor.
I'll correct the paste, but i'll try to avoid that remote typed actor
with an untyped one.

Thanks a lot
Chris
> > > > > > akka-user+...@googlegroups.com.
> > > > > > For more options, visit this group at
> > > > > >http://groups.google.com/group/akka-user?hl=en.
>
> > > > > --
> > > > > Viktor Klang
>
> > > > > Akka Tech Lead
> > > > > Typesafe <http://www.typesafe.com/> - The software stack for
> > > > applications
> > > > > that scale
>
> > > > > Twitter: @viktorklang
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "Akka User List" group.
> > > > To post to this group, send email to akka...@googlegroups.com.
> > > > To unsubscribe from this group, send email to
> > > > akka-user+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages