简体   繁体   English

在docker实例上使用带有动脉的Akka远程处理时出错

[英]Error using akka remoting with artery over docker instances

First of all, sorry for my english. 首先,对不起我的英语。 Google translate helps me a lot, haha. Google翻译对我有很大帮助,哈哈。

My problem is this: 我的问题是这样的:

I have two example projects developed with akka and java : example-remote-client.jar and example-remote-server.jar 我有两个使用akkajava开发的示例项目:example-remote-client.jar和example-remote-server.jar

I'm using artery serialization, and and i'm trying to send messages from client to server via akka-remoting. 我正在使用动脉序列化,并且正在尝试通过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: 两个jar都部署在运行在同一“ 192.168.0.250计算机”上的docker实例上,如下所示:

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": 我也尝试使用以下“ ActorSelection路径”发送消息:

"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" “ akka://服务器@ 192.168.0.250:5001 /用户/服务器进程”“ akka://服务器@localhost:5001 /用户/服务器进程”“ akka://服务器@ 192.168.0.250:10001 /用户/ 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 akka://服务器/用户/服务器进程

What is missing? 什么东西少了? I'm using akka 2.5.3 version... 我正在使用akka 2.5.3版本...

Thank's. 谢谢。

I am not quite sure how Akka canonical vs bind addressing works. 我不太确定Akka规范与绑定寻址的工作方式。 But my guess is that the bind.hostname is the actual IP or resolved IP by the hostname that it will listen on. 但是我的猜测是bind.hostname是实际IP或将通过其侦听的主机名解析的IP。 In this case, localhost translates to 127.0.0.1 , which means the container will only accept connections on 127.0.0.1 . 在这种情况下, localhost转换为127.0.0.1 ,这意味着容器将仅接受127.0.0.1连接。

Try setting the bind.hostname to 0.0.0.0 . 尝试将bind.hostname设置为0.0.0.0 This will allow connections from IP addresses outside the container (from host through port 5001). 这将允许来自容器外部IP地址的连接(从主机通过端口5001)。

Try setting the size of your /dev/shm volume to be larger. 尝试将/dev/shm卷的大小设置为更大。 In a docker-compose file, you can simply add this option: shm_size: 500M . shm_size: 500M -compose文件中,您可以简单地添加以下选项: shm_size: 500M This volume is a shared memory space that aeron uses to buffer messages. 该卷是aeron用来缓冲消息的共享内存空间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM