Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试在 netty 中编写一个包含 n 列表的处理程序SocketAddress。我想要发生的是从第一个地址开始并尝试连接。如果失败,请尝试下一个地址,依此类推。
SocketAddress
如果连接因任何原因断开,那么我希望无限期地重试连接,在地址列表中循环。
有没有人对如何写这篇文章有任何建议。我找到了有关执行单个地址重新连接处理程序的 netty 示例,但不确定多个情况。
我认为您可以使用连接部分的 ChannelFutureListener 轻松完成此操作。对于连接断开,您可以编写自定义 SimpleUpstreamChannelHandler 并覆盖 connectionClosed(..) 方法来处理“重新连接”。