2

使用 Akka.net 我正在尝试实现简单的场景。我创建了 2 个服务器和 1 个客户端,其中服务器接收客户端发送的消息并对其进行处理。

安装程序有时工作正常,有时会出现以下错误,我无法找出原因:

**

No response from remote. Handshake timed out or transport failure detector triggered.
Cause: Unknown
Association with remote system akka.tcp://RemoteFSharp@172.27.**.94:8777 has
failed; address is now gated for 5000 ms. Reason is: [Akka.Remote.EndpointDisass
ociatedException: Disassociated
   at Akka.Remote.EndpointWriter.PublishAndThrow(Exception reason, LogLevel leve
l)
   at Akka.Remote.EndpointWriter.Unhandled(Object message)
   at Akka.Actor.ActorCell.<>c__DisplayClass109_0.<Akka.Actor.IUntypedActorConte
xt.Become>b__0(Object m)
   at Akka.Actor.ActorBase.AroundReceive(Receive receive, Object message)
   at Akka.Actor.ActorCell.ReceiveMessage(Object message)
   at Akka.Actor.ActorCell.AutoReceiveMessage(Envelope envelope)
   at Akka.Actor.ActorCell.Invoke(Envelope envelope)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Akka.Actor.ActorCell.HandleFailed(Failed f)
   at Akka.Actor.ActorCell.SystemInvoke(Envelope envelope)]

**

客户端配置:

akka {
       log-dead-letters-during-shutdown = off

        actor {
        handshake-timeout = 600 s

        serializers {
            wire = "Akka.Serialization.WireSerializer, Akka.Serialization.Wire"
          }
        serialization-bindings {
          "System.Object" = wire
        }
          provider = "Akka.Remote.RemoteActorRefProvider, Akka.Remote"
        }
        remote {
            helios.tcp {
                maximum-frame-size = 20000000b
                tcp-keepalive = on
                transport-class =
          "Akka.Remote.Transport.Helios.HeliosTcpTransport, Akka.Remote"
                transport-protocol = tcp
                port = 8760
                hostname = 172.27.**.94
                }
          }
        log-remote-lifecycle-events = INFO
      }

服务器配置:

      akka {
        log-dead-letters-during-shutdown = off
        actor {

        handshake-timeout = 600 s
        serializers {
            wire = "Akka.Serialization.WireSerializer, Akka.Serialization.Wire"
          }
        serialization-bindings {
          "System.Object" = wire
        }
          provider = "Akka.Remote.RemoteActorRefProvider, Akka.Remote"
        }
        remote {
        helios.tcp {
              maximum-frame-size = 20000000b
              tcp-keepalive = on
              transport-class =
        "Akka.Remote.Transport.Helios.HeliosTcpTransport, Akka.Remote"
              transport-protocol = tcp
              port = 8777
              hostname = 172.27.**.94
          }
          }
        log-remote-lifecycle-events = INFO
      }

我也使用 Newtonsoft.Json 进行序列化,如下所示:

let CreateEmployeeActor (system: ActorSystem) actorName  =
    (spawn system actorName
        (fun mailbox ->
            let rec loop (count: int)= 
                actor {
                    let! message = mailbox.Receive()
                    let sender = mailbox.Sender()
                    let deserializedEmailData = JsonConvert.DeserializeObject<EmployeeActorMsgs> (message)
                    match deserializedEmailData with
                    | InItEmployee ->
                //Some Logic

                }
            loop (0)
            ))
4

0 回答 0