You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Niklas Therning <ni...@trillian.se> on 2007/01/25 09:32:34 UTC

Re: Mina client application problem(mina 1.01)

Stanley Ding wrote:
> Hi all,
>  
> I'm developing a client which only send a "SHUT_DOWN" message to the
> server. But it does not work now....
>  
> Here is the code:
>  
>   SocketConnector connector = new SocketConnector();
>   SocketConnectorConfig cfg = new SocketConnectorConfig(); 
>   cfg.getFilterChain().addLast(
>                 "codec",
>                 new ProtocolCodecFilter( new
> AuthProtocolCodecFactory(key)) );
>   cfg.getFilterChain().addLast("logger", new LoggingFilter());
>   
>   ConnectFuture cf = connector.connect(new
> InetSocketAddress("127.0.0.1", port), new IoHandlerAdapter(), cfg);
>   cf.join();
>   
>   if(cf.isConnected())
>   {
>    cf.getSession().write("SHUT_DOWN");
>    cf.getSession().getCloseFuture().join();
>    cf.getSession().close();
>   } 
>  
> Could you please tell me what the problem is?
What happens exactly? Do you get an exception or does the message never
reach the server? If the latter is the case I think the problem could be
that the client session is closed before the write has finished. Please
try the following change:

  if(cf.isConnected())
  {
   cf.getSession().write("SHUT_DOWN").join();
   cf.getSession().close().join();
  }

If the problem remains, please give us some more info (preferably more
of the code and/or logs).

HTH

-- 
Niklas Therning
www.spamdrain.net