Hi, I wirte a Long connection client, it's sample code as:
 public void startClient() throws Exception {
  NioSocketConnector socketConnector = new NioSocketConnector();
  socketConnector.setHandler(.......);
  .........................................................................
  ConnectFuture future = socketConnector.connect(new InetSocketAddress(ip ,
port));
  future.awaitUninterruptibly();
 }

 I implement IoHandler interface,  in sessionClosed method, I try to
reconnect the server side,  it works, but still print "reconnect"
 characters,
Can someone tell me if there is an error in my code?
@Override
 public void sessionClosed(IoSession session) throws Exception {
  while ((session.getService() instanceof IoConnector) &&
  !
((IoConnector)session.getService()).connect(session.getRemoteAddress()).isConnected())
{
  Thread.sleep( 5000 );
  log.warn("============reconnect===============");
  }
 }
Thank you very much in advance
Best regards

Reply via email to