Socket being automatically closed on SimpleChannelUpstreamHandler

araujoao daraujoao at gmail.com
Mon Jun 6 22:25:42 EDT 2011


Hello,

   I have a Client app, which receives messages from a server. 
   It connects to the server and keeps on receiving messages from the
server. 

   I cant find the reason why from time to time the client closes
automatically the socket, forcing the app to reopen it.
 
   Here is the bootstrap start, with some omissions to easy the reading task

           // Set up the pipeline factory.
        bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
            @Override
            public ChannelPipeline getPipeline() throws Exception {
                return Channels.pipeline(
                        new DelimiterBasedFrameDecoder(8192, false,
delimiters),
                        new ReaderHandler(bootstrap, docQueue, timer));

            }
        });
          

        bootstrap.setOption(
                  "remoteAddress", new InetSocketAddress(host, port));
        bootstrap.setOption("child.keepAlive", true);

   here is the handler 
    
public ReaderHandler(ClientBootstrap bootstrap, BlockingQueue<Message>
docQueue, Timer timer) {
        this.docQueue = docQueue;
        this.bootstrap = bootstrap;
        this.timer = timer;
    }

  
   
    @Override
    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
throws InterruptedException {
        ChannelBuffer chb = (ChannelBuffer) e.getMessage();

        //  println(chb.toString(Charset.defaultCharset()));
        if (chb == null && !chb.readable())
            return;
        process(chb.toString(Charset.defaultCharset()));

   } 


  It does not have anything special.But from time to time the channel is
closed. I tried
on different machines, and also on the same machine to see if it has to do
with a firewall, or something without success. 


  The only special thing about it is that it does not write on the channel.
It simply reads from it. 




   Does anybody has a clue why the socket 's been closed? 


   THanks, 
John, 

--
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/Socket-being-automatically-closed-on-SimpleChannelUpstreamHandler-tp6447781p6447781.html
Sent from the Netty User Group mailing list archive at Nabble.com.


More information about the netty-users mailing list