javadockerakkaakka-remoting

Error using akka remoting with artery over docker instances


First of all, sorry for my english. Google translate helps me a lot, haha.

My problem is this:

I have two example projects developed with akka and java: example-remote-client.jar and example-remote-server.jar

I'm using artery serialization, and and i'm trying to send messages from client to server via akka-remoting.

The client actor that does that is:

public class ClientActor extends AbstractActor {

    public static Props props() {
        return Props.create(ClientActor.class);

    }

    public ClientActor() {
        ActorSelection selection = getContext().system().actorSelection("akka://server@localhost:5001/user/server-process");
        selection.tell(new MessageRequest(), getSelf());
    }

    public Receive createReceive() {
        return receiveBuilder().match(MessageResponse.class, msg -> {
            System.out.println(msg.getMessage());
        }).build();
    }
}

My client configuration:

akka {
  loglevel = "DEBUG"

  actor {
    provider = remote
    allow-java-serialization = off


    serializers {
      java = "akka.serialization.JavaSerializer"
      myown = "serializers.ExampleByteBufSerializer"
    }

    serialization-bindings {
      "java.lang.String" = myown
      "protocol.MessageRequest" = myown
      "protocol.MessageResponse" = myown
      "java.lang.Boolean" = myown
    }

  }

  remote {
    artery {
      enabled = on
      canonical.hostname = "192.168.0.250"     # external (logical) hostname
      canonical.port = 5000                   # external (logical) port

      bind.hostname = "localhost" # internal (bind) hostname
      bind.port = 10000              # internal (bind) port
    }
  }
}

The server actor is very dummy, i dont think it is necessary to paste it here. But its configuration is:

akka {
  loglevel = "DEBUG"

  actor {
    provider = remote
    allow-java-serialization = off


    serializers {
      java = "akka.serialization.JavaSerializer"
      myown = "serializers.ExampleByteBufSerializer"
    }

    serialization-bindings {
      "java.lang.String" = myown
      "protocol.MessageRequest" = myown
      "protocol.MessageResponse" = myown
      "java.lang.Boolean" = myown
    }

  }

  remote {
    artery {
      enabled = on
      canonical.hostname = "192.168.0.250"     # external (logical) hostname
      canonical.port = 5001                   # external (logical) port

      bind.hostname = "localhost" # internal (bind) hostname
      bind.port = 10001              # internal (bind) port
    }
  }
}

Both jar are deployed over docker instances running over the same "192.168.0.250 machine", as seen below:

CONTAINER ID        IMAGE                      COMMAND                  CREATED             STATUS              PORTS                                            NAMES
d2970bd20371        openjdk:alpine             "sh"                     34 minutes ago      Up 34 minutes       0.0.0.0:5001->10001/tcp                          ex-remoting-server
36a67fea8590        openjdk:alpine             "sh"                     34 minutes ago      Up 34 minutes       0.0.0.0:5000->10000/tcp                          ex-remoting-client

The server starts ok, with the following log:

