クライアント接続で別のサーバーへのさらなる(クライアント)接続を開始する必要がある akka i/o TCP サーバーがあります。
私が行きたかったアプローチは -> TCP アクター -> リッスン -> 接続が成功するたびに、新しいクライアントアクターを開始し、ピア間のすべての通信を渡します
TCP サーバーでのクライアントの処理は正常に機能します。しかし、2 番目のサーバーへの接続のために別のアクターを開始するたびに、接続をセットアップできますが、応答しません。最終的には、
case _: ConnectionClosed ⇒ context stop self;
オンラインには明確なドキュメントがあまりないため、理解するのに苦労しています。私のクライアントは、主にドキュメントのクライアントの例を表しています。
(listener パラメータはクライアント サーバー アクターです。)
class ClientTransProxyHandler(remote: InetSocketAddress, listener: ActorRef) extends Actor {
import Tcp._
import context.system
IO(Tcp) ! Connect(remote)
def receive = {
case CommandFailed(_: Connect) ⇒
listener ! "failed"
context stop self
case c @ Connected(remote, local) ⇒
val connection = sender
connection ! Register(self)
context become {
case data: ByteString ⇒
connection ! Write(data);
case CommandFailed(w: Write) ⇒ // O/S buffer was full
case Received(data) ⇒
listener ! data; println(data);
case "close" ⇒
connection ! Close;
case _: ConnectionClosed ⇒ context stop self;
}
}
}
なるルーチンに入ると、接続が開始されるようです。しかし、私がするとき、それは何も送信しません
client ! data // where data is what i got initially from the client
これがまったく送信されるかどうかさえわかりません。
ありがとう!
完全なソースはhttps://github.com/AlessandroEmm/SNIProxy/blob/master/src/main/scala/SNIProxy/SNIProxy.scalaにあります。