[DEBUG] [07/04/2017 13:46:18.473] [main] [EventStream(akka://server)] logger log1-Logging$DefaultLogger started
[DEBUG] [07/04/2017 13:46:18.473] [main] [EventStream(akka://server)] Default Loggers started
[DEBUG] [07/04/2017 13:46:18.495] [main] [akka.serialization.Serialization(akka://server)] Replacing JavaSerializer with DisabledJavaSerializer, due to `akka.actor.allow-java-serialization = off`.
[INFO] [07/04/2017 13:46:18.628] [main] [akka.remote.artery.ArteryTransport(akka://server)] Started embedded media driver in directory [/dev/shm/aeron-root-server-efd42dec-452d-406c-8d1d-807e0d8ff7fc]
[INFO] [07/04/2017 13:46:18.693] [main] [akka.remote.artery.ArteryTransport(akka://server)] Remoting started; listening on address: [akka://server@192.168.0.250:5001] with UID [-2663186266051514585]

But when i try to start client, i get the following error:

[ERROR] [07/04/2017 14:09:05.250] [client-akka.actor.default-dispatcher-10] [akka://server@192.168.0.250:5001/] swallowing exception during message send
io.aeron.exceptions.RegistrationException: Insufficient usable storage for new log of length=50332096 in /dev/shm (shm)
    at io.aeron.ClientConductor.onError(ClientConductor.java:285)
    at io.aeron.DriverListenerAdapter.onMessage(DriverListenerAdapter.java:79)
    at org.agrona.concurrent.broadcast.CopyBroadcastReceiver.receive(CopyBroadcastReceiver.java:100)
    at io.aeron.DriverListenerAdapter.pollMessage(DriverListenerAdapter.java:59)
    at io.aeron.ClientConductor.doWork(ClientConductor.java:422)
    at io.aeron.ClientConductor.awaitResponse(ClientConductor.java:447)
    at io.aeron.ClientConductor.addPublication(ClientConductor.java:177)
    at io.aeron.Aeron.addPublication(Aeron.java:165)
    at akka.remote.artery.AeronSink$$anon$1.<init>(AeronSink.scala:103)
    at akka.remote.artery.AeronSink.createLogicAndMaterializedValue(AeronSink.scala:100)
    at akka.stream.impl.GraphStageIsland.materializeAtomic(PhasedFusingActorMaterializer.scala:627)
    at akka.stream.impl.PhasedFusingActorMaterializer.materialize(PhasedFusingActorMaterializer.scala:458)
    at akka.stream.impl.PhasedFusingActorMaterializer.materialize(PhasedFusingActorMaterializer.scala:420)
    at akka.stream.impl.PhasedFusingActorMaterializer.materialize(PhasedFusingActorMaterializer.scala:415)
    at akka.stream.scaladsl.RunnableGraph.run(Flow.scala:439)
    at akka.remote.artery.Association.akka$remote$artery$Association$$runOutboundOrdinaryMessagesStream(Association.scala:570)
    at akka.remote.artery.Association.runOutboundStreams(Association.scala:510)
    at akka.remote.artery.Association.associate(Association.scala:502)
    at akka.remote.artery.AssociationRegistry.association(Association.scala:763)
    at akka.remote.artery.ArteryTransport.association(ArteryTransport.scala:932)
    at akka.remote.artery.ArteryTransport.send(ArteryTransport.scala:918)
    at akka.remote.RemoteActorRef.$bang(RemoteActorRefProvider.scala:563)
    at akka.actor.ActorRef.tell(ActorRef.scala:124)
    at akka.actor.ActorSelection$.rec$1(ActorSelection.scala:250)
    at akka.actor.ActorSelection$.deliverSelection(ActorSelection.scala:254)
    at akka.actor.ActorSelection.tell(ActorSelection.scala:45)
    at actors.ClientActor.<init>(ClientActor.java:21)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.lang.Class.newInstance(Class.java:442)
    at akka.util.Reflect$.instantiate(Reflect.scala:44)
    at akka.actor.NoArgsReflectConstructor.produce(IndirectActorProducer.scala:105)
    at akka.actor.Props.newActor(Props.scala:213)
    at akka.actor.ActorCell.newActor(ActorCell.scala:563)
    at akka.actor.ActorCell.create(ActorCell.scala:589)
    at akka.actor.ActorCell.invokeAll$1(ActorCell.scala:462)
    at akka.actor.ActorCell.systemInvoke(ActorCell.scala:484)
    at akka.dispatch.Mailbox.processAllSystemMessages(Mailbox.scala:282)
    at akka.dispatch.Mailbox.run(Mailbox.scala:223)
    at akka.dispatch.Mailbox.exec(Mailbox.scala:234)
    at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
    at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
    at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
    at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

I also try to send message with these "ActorSelection paths":

"akka://server@192.168.0.250:5001/user/server-process" "akka://server@localhost:5001/user/server-process" "akka://server@192.168.0.250:10001/user/server-process" "akka://server@localhost:10001/user/server-process"

but the error still appears.

It is important to clarify, also, that the actor path of the server actor is:

akka://server/user/server-process

What is missing? I'm using akka 2.5.3 version...

Thank's.


Solution

  • I am not quite sure how Akka canonical vs bind addressing works. But my guess is that the bind.hostname is the actual IP or resolved IP by the hostname that it will listen on. In this case, localhost translates to 127.0.0.1, which means the container will only accept connections on 127.0.0.1.

    Try setting the bind.hostname to 0.0.0.0. This will allow connections from IP addresses outside the container (from host through port 5001).