<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0">
	<id>tag:n2.nabble.com,2006:forum-685700</id>
	<title>Nabble - Netty User Group</title>
	<updated>2009-11-24T09:02:32Z</updated>
	<link rel="self" type="application/atom+xml" href="http://n2.nabble.com/Netty-User-Group-f685700.xml" />
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/Netty-User-Group-f685700.html" />
	<subtitle type="html">End user questions and answers are posted here.</subtitle>
	
<entry>
	<id>tag:n2.nabble.com,2006:post-4059156</id>
	<title>Re: How to implement Streaming server like The Bayeux Protocol</title>
	<published>2009-11-24T09:02:32Z</published>
	<updated>2009-11-24T09:02:32Z</updated>
	<author>
		<name>sumitatgharkikhoj</name>
	</author>
	<content type="html">Sorry i was not been clear.
&lt;br&gt;&lt;br&gt;That is what i want to do.
&lt;br&gt;&lt;br&gt;I am using xmlhttprequst.multipart to do the streaming, so once a client connects to get the data
&lt;br&gt;whole day the connection is kept live ( the chunkwriter never returns).
&lt;br&gt;&lt;br&gt;An this is working fine for two users but as soon as there is a third user that connects he gets blocked.
&lt;br&gt;Since i have set cached thread pool for boss and worker threads should i think it should work fine for n no of users until we run out of os threads or EXecutor cannot create any more thread???
&lt;br&gt;NioServerSocketChannelFactory(Executors.newCachedThreadPool(),Executors.newCachedThreadPool()));
&lt;br&gt;&lt;br&gt;I also know for this mode of operation netty will fallback to one to one thread per client-server connection but i need netty to do it as i am using netty for other purpose already and i cannot mix any other libary ( jetty/mina).
&lt;br&gt;&lt;br&gt;&lt;blockquote class=&quot;quote light-black dark-border-color&quot;&gt;&lt;div class=&quot;quote light-border-color&quot;&gt;
&lt;div class=&quot;quote-author&quot; style=&quot;font-weight: bold;&quot;&gt;Trustin Lee wrote:&lt;/div&gt;
&lt;div class=&quot;quote-message shrinkable-quote&quot;&gt;Your ChunkedInput implementation never terminates since hasNextChunk()
&lt;br&gt;always return true. &amp;nbsp;Refer to the source code of the existing
&lt;br&gt;ChunkedInput implementations to figure out how to implement it
&lt;br&gt;correctly.
&lt;br&gt;&lt;br&gt;— Trustin Lee, &lt;a href=&quot;http://gleamynode.net/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://gleamynode.net/&lt;/a&gt;&lt;br&gt;&lt;br&gt;On Tue, Nov 24, 2009 at 11:51 PM, sumitatgharkikhoj
&lt;br&gt;&amp;lt;mailtosumitsingh@gmail.com&amp;gt; wrote:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; chunked writer is same as above mentioned.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; sumitatgharkikhoj wrote:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Hi Trustin, i replaced the line in the static file server example:
&lt;br&gt;&amp;gt;&amp;gt;  //ChannelFuture writeFuture = ch.write(new ChunkedFile(raf, 0,
&lt;br&gt;&amp;gt;&amp;gt; fileLength, 8192));
&lt;br&gt;&amp;gt;&amp;gt; with line :
&lt;br&gt;&amp;gt;&amp;gt;         ChannelFuture writeFuture = e.getChannel().write(new
&lt;br&gt;&amp;gt;&amp;gt; ChunkedInput() {
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; my server still getting blocked after two requests all other requests get
&lt;br&gt;&amp;gt;&amp;gt; piled up.
&lt;br&gt;&amp;gt;&amp;gt; What i did:
&lt;br&gt;&amp;gt;&amp;gt; 1) Took the example httpstatic file server
&lt;br&gt;&amp;gt;&amp;gt; 2) Instead of using chunked file use my own chunked input
&lt;br&gt;&amp;gt;&amp;gt; 3) Opened three different browsers: firefox, chrmoe,ie  ( to make sure the
&lt;br&gt;&amp;gt;&amp;gt; test does not gets affected by browser)
&lt;br&gt;&amp;gt;&amp;gt; 4) First two requests succeed and data starts streaming to both firefox
&lt;br&gt;&amp;gt;&amp;gt; and chrome but ie request does not event reach my handler.
&lt;br&gt;&amp;gt;&amp;gt; 5) When i escape or close one of the browser the third request goes
&lt;br&gt;&amp;gt;&amp;gt; through and my static file server handler gets the response.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; I still get the same results the server gets blocked.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Trustin Lee wrote:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; On Tue, Nov 24, 2009 at 1:02 PM, sumitatgharkikhoj
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;lt;mailtosumitsingh@gmail.com&amp;gt; wrote:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; First of all thank you for the nice framework, forum and documentation.
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; My problem is i am trying to write a http server with small footprint (
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; will
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; go as a component in bigger framework) but it needs to have streaming
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; support .
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; Different clients will connect at different times ranging from 100-1000
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; clients max and this server will be used for both streaming and short
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; data.
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; the data is streamed using XHR multipart request and continously (24/7)
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; .
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; But when i used the example code (please see below) the server blocks
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; after
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; first thread.
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; In your handler, you check if the returned future.isSuccess() is true
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; or false right after calling write().  It will be almost always false
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; because the write operation is asynchronous.  You are using
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; ChunkedInput, so I'd recommend you take a look into the
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; HttpStaticFileServerHandler.
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; Other option that i tried was jetty with continuation or cometd but i am
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; more inclined about netty (since i want to replace my mina udp layer
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; with
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; mina and maintain one single library ).
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; Any help will be appreciated, I have my machine available via webex to
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; debug
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; as well.
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; my server gets block at second request in the following code :
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; 1) in my http server:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;           ServerBootstrap bootstrap = new ServerBootstrap(new
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; NioServerSocketChannelFactory(Executors.newCachedThreadPool(),Executors.newCachedThreadPool()));
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;           bootstrap.setPipelineFactory(new
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; HttpServerPipelineFactory(requestHandler));
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;          bootstrap.bind(new InetSocketAddress(8080));
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; 2) in my pipelinefactory:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;    public ChannelPipeline getPipeline() throws Exception {
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;        ChannelPipeline pipeline = pipeline();
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;        pipeline.addLast(&amp;quot;decoder&amp;quot;, new HttpRequestDecoder());
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;        pipeline.addLast(&amp;quot;encoder&amp;quot;, new HttpResponseEncoder());
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;        pipeline.addLast(&amp;quot;chunkedWriter&amp;quot;, new ChunkedWriteHandler());
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;        pipeline.addLast(&amp;quot;handler&amp;quot;, requestHandler);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;        return pipeline;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; 3)my http request handler sends event using following code
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;        private void writeResponse(MessageEvent e) {
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                ChannelBuffer buf =
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; ChannelBuffers.copiedBuffer(responseContent.toString(), &amp;quot;UTF-8&amp;quot;);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                buf.setBytes(0, responseContent.toString().getBytes() );
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                responseContent.setLength(0);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                boolean close =
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;  HttpHeaders.Values.CLOSE.equalsIgnoreCase(request
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                .getHeader(HttpHeaders.Names.CONNECTION))
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                ||
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; request.getProtocolVersion().equals(HttpVersion.HTTP_1_0)
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                &amp;&amp;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; !HttpHeaders.Values.KEEP_ALIVE.equalsIgnoreCase(request
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;  .getHeader(HttpHeaders.Names.CONNECTION));
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                HttpResponse response = new
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; DefaultHttpResponse(HttpVersion.HTTP_1_1,
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; HttpResponseStatus.OK);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                //response.setContent(buf);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                //response.setHeader(HttpHeaders.Names.CONTENT_TYPE,
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; &amp;quot;text/html;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; charset=UTF-8&amp;quot;);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                response.setHeader(HttpHeaders.Names.CONTENT_TYPE,
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; &amp;quot;multipart/x-mixed-replace;boundary=XXoXoX&amp;quot;);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                //if (!close)
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                {
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        response.setHeader(&amp;quot;Connection&amp;quot;, &amp;quot;Keep-Alive&amp;quot;);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        response.setHeader(&amp;quot;Cache-Control&amp;quot;, &amp;quot;no-cache&amp;quot;);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        response.setHeader(&amp;quot;Access-Control-Allow-Origin&amp;quot;,
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; &amp;quot;*&amp;quot;);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                }
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                String cookieString =
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; request.getHeader(HttpHeaders.Names.COOKIE);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                if (cookieString != null) {
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        CookieDecoder cookieDecoder = new
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; CookieDecoder();
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        Set&amp;lt;Cookie&amp;gt; cookies =
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; cookieDecoder.decode(cookieString);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        if (!cookies.isEmpty()) {
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                CookieEncoder cookieEncoder = new
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; CookieEncoder(true);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                for (Cookie cookie : cookies) {
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                        cookieEncoder.addCookie(cookie);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                }
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;  response.addHeader(HttpHeaders.Names.SET_COOKIE,
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; cookieEncoder.encode());
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        }
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                }
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                ChannelFuture future =null;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                future = e.getChannel().write(response);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                String temp =&amp;quot;&amp;quot;;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                if(future.isSuccess()==false)
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        return;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                e.getChannel().write(new ChunkedInput() {
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        int i = 0;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        public Object nextChunk() throws Exception {
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                i++;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                String temp =&amp;quot;&amp;quot;;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                //temp =&amp;quot;--XXoXoX\r\n&amp;quot;;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                temp = &amp;quot;Content-Type: text/plain
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; \r\n\r\n&amp;quot;;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                temp += &amp;quot;{\&amp;quot;data\&amp;quot;:\&amp;quot;&amp;quot;+i+&amp;quot;\&amp;quot;}&amp;quot;;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                temp +=&amp;quot;\r\n--XXoXoX\r\n&amp;quot;;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                ChannelBuffer buf2 =
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; ChannelBuffers.copiedBuffer(temp.toString(),
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; &amp;quot;UTF-8&amp;quot;);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                Thread.sleep(100);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                return buf2;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        }
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        @Override
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        public boolean hasNextChunk() throws Exception {
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                        return true;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        }
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        @Override
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        public void close() throws Exception {
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                // TODO Auto-generated method stub
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        }
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                });
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;        if(close){
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                future.addListener(ChannelFutureListener.CLOSE);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;        }
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;        }
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; --
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; View this message in context:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; &lt;a href=&quot;http://n2.nabble.com/How-to-implement-Streaming-server-like-The-Bayeux-Protocol-tp4055722p4055722.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://n2.nabble.com/How-to-implement-Streaming-server-like-The-Bayeux-Protocol-tp4055722p4055722.html&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; Sent from the Netty User Group mailing list archive at Nabble.com.
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; netty-users mailing list
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; netty-users@lists.jboss.org
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; &lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; — Trustin Lee, &lt;a href=&quot;http://gleamynode.net/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://gleamynode.net/&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; netty-users mailing list
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; netty-users@lists.jboss.org
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; View this message in context: &lt;a href=&quot;http://n2.nabble.com/How-to-implement-Streaming-server-like-The-Bayeux-Protocol-tp4055722p4058231.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://n2.nabble.com/How-to-implement-Streaming-server-like-The-Bayeux-Protocol-tp4055722p4058231.html&lt;/a&gt;&lt;br&gt;&amp;gt; Sent from the Netty User Group mailing list archive at Nabble.com.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; netty-users mailing list
&lt;br&gt;&amp;gt; netty-users@lists.jboss.org
&lt;br&gt;&amp;gt; &lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;netty-users mailing list
&lt;br&gt;netty-users@lists.jboss.org
&lt;br&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;&lt;/blockquote&gt;
</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/How-to-implement-Streaming-server-like-The-Bayeux-Protocol-tp4055722p4059156.html" />
	<thr:in-reply-to ref="tag:n2.nabble.com,2006:post-4058891"/>
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4058891</id>
	<title>Re: How to implement Streaming server like The Bayeux Protocol</title>
	<published>2009-11-24T08:21:13Z</published>
	<updated>2009-11-24T08:21:13Z</updated>
	<author>
		<name>Trustin Lee</name>
	</author>
	<content type="html">Your ChunkedInput implementation never terminates since hasNextChunk()
&lt;br&gt;always return true. &amp;nbsp;Refer to the source code of the existing
&lt;br&gt;ChunkedInput implementations to figure out how to implement it
&lt;br&gt;correctly.
&lt;br&gt;&lt;br&gt;— Trustin Lee, &lt;a href=&quot;http://gleamynode.net/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://gleamynode.net/&lt;/a&gt;&lt;br&gt;&lt;br&gt;On Tue, Nov 24, 2009 at 11:51 PM, sumitatgharkikhoj
&lt;br&gt;&amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4058891&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; chunked writer is same as above mentioned.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; sumitatgharkikhoj wrote:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Hi Trustin, i replaced the line in the static file server example:
&lt;br&gt;&amp;gt;&amp;gt;  //ChannelFuture writeFuture = ch.write(new ChunkedFile(raf, 0,
&lt;br&gt;&amp;gt;&amp;gt; fileLength, 8192));
&lt;br&gt;&amp;gt;&amp;gt; with line :
&lt;br&gt;&amp;gt;&amp;gt;         ChannelFuture writeFuture = e.getChannel().write(new
&lt;br&gt;&amp;gt;&amp;gt; ChunkedInput() {
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; my server still getting blocked after two requests all other requests get
&lt;br&gt;&amp;gt;&amp;gt; piled up.
&lt;br&gt;&amp;gt;&amp;gt; What i did:
&lt;br&gt;&amp;gt;&amp;gt; 1) Took the example httpstatic file server
&lt;br&gt;&amp;gt;&amp;gt; 2) Instead of using chunked file use my own chunked input
&lt;br&gt;&amp;gt;&amp;gt; 3) Opened three different browsers: firefox, chrmoe,ie  ( to make sure the
&lt;br&gt;&amp;gt;&amp;gt; test does not gets affected by browser)
&lt;br&gt;&amp;gt;&amp;gt; 4) First two requests succeed and data starts streaming to both firefox
&lt;br&gt;&amp;gt;&amp;gt; and chrome but ie request does not event reach my handler.
&lt;br&gt;&amp;gt;&amp;gt; 5) When i escape or close one of the browser the third request goes
&lt;br&gt;&amp;gt;&amp;gt; through and my static file server handler gets the response.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; I still get the same results the server gets blocked.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Trustin Lee wrote:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; On Tue, Nov 24, 2009 at 1:02 PM, sumitatgharkikhoj
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4058891&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; First of all thank you for the nice framework, forum and documentation.
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; My problem is i am trying to write a http server with small footprint (
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; will
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; go as a component in bigger framework) but it needs to have streaming
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; support .
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; Different clients will connect at different times ranging from 100-1000
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; clients max and this server will be used for both streaming and short
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; data.
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; the data is streamed using XHR multipart request and continously (24/7)
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; .
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; But when i used the example code (please see below) the server blocks
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; after
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; first thread.
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; In your handler, you check if the returned future.isSuccess() is true
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; or false right after calling write().  It will be almost always false
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; because the write operation is asynchronous.  You are using
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; ChunkedInput, so I'd recommend you take a look into the
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; HttpStaticFileServerHandler.
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; Other option that i tried was jetty with continuation or cometd but i am
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; more inclined about netty (since i want to replace my mina udp layer
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; with
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; mina and maintain one single library ).
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; Any help will be appreciated, I have my machine available via webex to
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; debug
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; as well.
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; my server gets block at second request in the following code :
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; 1) in my http server:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;           ServerBootstrap bootstrap = new ServerBootstrap(new
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; NioServerSocketChannelFactory(Executors.newCachedThreadPool(),Executors.newCachedThreadPool()));
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;           bootstrap.setPipelineFactory(new
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; HttpServerPipelineFactory(requestHandler));
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;          bootstrap.bind(new InetSocketAddress(8080));
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; 2) in my pipelinefactory:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;    public ChannelPipeline getPipeline() throws Exception {
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;        ChannelPipeline pipeline = pipeline();
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;        pipeline.addLast(&amp;quot;decoder&amp;quot;, new HttpRequestDecoder());
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;        pipeline.addLast(&amp;quot;encoder&amp;quot;, new HttpResponseEncoder());
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;        pipeline.addLast(&amp;quot;chunkedWriter&amp;quot;, new ChunkedWriteHandler());
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;        pipeline.addLast(&amp;quot;handler&amp;quot;, requestHandler);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;        return pipeline;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; 3)my http request handler sends event using following code
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;        private void writeResponse(MessageEvent e) {
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                ChannelBuffer buf =
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; ChannelBuffers.copiedBuffer(responseContent.toString(), &amp;quot;UTF-8&amp;quot;);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                buf.setBytes(0, responseContent.toString().getBytes() );
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                responseContent.setLength(0);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                boolean close =
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;  HttpHeaders.Values.CLOSE.equalsIgnoreCase(request
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                .getHeader(HttpHeaders.Names.CONNECTION))
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                ||
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; request.getProtocolVersion().equals(HttpVersion.HTTP_1_0)
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                &amp;&amp;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; !HttpHeaders.Values.KEEP_ALIVE.equalsIgnoreCase(request
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;  .getHeader(HttpHeaders.Names.CONNECTION));
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                HttpResponse response = new
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; DefaultHttpResponse(HttpVersion.HTTP_1_1,
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; HttpResponseStatus.OK);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                //response.setContent(buf);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                //response.setHeader(HttpHeaders.Names.CONTENT_TYPE,
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; &amp;quot;text/html;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; charset=UTF-8&amp;quot;);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                response.setHeader(HttpHeaders.Names.CONTENT_TYPE,
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; &amp;quot;multipart/x-mixed-replace;boundary=XXoXoX&amp;quot;);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                //if (!close)
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                {
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        response.setHeader(&amp;quot;Connection&amp;quot;, &amp;quot;Keep-Alive&amp;quot;);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        response.setHeader(&amp;quot;Cache-Control&amp;quot;, &amp;quot;no-cache&amp;quot;);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        response.setHeader(&amp;quot;Access-Control-Allow-Origin&amp;quot;,
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; &amp;quot;*&amp;quot;);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                }
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                String cookieString =
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; request.getHeader(HttpHeaders.Names.COOKIE);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                if (cookieString != null) {
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        CookieDecoder cookieDecoder = new
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; CookieDecoder();
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        Set&amp;lt;Cookie&amp;gt; cookies =
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; cookieDecoder.decode(cookieString);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        if (!cookies.isEmpty()) {
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                CookieEncoder cookieEncoder = new
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; CookieEncoder(true);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                for (Cookie cookie : cookies) {
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                        cookieEncoder.addCookie(cookie);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                }
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;  response.addHeader(HttpHeaders.Names.SET_COOKIE,
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; cookieEncoder.encode());
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        }
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                }
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                ChannelFuture future =null;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                future = e.getChannel().write(response);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                String temp =&amp;quot;&amp;quot;;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                if(future.isSuccess()==false)
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        return;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                e.getChannel().write(new ChunkedInput() {
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        int i = 0;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        public Object nextChunk() throws Exception {
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                i++;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                String temp =&amp;quot;&amp;quot;;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                //temp =&amp;quot;--XXoXoX\r\n&amp;quot;;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                temp = &amp;quot;Content-Type: text/plain
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; \r\n\r\n&amp;quot;;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                temp += &amp;quot;{\&amp;quot;data\&amp;quot;:\&amp;quot;&amp;quot;+i+&amp;quot;\&amp;quot;}&amp;quot;;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                temp +=&amp;quot;\r\n--XXoXoX\r\n&amp;quot;;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                ChannelBuffer buf2 =
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; ChannelBuffers.copiedBuffer(temp.toString(),
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; &amp;quot;UTF-8&amp;quot;);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                Thread.sleep(100);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                return buf2;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        }
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        @Override
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        public boolean hasNextChunk() throws Exception {
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                        return true;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        }
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        @Override
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        public void close() throws Exception {
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                                // TODO Auto-generated method stub
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                        }
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                });
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;        if(close){
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;                future.addListener(ChannelFutureListener.CLOSE);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;        }
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;        }
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; --
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; View this message in context:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; &lt;a href=&quot;http://n2.nabble.com/How-to-implement-Streaming-server-like-The-Bayeux-Protocol-tp4055722p4055722.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://n2.nabble.com/How-to-implement-Streaming-server-like-The-Bayeux-Protocol-tp4055722p4055722.html&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; Sent from the Netty User Group mailing list archive at Nabble.com.
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; netty-users mailing list
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; &lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4058891&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; &lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; — Trustin Lee, &lt;a href=&quot;http://gleamynode.net/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://gleamynode.net/&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; netty-users mailing list
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4058891&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; View this message in context: &lt;a href=&quot;http://n2.nabble.com/How-to-implement-Streaming-server-like-The-Bayeux-Protocol-tp4055722p4058231.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://n2.nabble.com/How-to-implement-Streaming-server-like-The-Bayeux-Protocol-tp4055722p4058231.html&lt;/a&gt;&lt;br&gt;&amp;gt; Sent from the Netty User Group mailing list archive at Nabble.com.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; netty-users mailing list
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4058891&amp;i=4&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&amp;gt; &lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;netty-users mailing list
&lt;br&gt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4058891&amp;i=5&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&lt;div class=&quot;signature&quot;&gt;— Trustin Lee, &lt;a href=&quot;http://gleamynode.net/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://gleamynode.net/&lt;/a&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/How-to-implement-Streaming-server-like-The-Bayeux-Protocol-tp4055722p4058891.html" />
	<thr:in-reply-to ref="tag:n2.nabble.com,2006:post-4058231"/>
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4058231</id>
	<title>Re: How to implement Streaming server like The Bayeux Protocol</title>
	<published>2009-11-24T06:51:09Z</published>
	<updated>2009-11-24T06:51:09Z</updated>
	<author>
		<name>sumitatgharkikhoj</name>
	</author>
	<content type="html">chunked writer is same as above mentioned.
&lt;br&gt;&lt;br&gt;&lt;blockquote class=&quot;quote light-black dark-border-color&quot;&gt;&lt;div class=&quot;quote light-border-color&quot;&gt;
&lt;div class=&quot;quote-author&quot; style=&quot;font-weight: bold;&quot;&gt;sumitatgharkikhoj wrote:&lt;/div&gt;
&lt;div class=&quot;quote-message shrinkable-quote&quot;&gt;Hi Trustin, i replaced the line in the static file server example:
&lt;br&gt;&amp;nbsp;//ChannelFuture writeFuture = ch.write(new ChunkedFile(raf, 0, fileLength, 8192));
&lt;br&gt;with line :
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ChannelFuture writeFuture = e.getChannel().write(new ChunkedInput() {
&lt;br&gt;&lt;br&gt;my server still getting blocked after two requests all other requests get piled up.
&lt;br&gt;What i did:
&lt;br&gt;1) Took the example httpstatic file server
&lt;br&gt;2) Instead of using chunked file use my own chunked input
&lt;br&gt;3) Opened three different browsers: firefox, chrmoe,ie &amp;nbsp;( to make sure the test does not gets affected by browser)
&lt;br&gt;4) First two requests succeed and data starts streaming to both firefox and chrome but ie request does not event reach my handler.
&lt;br&gt;5) When i escape or close one of the browser the third request goes through and my static file server handler gets the response.
&lt;br&gt;&lt;br&gt;I still get the same results the server gets blocked.
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;blockquote class=&quot;quote light-black dark-border-color&quot;&gt;&lt;div class=&quot;quote light-border-color&quot;&gt;
&lt;div class=&quot;quote-author&quot; style=&quot;font-weight: bold;&quot;&gt;Trustin Lee wrote:&lt;/div&gt;
&lt;div class=&quot;quote-message shrinkable-quote&quot;&gt;On Tue, Nov 24, 2009 at 1:02 PM, sumitatgharkikhoj
&lt;br&gt;&amp;lt;mailtosumitsingh@gmail.com&amp;gt; wrote:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; First of all thank you for the nice framework, forum and documentation.
&lt;br&gt;&amp;gt; My problem is i am trying to write a http server with small footprint ( will
&lt;br&gt;&amp;gt; go as a component in bigger framework) but it needs to have streaming
&lt;br&gt;&amp;gt; support .
&lt;br&gt;&amp;gt; Different clients will connect at different times ranging from 100-1000
&lt;br&gt;&amp;gt; clients max and this server will be used for both streaming and short data.
&lt;br&gt;&amp;gt; the data is streamed using XHR multipart request and continously (24/7) .
&lt;br&gt;&amp;gt; But when i used the example code (please see below) the server blocks after
&lt;br&gt;&amp;gt; first thread.
&lt;br&gt;&lt;br&gt;In your handler, you check if the returned future.isSuccess() is true
&lt;br&gt;or false right after calling write(). &amp;nbsp;It will be almost always false
&lt;br&gt;because the write operation is asynchronous. &amp;nbsp;You are using
&lt;br&gt;ChunkedInput, so I'd recommend you take a look into the
&lt;br&gt;HttpStaticFileServerHandler.
&lt;br&gt;&lt;br&gt;&amp;gt; Other option that i tried was jetty with continuation or cometd but i am
&lt;br&gt;&amp;gt; more inclined about netty (since i want to replace my mina udp layer with
&lt;br&gt;&amp;gt; mina and maintain one single library ).
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Any help will be appreciated, I have my machine available via webex to debug
&lt;br&gt;&amp;gt; as well.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; my server gets block at second request in the following code :
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; 1) in my http server:
&lt;br&gt;&amp;gt;           ServerBootstrap bootstrap = new ServerBootstrap(new
&lt;br&gt;&amp;gt; NioServerSocketChannelFactory(Executors.newCachedThreadPool(),Executors.newCachedThreadPool()));
&lt;br&gt;&amp;gt;           bootstrap.setPipelineFactory(new
&lt;br&gt;&amp;gt; HttpServerPipelineFactory(requestHandler));
&lt;br&gt;&amp;gt;          bootstrap.bind(new InetSocketAddress(8080));
&lt;br&gt;&amp;gt; 2) in my pipelinefactory:
&lt;br&gt;&amp;gt;    public ChannelPipeline getPipeline() throws Exception {
&lt;br&gt;&amp;gt;        ChannelPipeline pipeline = pipeline();
&lt;br&gt;&amp;gt;        pipeline.addLast(&amp;quot;decoder&amp;quot;, new HttpRequestDecoder());
&lt;br&gt;&amp;gt;        pipeline.addLast(&amp;quot;encoder&amp;quot;, new HttpResponseEncoder());
&lt;br&gt;&amp;gt;        pipeline.addLast(&amp;quot;chunkedWriter&amp;quot;, new ChunkedWriteHandler());
&lt;br&gt;&amp;gt;        pipeline.addLast(&amp;quot;handler&amp;quot;, requestHandler);
&lt;br&gt;&amp;gt;        return pipeline;
&lt;br&gt;&amp;gt; 3)my http request handler sends event using following code
&lt;br&gt;&amp;gt;        private void writeResponse(MessageEvent e) {
&lt;br&gt;&amp;gt;                ChannelBuffer buf =
&lt;br&gt;&amp;gt; ChannelBuffers.copiedBuffer(responseContent.toString(), &amp;quot;UTF-8&amp;quot;);
&lt;br&gt;&amp;gt;                buf.setBytes(0, responseContent.toString().getBytes() );
&lt;br&gt;&amp;gt;                responseContent.setLength(0);
&lt;br&gt;&amp;gt;                boolean close =  HttpHeaders.Values.CLOSE.equalsIgnoreCase(request
&lt;br&gt;&amp;gt;                                .getHeader(HttpHeaders.Names.CONNECTION))
&lt;br&gt;&amp;gt;                                || request.getProtocolVersion().equals(HttpVersion.HTTP_1_0)
&lt;br&gt;&amp;gt;                                &amp;&amp; !HttpHeaders.Values.KEEP_ALIVE.equalsIgnoreCase(request
&lt;br&gt;&amp;gt;                                                .getHeader(HttpHeaders.Names.CONNECTION));
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;                HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1,
&lt;br&gt;&amp;gt; HttpResponseStatus.OK);
&lt;br&gt;&amp;gt;                //response.setContent(buf);
&lt;br&gt;&amp;gt;                //response.setHeader(HttpHeaders.Names.CONTENT_TYPE, &amp;quot;text/html;
&lt;br&gt;&amp;gt; charset=UTF-8&amp;quot;);
&lt;br&gt;&amp;gt;                response.setHeader(HttpHeaders.Names.CONTENT_TYPE,
&lt;br&gt;&amp;gt; &amp;quot;multipart/x-mixed-replace;boundary=XXoXoX&amp;quot;);
&lt;br&gt;&amp;gt;                //if (!close)
&lt;br&gt;&amp;gt;                {
&lt;br&gt;&amp;gt;                        response.setHeader(&amp;quot;Connection&amp;quot;, &amp;quot;Keep-Alive&amp;quot;);
&lt;br&gt;&amp;gt;                        response.setHeader(&amp;quot;Cache-Control&amp;quot;, &amp;quot;no-cache&amp;quot;);
&lt;br&gt;&amp;gt;                        response.setHeader(&amp;quot;Access-Control-Allow-Origin&amp;quot;, &amp;quot;*&amp;quot;);
&lt;br&gt;&amp;gt;                }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;                String cookieString = request.getHeader(HttpHeaders.Names.COOKIE);
&lt;br&gt;&amp;gt;                if (cookieString != null) {
&lt;br&gt;&amp;gt;                        CookieDecoder cookieDecoder = new CookieDecoder();
&lt;br&gt;&amp;gt;                        Set&amp;lt;Cookie&amp;gt; cookies = cookieDecoder.decode(cookieString);
&lt;br&gt;&amp;gt;                        if (!cookies.isEmpty()) {
&lt;br&gt;&amp;gt;                                CookieEncoder cookieEncoder = new CookieEncoder(true);
&lt;br&gt;&amp;gt;                                for (Cookie cookie : cookies) {
&lt;br&gt;&amp;gt;                                        cookieEncoder.addCookie(cookie);
&lt;br&gt;&amp;gt;                                }
&lt;br&gt;&amp;gt;                                response.addHeader(HttpHeaders.Names.SET_COOKIE,
&lt;br&gt;&amp;gt; cookieEncoder.encode());
&lt;br&gt;&amp;gt;                        }
&lt;br&gt;&amp;gt;                }
&lt;br&gt;&amp;gt;                ChannelFuture future =null;
&lt;br&gt;&amp;gt;                future = e.getChannel().write(response);
&lt;br&gt;&amp;gt;                String temp =&amp;quot;&amp;quot;;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;                if(future.isSuccess()==false)
&lt;br&gt;&amp;gt;                        return;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;                e.getChannel().write(new ChunkedInput() {
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;                        int i = 0;
&lt;br&gt;&amp;gt;                        public Object nextChunk() throws Exception {
&lt;br&gt;&amp;gt;                                i++;
&lt;br&gt;&amp;gt;                                String temp =&amp;quot;&amp;quot;;
&lt;br&gt;&amp;gt;                                //temp =&amp;quot;--XXoXoX\r\n&amp;quot;;
&lt;br&gt;&amp;gt;                                temp = &amp;quot;Content-Type: text/plain \r\n\r\n&amp;quot;;
&lt;br&gt;&amp;gt;                                temp += &amp;quot;{\&amp;quot;data\&amp;quot;:\&amp;quot;&amp;quot;+i+&amp;quot;\&amp;quot;}&amp;quot;;
&lt;br&gt;&amp;gt;                                temp +=&amp;quot;\r\n--XXoXoX\r\n&amp;quot;;
&lt;br&gt;&amp;gt;                                ChannelBuffer buf2 = ChannelBuffers.copiedBuffer(temp.toString(),
&lt;br&gt;&amp;gt; &amp;quot;UTF-8&amp;quot;);
&lt;br&gt;&amp;gt;                                Thread.sleep(100);
&lt;br&gt;&amp;gt;                                return buf2;
&lt;br&gt;&amp;gt;                        }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;                        @Override
&lt;br&gt;&amp;gt;                        public boolean hasNextChunk() throws Exception {
&lt;br&gt;&amp;gt;                                        return true;
&lt;br&gt;&amp;gt;                        }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;                        @Override
&lt;br&gt;&amp;gt;                        public void close() throws Exception {
&lt;br&gt;&amp;gt;                                // TODO Auto-generated method stub
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;                        }
&lt;br&gt;&amp;gt;                });
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;        if(close){
&lt;br&gt;&amp;gt;                future.addListener(ChannelFutureListener.CLOSE);
&lt;br&gt;&amp;gt;        }
&lt;br&gt;&amp;gt;        }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; View this message in context: &lt;a href=&quot;http://n2.nabble.com/How-to-implement-Streaming-server-like-The-Bayeux-Protocol-tp4055722p4055722.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://n2.nabble.com/How-to-implement-Streaming-server-like-The-Bayeux-Protocol-tp4055722p4055722.html&lt;/a&gt;&lt;br&gt;&amp;gt; Sent from the Netty User Group mailing list archive at Nabble.com.
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; netty-users mailing list
&lt;br&gt;&amp;gt; netty-users@lists.jboss.org
&lt;br&gt;&amp;gt; &lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&lt;br&gt;— Trustin Lee, &lt;a href=&quot;http://gleamynode.net/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://gleamynode.net/&lt;/a&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;netty-users mailing list
&lt;br&gt;netty-users@lists.jboss.org
&lt;br&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;/blockquote&gt;
</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/How-to-implement-Streaming-server-like-The-Bayeux-Protocol-tp4055722p4058231.html" />
	<thr:in-reply-to ref="tag:n2.nabble.com,2006:post-4058218"/>
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4058218</id>
	<title>Re: How to implement Streaming server like The Bayeux Protocol</title>
	<published>2009-11-24T06:49:13Z</published>
	<updated>2009-11-24T06:49:13Z</updated>
	<author>
		<name>sumitatgharkikhoj</name>
	</author>
	<content type="html">Hi Trustin, i replaced the line in the static file server example:
&lt;br&gt;&amp;nbsp;//ChannelFuture writeFuture = ch.write(new ChunkedFile(raf, 0, fileLength, 8192));
&lt;br&gt;with line :
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ChannelFuture writeFuture = e.getChannel().write(new ChunkedInput() {
&lt;br&gt;&lt;br&gt;my server still getting blocked after two requests all other requests get piled up.
&lt;br&gt;What i did:
&lt;br&gt;1) Took the example httpstatic file server
&lt;br&gt;2) Instead of using chunked file use my own chunked input
&lt;br&gt;3) Opened three different browsers: firefox, chrmoe,ie &amp;nbsp;( to make sure the test does not gets affected by browser)
&lt;br&gt;4) First two requests succeed and data starts streaming to both firefox and chrome but ie request does not event reach my handler.
&lt;br&gt;5) When i escape or close one of the browser the third request goes through and my static file server handler gets the response.
&lt;br&gt;&lt;br&gt;I still get the same results the server gets blocked.
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;blockquote class=&quot;quote light-black dark-border-color&quot;&gt;&lt;div class=&quot;quote light-border-color&quot;&gt;
&lt;div class=&quot;quote-author&quot; style=&quot;font-weight: bold;&quot;&gt;Trustin Lee wrote:&lt;/div&gt;
&lt;div class=&quot;quote-message shrinkable-quote&quot;&gt;On Tue, Nov 24, 2009 at 1:02 PM, sumitatgharkikhoj
&lt;br&gt;&amp;lt;mailtosumitsingh@gmail.com&amp;gt; wrote:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; First of all thank you for the nice framework, forum and documentation.
&lt;br&gt;&amp;gt; My problem is i am trying to write a http server with small footprint ( will
&lt;br&gt;&amp;gt; go as a component in bigger framework) but it needs to have streaming
&lt;br&gt;&amp;gt; support .
&lt;br&gt;&amp;gt; Different clients will connect at different times ranging from 100-1000
&lt;br&gt;&amp;gt; clients max and this server will be used for both streaming and short data.
&lt;br&gt;&amp;gt; the data is streamed using XHR multipart request and continously (24/7) .
&lt;br&gt;&amp;gt; But when i used the example code (please see below) the server blocks after
&lt;br&gt;&amp;gt; first thread.
&lt;br&gt;&lt;br&gt;In your handler, you check if the returned future.isSuccess() is true
&lt;br&gt;or false right after calling write(). &amp;nbsp;It will be almost always false
&lt;br&gt;because the write operation is asynchronous. &amp;nbsp;You are using
&lt;br&gt;ChunkedInput, so I'd recommend you take a look into the
&lt;br&gt;HttpStaticFileServerHandler.
&lt;br&gt;&lt;br&gt;&amp;gt; Other option that i tried was jetty with continuation or cometd but i am
&lt;br&gt;&amp;gt; more inclined about netty (since i want to replace my mina udp layer with
&lt;br&gt;&amp;gt; mina and maintain one single library ).
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Any help will be appreciated, I have my machine available via webex to debug
&lt;br&gt;&amp;gt; as well.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; my server gets block at second request in the following code :
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; 1) in my http server:
&lt;br&gt;&amp;gt;           ServerBootstrap bootstrap = new ServerBootstrap(new
&lt;br&gt;&amp;gt; NioServerSocketChannelFactory(Executors.newCachedThreadPool(),Executors.newCachedThreadPool()));
&lt;br&gt;&amp;gt;           bootstrap.setPipelineFactory(new
&lt;br&gt;&amp;gt; HttpServerPipelineFactory(requestHandler));
&lt;br&gt;&amp;gt;          bootstrap.bind(new InetSocketAddress(8080));
&lt;br&gt;&amp;gt; 2) in my pipelinefactory:
&lt;br&gt;&amp;gt;    public ChannelPipeline getPipeline() throws Exception {
&lt;br&gt;&amp;gt;        ChannelPipeline pipeline = pipeline();
&lt;br&gt;&amp;gt;        pipeline.addLast(&amp;quot;decoder&amp;quot;, new HttpRequestDecoder());
&lt;br&gt;&amp;gt;        pipeline.addLast(&amp;quot;encoder&amp;quot;, new HttpResponseEncoder());
&lt;br&gt;&amp;gt;        pipeline.addLast(&amp;quot;chunkedWriter&amp;quot;, new ChunkedWriteHandler());
&lt;br&gt;&amp;gt;        pipeline.addLast(&amp;quot;handler&amp;quot;, requestHandler);
&lt;br&gt;&amp;gt;        return pipeline;
&lt;br&gt;&amp;gt; 3)my http request handler sends event using following code
&lt;br&gt;&amp;gt;        private void writeResponse(MessageEvent e) {
&lt;br&gt;&amp;gt;                ChannelBuffer buf =
&lt;br&gt;&amp;gt; ChannelBuffers.copiedBuffer(responseContent.toString(), &amp;quot;UTF-8&amp;quot;);
&lt;br&gt;&amp;gt;                buf.setBytes(0, responseContent.toString().getBytes() );
&lt;br&gt;&amp;gt;                responseContent.setLength(0);
&lt;br&gt;&amp;gt;                boolean close =  HttpHeaders.Values.CLOSE.equalsIgnoreCase(request
&lt;br&gt;&amp;gt;                                .getHeader(HttpHeaders.Names.CONNECTION))
&lt;br&gt;&amp;gt;                                || request.getProtocolVersion().equals(HttpVersion.HTTP_1_0)
&lt;br&gt;&amp;gt;                                &amp;&amp; !HttpHeaders.Values.KEEP_ALIVE.equalsIgnoreCase(request
&lt;br&gt;&amp;gt;                                                .getHeader(HttpHeaders.Names.CONNECTION));
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;                HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1,
&lt;br&gt;&amp;gt; HttpResponseStatus.OK);
&lt;br&gt;&amp;gt;                //response.setContent(buf);
&lt;br&gt;&amp;gt;                //response.setHeader(HttpHeaders.Names.CONTENT_TYPE, &amp;quot;text/html;
&lt;br&gt;&amp;gt; charset=UTF-8&amp;quot;);
&lt;br&gt;&amp;gt;                response.setHeader(HttpHeaders.Names.CONTENT_TYPE,
&lt;br&gt;&amp;gt; &amp;quot;multipart/x-mixed-replace;boundary=XXoXoX&amp;quot;);
&lt;br&gt;&amp;gt;                //if (!close)
&lt;br&gt;&amp;gt;                {
&lt;br&gt;&amp;gt;                        response.setHeader(&amp;quot;Connection&amp;quot;, &amp;quot;Keep-Alive&amp;quot;);
&lt;br&gt;&amp;gt;                        response.setHeader(&amp;quot;Cache-Control&amp;quot;, &amp;quot;no-cache&amp;quot;);
&lt;br&gt;&amp;gt;                        response.setHeader(&amp;quot;Access-Control-Allow-Origin&amp;quot;, &amp;quot;*&amp;quot;);
&lt;br&gt;&amp;gt;                }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;                String cookieString = request.getHeader(HttpHeaders.Names.COOKIE);
&lt;br&gt;&amp;gt;                if (cookieString != null) {
&lt;br&gt;&amp;gt;                        CookieDecoder cookieDecoder = new CookieDecoder();
&lt;br&gt;&amp;gt;                        Set&amp;lt;Cookie&amp;gt; cookies = cookieDecoder.decode(cookieString);
&lt;br&gt;&amp;gt;                        if (!cookies.isEmpty()) {
&lt;br&gt;&amp;gt;                                CookieEncoder cookieEncoder = new CookieEncoder(true);
&lt;br&gt;&amp;gt;                                for (Cookie cookie : cookies) {
&lt;br&gt;&amp;gt;                                        cookieEncoder.addCookie(cookie);
&lt;br&gt;&amp;gt;                                }
&lt;br&gt;&amp;gt;                                response.addHeader(HttpHeaders.Names.SET_COOKIE,
&lt;br&gt;&amp;gt; cookieEncoder.encode());
&lt;br&gt;&amp;gt;                        }
&lt;br&gt;&amp;gt;                }
&lt;br&gt;&amp;gt;                ChannelFuture future =null;
&lt;br&gt;&amp;gt;                future = e.getChannel().write(response);
&lt;br&gt;&amp;gt;                String temp =&amp;quot;&amp;quot;;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;                if(future.isSuccess()==false)
&lt;br&gt;&amp;gt;                        return;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;                e.getChannel().write(new ChunkedInput() {
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;                        int i = 0;
&lt;br&gt;&amp;gt;                        public Object nextChunk() throws Exception {
&lt;br&gt;&amp;gt;                                i++;
&lt;br&gt;&amp;gt;                                String temp =&amp;quot;&amp;quot;;
&lt;br&gt;&amp;gt;                                //temp =&amp;quot;--XXoXoX\r\n&amp;quot;;
&lt;br&gt;&amp;gt;                                temp = &amp;quot;Content-Type: text/plain \r\n\r\n&amp;quot;;
&lt;br&gt;&amp;gt;                                temp += &amp;quot;{\&amp;quot;data\&amp;quot;:\&amp;quot;&amp;quot;+i+&amp;quot;\&amp;quot;}&amp;quot;;
&lt;br&gt;&amp;gt;                                temp +=&amp;quot;\r\n--XXoXoX\r\n&amp;quot;;
&lt;br&gt;&amp;gt;                                ChannelBuffer buf2 = ChannelBuffers.copiedBuffer(temp.toString(),
&lt;br&gt;&amp;gt; &amp;quot;UTF-8&amp;quot;);
&lt;br&gt;&amp;gt;                                Thread.sleep(100);
&lt;br&gt;&amp;gt;                                return buf2;
&lt;br&gt;&amp;gt;                        }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;                        @Override
&lt;br&gt;&amp;gt;                        public boolean hasNextChunk() throws Exception {
&lt;br&gt;&amp;gt;                                        return true;
&lt;br&gt;&amp;gt;                        }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;                        @Override
&lt;br&gt;&amp;gt;                        public void close() throws Exception {
&lt;br&gt;&amp;gt;                                // TODO Auto-generated method stub
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;                        }
&lt;br&gt;&amp;gt;                });
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;        if(close){
&lt;br&gt;&amp;gt;                future.addListener(ChannelFutureListener.CLOSE);
&lt;br&gt;&amp;gt;        }
&lt;br&gt;&amp;gt;        }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; View this message in context: &lt;a href=&quot;http://n2.nabble.com/How-to-implement-Streaming-server-like-The-Bayeux-Protocol-tp4055722p4055722.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://n2.nabble.com/How-to-implement-Streaming-server-like-The-Bayeux-Protocol-tp4055722p4055722.html&lt;/a&gt;&lt;br&gt;&amp;gt; Sent from the Netty User Group mailing list archive at Nabble.com.
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; netty-users mailing list
&lt;br&gt;&amp;gt; netty-users@lists.jboss.org
&lt;br&gt;&amp;gt; &lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&lt;br&gt;— Trustin Lee, &lt;a href=&quot;http://gleamynode.net/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://gleamynode.net/&lt;/a&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;netty-users mailing list
&lt;br&gt;netty-users@lists.jboss.org
&lt;br&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;&lt;/blockquote&gt;
</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/How-to-implement-Streaming-server-like-The-Bayeux-Protocol-tp4055722p4058218.html" />
	<thr:in-reply-to ref="tag:n2.nabble.com,2006:post-4055786"/>
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4055786</id>
	<title>Re: How to implement Streaming server like The Bayeux Protocol</title>
	<published>2009-11-23T20:18:11Z</published>
	<updated>2009-11-23T20:18:11Z</updated>
	<author>
		<name>Trustin Lee</name>
	</author>
	<content type="html">On Tue, Nov 24, 2009 at 1:02 PM, sumitatgharkikhoj
&lt;br&gt;&amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4055786&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; First of all thank you for the nice framework, forum and documentation.
&lt;br&gt;&amp;gt; My problem is i am trying to write a http server with small footprint ( will
&lt;br&gt;&amp;gt; go as a component in bigger framework) but it needs to have streaming
&lt;br&gt;&amp;gt; support .
&lt;br&gt;&amp;gt; Different clients will connect at different times ranging from 100-1000
&lt;br&gt;&amp;gt; clients max and this server will be used for both streaming and short data.
&lt;br&gt;&amp;gt; the data is streamed using XHR multipart request and continously (24/7) .
&lt;br&gt;&amp;gt; But when i used the example code (please see below) the server blocks after
&lt;br&gt;&amp;gt; first thread.
&lt;/div&gt;&lt;br&gt;In your handler, you check if the returned future.isSuccess() is true
&lt;br&gt;or false right after calling write(). &amp;nbsp;It will be almost always false
&lt;br&gt;because the write operation is asynchronous. &amp;nbsp;You are using
&lt;br&gt;ChunkedInput, so I'd recommend you take a look into the
&lt;br&gt;HttpStaticFileServerHandler.
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Other option that i tried was jetty with continuation or cometd but i am
&lt;br&gt;&amp;gt; more inclined about netty (since i want to replace my mina udp layer with
&lt;br&gt;&amp;gt; mina and maintain one single library ).
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Any help will be appreciated, I have my machine available via webex to debug
&lt;br&gt;&amp;gt; as well.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; my server gets block at second request in the following code :
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; 1) in my http server:
&lt;br&gt;&amp;gt;           ServerBootstrap bootstrap = new ServerBootstrap(new
&lt;br&gt;&amp;gt; NioServerSocketChannelFactory(Executors.newCachedThreadPool(),Executors.newCachedThreadPool()));
&lt;br&gt;&amp;gt;           bootstrap.setPipelineFactory(new
&lt;br&gt;&amp;gt; HttpServerPipelineFactory(requestHandler));
&lt;br&gt;&amp;gt;          bootstrap.bind(new InetSocketAddress(8080));
&lt;br&gt;&amp;gt; 2) in my pipelinefactory:
&lt;br&gt;&amp;gt;    public ChannelPipeline getPipeline() throws Exception {
&lt;br&gt;&amp;gt;        ChannelPipeline pipeline = pipeline();
&lt;br&gt;&amp;gt;        pipeline.addLast(&amp;quot;decoder&amp;quot;, new HttpRequestDecoder());
&lt;br&gt;&amp;gt;        pipeline.addLast(&amp;quot;encoder&amp;quot;, new HttpResponseEncoder());
&lt;br&gt;&amp;gt;        pipeline.addLast(&amp;quot;chunkedWriter&amp;quot;, new ChunkedWriteHandler());
&lt;br&gt;&amp;gt;        pipeline.addLast(&amp;quot;handler&amp;quot;, requestHandler);
&lt;br&gt;&amp;gt;        return pipeline;
&lt;br&gt;&amp;gt; 3)my http request handler sends event using following code
&lt;br&gt;&amp;gt;        private void writeResponse(MessageEvent e) {
&lt;br&gt;&amp;gt;                ChannelBuffer buf =
&lt;br&gt;&amp;gt; ChannelBuffers.copiedBuffer(responseContent.toString(), &amp;quot;UTF-8&amp;quot;);
&lt;br&gt;&amp;gt;                buf.setBytes(0, responseContent.toString().getBytes() );
&lt;br&gt;&amp;gt;                responseContent.setLength(0);
&lt;br&gt;&amp;gt;                boolean close =  HttpHeaders.Values.CLOSE.equalsIgnoreCase(request
&lt;br&gt;&amp;gt;                                .getHeader(HttpHeaders.Names.CONNECTION))
&lt;br&gt;&amp;gt;                                || request.getProtocolVersion().equals(HttpVersion.HTTP_1_0)
&lt;br&gt;&amp;gt;                                &amp;&amp; !HttpHeaders.Values.KEEP_ALIVE.equalsIgnoreCase(request
&lt;br&gt;&amp;gt;                                                .getHeader(HttpHeaders.Names.CONNECTION));
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;                HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1,
&lt;br&gt;&amp;gt; HttpResponseStatus.OK);
&lt;br&gt;&amp;gt;                //response.setContent(buf);
&lt;br&gt;&amp;gt;                //response.setHeader(HttpHeaders.Names.CONTENT_TYPE, &amp;quot;text/html;
&lt;br&gt;&amp;gt; charset=UTF-8&amp;quot;);
&lt;br&gt;&amp;gt;                response.setHeader(HttpHeaders.Names.CONTENT_TYPE,
&lt;br&gt;&amp;gt; &amp;quot;multipart/x-mixed-replace;boundary=XXoXoX&amp;quot;);
&lt;br&gt;&amp;gt;                //if (!close)
&lt;br&gt;&amp;gt;                {
&lt;br&gt;&amp;gt;                        response.setHeader(&amp;quot;Connection&amp;quot;, &amp;quot;Keep-Alive&amp;quot;);
&lt;br&gt;&amp;gt;                        response.setHeader(&amp;quot;Cache-Control&amp;quot;, &amp;quot;no-cache&amp;quot;);
&lt;br&gt;&amp;gt;                        response.setHeader(&amp;quot;Access-Control-Allow-Origin&amp;quot;, &amp;quot;*&amp;quot;);
&lt;br&gt;&amp;gt;                }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;                String cookieString = request.getHeader(HttpHeaders.Names.COOKIE);
&lt;br&gt;&amp;gt;                if (cookieString != null) {
&lt;br&gt;&amp;gt;                        CookieDecoder cookieDecoder = new CookieDecoder();
&lt;br&gt;&amp;gt;                        Set&amp;lt;Cookie&amp;gt; cookies = cookieDecoder.decode(cookieString);
&lt;br&gt;&amp;gt;                        if (!cookies.isEmpty()) {
&lt;br&gt;&amp;gt;                                CookieEncoder cookieEncoder = new CookieEncoder(true);
&lt;br&gt;&amp;gt;                                for (Cookie cookie : cookies) {
&lt;br&gt;&amp;gt;                                        cookieEncoder.addCookie(cookie);
&lt;br&gt;&amp;gt;                                }
&lt;br&gt;&amp;gt;                                response.addHeader(HttpHeaders.Names.SET_COOKIE,
&lt;br&gt;&amp;gt; cookieEncoder.encode());
&lt;br&gt;&amp;gt;                        }
&lt;br&gt;&amp;gt;                }
&lt;br&gt;&amp;gt;                ChannelFuture future =null;
&lt;br&gt;&amp;gt;                future = e.getChannel().write(response);
&lt;br&gt;&amp;gt;                String temp =&amp;quot;&amp;quot;;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;                if(future.isSuccess()==false)
&lt;br&gt;&amp;gt;                        return;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;                e.getChannel().write(new ChunkedInput() {
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;                        int i = 0;
&lt;br&gt;&amp;gt;                        public Object nextChunk() throws Exception {
&lt;br&gt;&amp;gt;                                i++;
&lt;br&gt;&amp;gt;                                String temp =&amp;quot;&amp;quot;;
&lt;br&gt;&amp;gt;                                //temp =&amp;quot;--XXoXoX\r\n&amp;quot;;
&lt;br&gt;&amp;gt;                                temp = &amp;quot;Content-Type: text/plain \r\n\r\n&amp;quot;;
&lt;br&gt;&amp;gt;                                temp += &amp;quot;{\&amp;quot;data\&amp;quot;:\&amp;quot;&amp;quot;+i+&amp;quot;\&amp;quot;}&amp;quot;;
&lt;br&gt;&amp;gt;                                temp +=&amp;quot;\r\n--XXoXoX\r\n&amp;quot;;
&lt;br&gt;&amp;gt;                                ChannelBuffer buf2 = ChannelBuffers.copiedBuffer(temp.toString(),
&lt;br&gt;&amp;gt; &amp;quot;UTF-8&amp;quot;);
&lt;br&gt;&amp;gt;                                Thread.sleep(100);
&lt;br&gt;&amp;gt;                                return buf2;
&lt;br&gt;&amp;gt;                        }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;                        @Override
&lt;br&gt;&amp;gt;                        public boolean hasNextChunk() throws Exception {
&lt;br&gt;&amp;gt;                                        return true;
&lt;br&gt;&amp;gt;                        }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;                        @Override
&lt;br&gt;&amp;gt;                        public void close() throws Exception {
&lt;br&gt;&amp;gt;                                // TODO Auto-generated method stub
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;                        }
&lt;br&gt;&amp;gt;                });
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;        if(close){
&lt;br&gt;&amp;gt;                future.addListener(ChannelFutureListener.CLOSE);
&lt;br&gt;&amp;gt;        }
&lt;br&gt;&amp;gt;        }
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; View this message in context: &lt;a href=&quot;http://n2.nabble.com/How-to-implement-Streaming-server-like-The-Bayeux-Protocol-tp4055722p4055722.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://n2.nabble.com/How-to-implement-Streaming-server-like-The-Bayeux-Protocol-tp4055722p4055722.html&lt;/a&gt;&lt;br&gt;&amp;gt; Sent from the Netty User Group mailing list archive at Nabble.com.
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; netty-users mailing list
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4055786&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&amp;gt; &lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;— Trustin Lee, &lt;a href=&quot;http://gleamynode.net/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://gleamynode.net/&lt;/a&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;netty-users mailing list
&lt;br&gt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4055786&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&lt;div class=&quot;signature&quot;&gt;— Trustin Lee, &lt;a href=&quot;http://gleamynode.net/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://gleamynode.net/&lt;/a&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/How-to-implement-Streaming-server-like-The-Bayeux-Protocol-tp4055722p4055786.html" />
	<thr:in-reply-to ref="tag:n2.nabble.com,2006:post-4055722"/>
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4055722</id>
	<title>How to implement Streaming server like The Bayeux Protocol</title>
	<published>2009-11-23T20:02:47Z</published>
	<updated>2009-11-23T20:02:47Z</updated>
	<author>
		<name>sumitatgharkikhoj</name>
	</author>
	<content type="html">First of all thank you for the nice framework, forum and documentation.
&lt;br&gt;My problem is i am trying to write a http server with small footprint ( will go as a component in bigger framework) but it needs to have streaming support .
&lt;br&gt;Different clients will connect at different times ranging from 100-1000 clients max and this server will be used for both streaming and short data.
&lt;br&gt;the data is streamed using XHR multipart request and continously (24/7) . 
&lt;br&gt;But when i used the example code (please see below) the server blocks after first thread.
&lt;br&gt;Other option that i tried was jetty with continuation or cometd but i am more inclined about netty (since i want to replace my mina udp layer with mina and maintain one single library ).
&lt;br&gt;&lt;br&gt;Any help will be appreciated, I have my machine available via webex to debug as well.
&lt;br&gt;&lt;br&gt;&lt;br&gt;my server gets block at second request in the following code :
&lt;br&gt;&lt;br&gt;1) in my http server:
&lt;br&gt;&amp;nbsp; &amp;nbsp; 	 &amp;nbsp; ServerBootstrap bootstrap = new ServerBootstrap(new NioServerSocketChannelFactory(Executors.newCachedThreadPool(),Executors.newCachedThreadPool()));
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;bootstrap.setPipelineFactory(new HttpServerPipelineFactory(requestHandler));
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; bootstrap.bind(new InetSocketAddress(8080));
&lt;br&gt;2) in my pipelinefactory:
&lt;br&gt;&amp;nbsp; &amp;nbsp; public ChannelPipeline getPipeline() throws Exception {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ChannelPipeline pipeline = pipeline();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pipeline.addLast(&amp;quot;decoder&amp;quot;, new HttpRequestDecoder());
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pipeline.addLast(&amp;quot;encoder&amp;quot;, new HttpResponseEncoder());
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pipeline.addLast(&amp;quot;chunkedWriter&amp;quot;, new ChunkedWriteHandler());
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pipeline.addLast(&amp;quot;handler&amp;quot;, requestHandler);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return pipeline; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;3)my http request handler sends event using following code 
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private void writeResponse(MessageEvent e) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ChannelBuffer buf = ChannelBuffers.copiedBuffer(responseContent.toString(), &amp;quot;UTF-8&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; buf.setBytes(0, responseContent.toString().getBytes() );
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; responseContent.setLength(0);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; boolean close = &amp;nbsp;HttpHeaders.Values.CLOSE.equalsIgnoreCase(request
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .getHeader(HttpHeaders.Names.CONNECTION))
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; || request.getProtocolVersion().equals(HttpVersion.HTTP_1_0)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;&amp; !HttpHeaders.Values.KEEP_ALIVE.equalsIgnoreCase(request
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .getHeader(HttpHeaders.Names.CONNECTION));
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1,			HttpResponseStatus.OK);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //response.setContent(buf);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //response.setHeader(HttpHeaders.Names.CONTENT_TYPE, &amp;quot;text/html; charset=UTF-8&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; response.setHeader(HttpHeaders.Names.CONTENT_TYPE, &amp;quot;multipart/x-mixed-replace;boundary=XXoXoX&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //if (!close) 
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; response.setHeader(&amp;quot;Connection&amp;quot;, &amp;quot;Keep-Alive&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; response.setHeader(&amp;quot;Cache-Control&amp;quot;, &amp;quot;no-cache&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; response.setHeader(&amp;quot;Access-Control-Allow-Origin&amp;quot;, &amp;quot;*&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; String cookieString = request.getHeader(HttpHeaders.Names.COOKIE);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (cookieString != null) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CookieDecoder cookieDecoder = new CookieDecoder();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Set&amp;lt;Cookie&amp;gt; cookies = cookieDecoder.decode(cookieString);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (!cookies.isEmpty()) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; CookieEncoder cookieEncoder = new CookieEncoder(true);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for (Cookie cookie : cookies) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cookieEncoder.addCookie(cookie);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; response.addHeader(HttpHeaders.Names.SET_COOKIE, cookieEncoder.encode());
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ChannelFuture future =null;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; future = e.getChannel().write(response);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; String temp =&amp;quot;&amp;quot;;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(future.isSuccess()==false)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; e.getChannel().write(new ChunkedInput() {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; int i = 0;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public Object nextChunk() throws Exception {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; i++;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; String temp =&amp;quot;&amp;quot;;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //temp =&amp;quot;--XXoXoX\r\n&amp;quot;;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; temp = &amp;quot;Content-Type: text/plain \r\n\r\n&amp;quot;;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; temp += &amp;quot;{\&amp;quot;data\&amp;quot;:\&amp;quot;&amp;quot;+i+&amp;quot;\&amp;quot;}&amp;quot;;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; temp +=&amp;quot;\r\n--XXoXoX\r\n&amp;quot;;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ChannelBuffer buf2 = ChannelBuffers.copiedBuffer(temp.toString(), &amp;quot;UTF-8&amp;quot;);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Thread.sleep(100);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return buf2;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; @Override
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public boolean hasNextChunk() throws Exception {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return true;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; @Override
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public void close() throws Exception {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // TODO Auto-generated method stub
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; });
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(close){
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; future.addListener(ChannelFutureListener.CLOSE);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/How-to-implement-Streaming-server-like-The-Bayeux-Protocol-tp4055722p4055722.html" />
	
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4053416</id>
	<title>Announcing Flazr - RTMP streaming server based on Netty</title>
	<published>2009-11-23T11:41:27Z</published>
	<updated>2009-11-23T11:41:27Z</updated>
	<author>
		<name>Peter Thomas</name>
	</author>
	<content type="html">Hi,&lt;br&gt;&lt;br&gt;Just a quick message to this list, apologies for the shameless plug ;)  A big thanks to Trustin and all others involved for this awesome framework.&lt;br&gt;&lt;br&gt;I ported the code at &lt;a href=&quot;http://flazr.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://flazr.com&lt;/a&gt; from Apache Mina to Netty in around a month (not full time).  Along the way, mainly because I was pretty impressed by Netty, the documentation quality and the way things just fell into place after implementing the basic encoder / decoder - what was originally envisaged as a pure client-side project extended smoothly into a server-side one as well.  There&amp;#39;s even an experimental proxy server for RTMP in the distribution which was written in a matter of minutes - but is proving very useful for watching the wire and debugging stuff.  I hope to write a detailed summary or blog post later, for now hope this message finds people on this list who may be interested in the RTMP protocol - one which used to be somewhat obscure until recently.  Hoping to have more updates on the status of this project in the future.&lt;br&gt;
&lt;br&gt;Regards,&lt;br&gt;&lt;br&gt;Peter.&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;
&lt;br /&gt;_______________________________________________
&lt;br&gt;netty-users mailing list
&lt;br&gt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4053416&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/Announcing-Flazr-RTMP-streaming-server-based-on-Netty-tp4053416p4053416.html" />
	
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4048535</id>
	<title>Re: Can you share ChannelFactory / worker threads in a p2p app?</title>
	<published>2009-11-22T17:38:14Z</published>
	<updated>2009-11-22T17:38:14Z</updated>
	<author>
		<name>Thingfish</name>
	</author>
	<content type="html">There is probably not much of a performance difference looking at the individual app. I want to be able to run a large number of instances on a single machine (for testing), and number of threads might become an issue in this case.&lt;div&gt;
&lt;br&gt;&lt;/div&gt;&lt;div&gt;I&amp;#39;ve put a simple (as of yet untested) suggestion together, as for how worker sharing might be archived. I noticed that NioServerSocketPipelineSink and NioClientSocketPipelineSink implements the same round-robin load balancing over a worker array, and that the sinks make no use of workerExecutor and workerCount once the worker array has been constructed. I&amp;#39;ve factored this out into a NioWorkerPool class, and changed the sinks to receive this instead. The channel factories have had a new constructor added, that takes a pre-constructed workerPool, thereby making it possible to share the pool between clients and servers. &lt;/div&gt;
&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Have included the code below (as a patch against trunk). A few issues: Need to assign a useful bossID to a shared worker, and also change NioWorker so that an appropriate threadName is selected. Do you foresee any issues with this solution?&lt;/div&gt;
&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Regards&lt;/div&gt;&lt;div&gt;Jannick Bitsch&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;### Eclipse Workspace Patch 1.0&lt;/div&gt;&lt;div&gt;#P Netty&lt;/div&gt;&lt;div&gt;Index: src/org/jboss/netty/channel/socket/nio/NioClientSocketChannelFactory.java&lt;/div&gt;
&lt;div&gt;===================================================================&lt;/div&gt;&lt;div&gt;--- src/org/jboss/netty/channel/socket/nio/NioClientSocketChannelFactory.java&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;(revision 1904)&lt;/div&gt;
&lt;div&gt;+++ src/org/jboss/netty/channel/socket/nio/NioClientSocketChannelFactory.java&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;(working copy)&lt;/div&gt;&lt;div&gt;@@ -118,23 +118,30 @@&lt;/div&gt;&lt;div&gt;     public NioClientSocketChannelFactory(&lt;/div&gt;
&lt;div&gt;             Executor bossExecutor, Executor workerExecutor,&lt;/div&gt;&lt;div&gt;             int workerCount) {&lt;/div&gt;&lt;div&gt;+    &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;this(bossExecutor, new NioWorkerPool(workerExecutor, workerCount));&lt;/div&gt;
&lt;div&gt;+    }&lt;/div&gt;&lt;div&gt;+    &lt;/div&gt;&lt;div&gt;+    &lt;/div&gt;&lt;div&gt;+    /**&lt;/div&gt;&lt;div&gt;+     * Creates a new instance.&lt;/div&gt;&lt;div&gt;+     *&lt;/div&gt;&lt;div&gt;+     * @param bossExecutor&lt;/div&gt;&lt;div&gt;+     *        the {@link Executor} which will execute the boss thread&lt;/div&gt;
&lt;div&gt;+     * @param workerPool&lt;/div&gt;&lt;div&gt;+     *        the {@link NioWorkerPool} which will supply nio workers&lt;/div&gt;&lt;div&gt;+     */&lt;/div&gt;&lt;div&gt;+    public NioClientSocketChannelFactory(&lt;/div&gt;&lt;div&gt;+            Executor bossExecutor, NioWorkerPool workerPool) {&lt;/div&gt;
&lt;div&gt;         if (bossExecutor == null) {&lt;/div&gt;&lt;div&gt;             throw new NullPointerException(&amp;quot;bossExecutor&amp;quot;);&lt;/div&gt;&lt;div&gt;         }&lt;/div&gt;&lt;div&gt;-        if (workerExecutor == null) {&lt;/div&gt;&lt;div&gt;-            throw new NullPointerException(&amp;quot;workerExecutor&amp;quot;);&lt;/div&gt;
&lt;div&gt;-        }&lt;/div&gt;&lt;div&gt;-        if (workerCount &amp;lt;= 0) {&lt;/div&gt;&lt;div&gt;-            throw new IllegalArgumentException(&lt;/div&gt;&lt;div&gt;-                    &amp;quot;workerCount (&amp;quot; + workerCount + &amp;quot;) &amp;quot; +&lt;/div&gt;&lt;div&gt;
-                    &amp;quot;must be a positive integer.&amp;quot;);&lt;/div&gt;&lt;div&gt;-        }&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;         this.bossExecutor = bossExecutor;&lt;/div&gt;&lt;div&gt;-        this.workerExecutor = workerExecutor;&lt;/div&gt;&lt;div&gt;-        sink = new NioClientSocketPipelineSink(bossExecutor, workerExecutor, workerCount);&lt;/div&gt;
&lt;div&gt;-    }&lt;/div&gt;&lt;div&gt;+        this.workerExecutor = workerPool.workerExecutor;&lt;/div&gt;&lt;div&gt;+        sink = new NioClientSocketPipelineSink(bossExecutor, workerPool);&lt;/div&gt;&lt;div&gt;+    }    &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;+    &lt;/div&gt;&lt;div&gt;
     public SocketChannel newChannel(ChannelPipeline pipeline) {&lt;/div&gt;&lt;div&gt;         return new NioClientSocketChannel(this, pipeline, sink, sink.nextWorker());&lt;/div&gt;&lt;div&gt;     }&lt;/div&gt;&lt;div&gt;Index: src/org/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink.java&lt;/div&gt;
&lt;div&gt;===================================================================&lt;/div&gt;&lt;div&gt;--- src/org/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink.java&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;(revision 1904)&lt;/div&gt;
&lt;div&gt;+++ src/org/jboss/netty/channel/socket/nio/NioClientSocketPipelineSink.java&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;(working copy)&lt;/div&gt;&lt;div&gt;@@ -63,16 +63,12 @@&lt;/div&gt;&lt;div&gt;     final int id = nextId.incrementAndGet();&lt;/div&gt;
&lt;div&gt;     final Executor bossExecutor;&lt;/div&gt;&lt;div&gt;     private final Boss boss = new Boss();&lt;/div&gt;&lt;div&gt;-    private final NioWorker[] workers;&lt;/div&gt;&lt;div&gt;-    private final AtomicInteger workerIndex = new AtomicInteger();&lt;/div&gt;
&lt;div&gt;+    private final NioWorkerPool workerPool;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;     NioClientSocketPipelineSink(&lt;/div&gt;&lt;div&gt;-            Executor bossExecutor, Executor workerExecutor, int workerCount) {&lt;/div&gt;&lt;div&gt;+            Executor bossExecutor, NioWorkerPool workerPool) {&lt;/div&gt;
&lt;div&gt;         this.bossExecutor = bossExecutor;&lt;/div&gt;&lt;div&gt;-        workers = new NioWorker[workerCount];&lt;/div&gt;&lt;div&gt;-        for (int i = 0; i &amp;lt; workers.length; i ++) {&lt;/div&gt;&lt;div&gt;-            workers[i] = new NioWorker(id, i + 1, workerExecutor);&lt;/div&gt;
&lt;div&gt;-        }&lt;/div&gt;&lt;div&gt;+        this.workerPool = workerPool;&lt;/div&gt;&lt;div&gt;     }&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;     public void eventSunk(&lt;/div&gt;&lt;div&gt;@@ -160,8 +156,7 @@&lt;/div&gt;&lt;div&gt;     }&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;     NioWorker nextWorker() {&lt;/div&gt;
&lt;div&gt;-        return workers[Math.abs(&lt;/div&gt;&lt;div&gt;-                workerIndex.getAndIncrement() % workers.length)];&lt;/div&gt;&lt;div&gt;+        return workerPool.nextWorker();&lt;/div&gt;&lt;div&gt;     }&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;     private final class Boss implements Runnable {&lt;/div&gt;
&lt;div&gt;Index: src/org/jboss/netty/channel/socket/nio/NioServerSocketPipelineSink.java&lt;/div&gt;&lt;div&gt;===================================================================&lt;/div&gt;&lt;div&gt;--- src/org/jboss/netty/channel/socket/nio/NioServerSocketPipelineSink.java&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;(revision 1904)&lt;/div&gt;
&lt;div&gt;+++ src/org/jboss/netty/channel/socket/nio/NioServerSocketPipelineSink.java&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;(working copy)&lt;/div&gt;&lt;div&gt;@@ -57,14 +57,10 @@&lt;/div&gt;&lt;div&gt;     private static final AtomicInteger nextId = new AtomicInteger();&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;&lt;div&gt;     private final int id = nextId.incrementAndGet();&lt;/div&gt;&lt;div&gt;-    private final NioWorker[] workers;&lt;/div&gt;&lt;div&gt;-    private final AtomicInteger workerIndex = new AtomicInteger();&lt;/div&gt;&lt;div&gt;+    private final NioWorkerPool workerPool;&lt;/div&gt;
&lt;div&gt; &lt;/div&gt;&lt;div&gt;-    NioServerSocketPipelineSink(Executor workerExecutor, int workerCount) {&lt;/div&gt;&lt;div&gt;-        workers = new NioWorker[workerCount];&lt;/div&gt;&lt;div&gt;-        for (int i = 0; i &amp;lt; workers.length; i ++) {&lt;/div&gt;
&lt;div&gt;-            workers[i] = new NioWorker(id, i + 1, workerExecutor);&lt;/div&gt;&lt;div&gt;-        }&lt;/div&gt;&lt;div&gt;+    NioServerSocketPipelineSink(NioWorkerPool workerPool) {&lt;/div&gt;&lt;div&gt;+    &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;this.workerPool = workerPool;&lt;/div&gt;
&lt;div&gt;     }&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;     public void eventSunk(&lt;/div&gt;&lt;div&gt;@@ -191,8 +187,7 @@&lt;/div&gt;&lt;div&gt;     }&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;     NioWorker nextWorker() {&lt;/div&gt;&lt;div&gt;-        return workers[Math.abs(&lt;/div&gt;&lt;div&gt;-                workerIndex.getAndIncrement() % workers.length)];&lt;/div&gt;
&lt;div&gt;+        return workerPool.nextWorker();&lt;/div&gt;&lt;div&gt;     }&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;     private final class Boss implements Runnable {&lt;/div&gt;&lt;div&gt;Index: src/org/jboss/netty/channel/socket/nio/NioWorkerPool.java&lt;/div&gt;&lt;div&gt;
===================================================================&lt;/div&gt;&lt;div&gt;--- src/org/jboss/netty/channel/socket/nio/NioWorkerPool.java&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;(revision 0)&lt;/div&gt;&lt;div&gt;
+++ src/org/jboss/netty/channel/socket/nio/NioWorkerPool.java&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;(revision 0)&lt;/div&gt;&lt;div&gt;@@ -0,0 +1,34 @@&lt;/div&gt;&lt;div&gt;+package org.jboss.netty.channel.socket.nio;&lt;/div&gt;
&lt;div&gt;+&lt;/div&gt;&lt;div&gt;+import java.util.concurrent.Executor;&lt;/div&gt;&lt;div&gt;+import java.util.concurrent.atomic.AtomicInteger;&lt;/div&gt;&lt;div&gt;+&lt;/div&gt;&lt;div&gt;+public class NioWorkerPool {&lt;/div&gt;&lt;div&gt;+&lt;/div&gt;&lt;div&gt;+&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;private final NioWorker[] workers;&lt;/div&gt;
&lt;div&gt;+&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;private final AtomicInteger workerIndex = new AtomicInteger();&lt;/div&gt;&lt;div&gt;+&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;final Executor workerExecutor;&lt;/div&gt;
&lt;div&gt;+&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;&lt;/div&gt;&lt;div&gt;+&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;public NioWorkerPool(Executor workerExecutor, int workerCount){&lt;/div&gt;&lt;div&gt;+        if (workerExecutor == null) {&lt;/div&gt;
&lt;div&gt;+            throw new NullPointerException(&amp;quot;workerExecutor&amp;quot;);&lt;/div&gt;&lt;div&gt;+        }&lt;/div&gt;&lt;div&gt;+        if (workerCount &amp;lt;= 0) {&lt;/div&gt;&lt;div&gt;+            throw new IllegalArgumentException(&lt;/div&gt;&lt;div&gt;+                    &amp;quot;workerCount (&amp;quot; + workerCount + &amp;quot;) &amp;quot; +&lt;/div&gt;
&lt;div&gt;+                    &amp;quot;must be a positive integer.&amp;quot;);&lt;/div&gt;&lt;div&gt;+        }&lt;/div&gt;&lt;div&gt;+&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;&lt;/div&gt;&lt;div&gt;+&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;this.workerExecutor = workerExecutor;&lt;/div&gt;
&lt;div&gt;+&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;&lt;/div&gt;&lt;div&gt;+&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;workers = new NioWorker[workerCount];&lt;/div&gt;&lt;div&gt;+        for (int i = 0; i &amp;lt; workers.length; i ++) {&lt;/div&gt;
&lt;div&gt;+            workers[i] = new NioWorker(0xBEEF, i + 1, workerExecutor);&lt;/div&gt;&lt;div&gt;+        }&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;&lt;/div&gt;&lt;div&gt;+&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/div&gt;
&lt;div&gt;+&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;&lt;/div&gt;&lt;div&gt;+    public NioWorker nextWorker() {&lt;/div&gt;&lt;div&gt;+        return workers[Math.abs(&lt;/div&gt;&lt;div&gt;+                workerIndex.getAndIncrement() % workers.length)];&lt;/div&gt;
&lt;div&gt;+    }&lt;/div&gt;&lt;div&gt;+}&lt;/div&gt;&lt;div&gt;\ No newline at end of file&lt;/div&gt;&lt;div&gt;Index: src/org/jboss/netty/channel/socket/nio/NioServerSocketChannelFactory.java&lt;/div&gt;&lt;div&gt;===================================================================&lt;/div&gt;
&lt;div&gt;--- src/org/jboss/netty/channel/socket/nio/NioServerSocketChannelFactory.java&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;(revision 1904)&lt;/div&gt;&lt;div&gt;+++ src/org/jboss/netty/channel/socket/nio/NioServerSocketChannelFactory.java&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;(working copy)&lt;/div&gt;
&lt;div&gt;@@ -122,22 +122,34 @@&lt;/div&gt;&lt;div&gt;     public NioServerSocketChannelFactory(&lt;/div&gt;&lt;div&gt;             Executor bossExecutor, Executor workerExecutor,&lt;/div&gt;&lt;div&gt;             int workerCount) {&lt;/div&gt;&lt;div&gt;+        this(bossExecutor, new NioWorkerPool(workerExecutor, workerCount));&lt;/div&gt;
&lt;div&gt;+    }&lt;/div&gt;&lt;div&gt;+&lt;/div&gt;&lt;div&gt;+    /**&lt;/div&gt;&lt;div&gt;+     * Creates a new instance.&lt;/div&gt;&lt;div&gt;+     *&lt;/div&gt;&lt;div&gt;+     * @param bossExecutor&lt;/div&gt;&lt;div&gt;+     *        the {@link Executor} which will execute the boss threads&lt;/div&gt;
&lt;div&gt;+     * @param workerPool&lt;/div&gt;&lt;div&gt;+     *        the {@link NioWorkerPool} which will supply nio workers&lt;/div&gt;&lt;div&gt;+     */    &lt;/div&gt;&lt;div&gt;+    public NioServerSocketChannelFactory(&lt;/div&gt;&lt;div&gt;+    &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;Executor bossExecutor, NioWorkerPool workerPool){&lt;/div&gt;
&lt;div&gt;+    &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;&lt;/div&gt;&lt;div&gt;         if (bossExecutor == null) {&lt;/div&gt;&lt;div&gt;             throw new NullPointerException(&amp;quot;bossExecutor&amp;quot;);&lt;/div&gt;&lt;div&gt;         }&lt;/div&gt;
&lt;div&gt;-        if (workerExecutor == null) {&lt;/div&gt;&lt;div&gt;-            throw new NullPointerException(&amp;quot;workerExecutor&amp;quot;);&lt;/div&gt;&lt;div&gt;+        &lt;/div&gt;&lt;div&gt;+        if (workerPool == null) {&lt;/div&gt;&lt;div&gt;+            throw new NullPointerException(&amp;quot;workerPool&amp;quot;);&lt;/div&gt;
&lt;div&gt;         }&lt;/div&gt;&lt;div&gt;-        if (workerCount &amp;lt;= 0) {&lt;/div&gt;&lt;div&gt;-            throw new IllegalArgumentException(&lt;/div&gt;&lt;div&gt;-                    &amp;quot;workerCount (&amp;quot; + workerCount + &amp;quot;) &amp;quot; +&lt;/div&gt;&lt;div&gt;
-                    &amp;quot;must be a positive integer.&amp;quot;);&lt;/div&gt;&lt;div&gt;-        }&lt;/div&gt;&lt;div&gt;-        this.bossExecutor = bossExecutor;&lt;/div&gt;&lt;div&gt;-        this.workerExecutor = workerExecutor;&lt;/div&gt;&lt;div&gt;-        sink = new NioServerSocketPipelineSink(workerExecutor, workerCount);&lt;/div&gt;
&lt;div&gt;+    &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;&lt;/div&gt;&lt;div&gt;+    &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;this.bossExecutor = bossExecutor;&lt;/div&gt;&lt;div&gt;+    &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;this.workerExecutor = workerPool.workerExecutor;&lt;/div&gt;
&lt;div&gt;+        sink = new NioServerSocketPipelineSink(workerPool);    &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;&lt;/div&gt;&lt;div&gt;     }&lt;/div&gt;&lt;div&gt;-&lt;/div&gt;&lt;div&gt;+    &lt;/div&gt;&lt;div&gt;+    &lt;/div&gt;&lt;div&gt;     public ServerSocketChannel newChannel(ChannelPipeline pipeline) {&lt;/div&gt;
&lt;div&gt;         return new NioServerSocketChannel(this, pipeline, sink);&lt;/div&gt;&lt;div&gt;     }&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;div class=&quot;gmail_quote&quot;&gt;2009/11/23 Trustin Lee [via Netty Forums and Mailing Lists] &lt;span dir=&quot;ltr&quot;&gt;&amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4048535&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt;&lt;/span&gt;&lt;br&gt;
&lt;blockquote class=&quot;gmail_quote&quot; style=&quot;margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;&quot;&gt;

When I design Netty API, sharing worker threads for client and server
&lt;br&gt;side seemed to complicate the API too much comparing to the gained
&lt;br&gt;performance, and therefore the worker threads are not shared by
&lt;br&gt;different ChannelFactories.
&lt;br&gt;&lt;br&gt;If there is obvious advantage in performance, I&amp;#39;d like to implement it
&lt;br&gt;though.  Please let me know if you find something.
&lt;br&gt;&lt;br&gt;Thanks
&lt;br&gt;&lt;br&gt;— Trustin Lee, &lt;a href=&quot;http://gleamynode.net/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;http://gleamynode.net/&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;On Mon, Nov 23, 2009 at 8:42 AM, Thingfish &amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;amp;node=4048335&amp;amp;i=0&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt; wrote:
&lt;div&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Hi
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I&amp;#39;m currently in the process of coding a peer 2 peer app on top of Netty. By
&lt;br&gt;&amp;gt; definition each peer acts as both a server and a client, which means that I
&lt;br&gt;&amp;gt; currently make use of both the ClientBootstrap and ServerBootstrap   to
&lt;br&gt;&amp;gt; support &amp;quot;connection setup&amp;quot; in both directions. Once established &amp;quot;incomming&amp;quot;
&lt;br&gt;&amp;gt; and &amp;quot;outgoing&amp;quot; connections are indistinct able, and for this reason they
&lt;br&gt;&amp;gt; share the same pipeline factory.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; My question is, if its possible to also have them share the same worker
&lt;br&gt;&amp;gt; threads and selectors? Currently the use of seperate NioClient and NioServer
&lt;br&gt;&amp;gt; SocketChannelFactories means, that two disjoint sets of worker threads and
&lt;br&gt;&amp;gt; I/O resources are created. As both these worker pools deliver the exact same
&lt;br&gt;&amp;gt; service, it would be more efficient to avoid the extra threads.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; View this message in context: &lt;a href=&quot;http://n2.nabble.com/Can-you-share-ChannelFactory-worker-threads-in-a-p2p-app-tp4048241p4048241.html&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;http://n2.nabble.com/Can-you-share-ChannelFactory-worker-threads-in-a-p2p-app-tp4048241p4048241.html&lt;/a&gt;&lt;/div&gt;
&amp;gt; Sent from the Netty User Group mailing list archive at Nabble.com.
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; netty-users mailing list
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;amp;node=4048335&amp;amp;i=1&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&amp;gt; &lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;netty-users mailing list
&lt;br&gt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;amp;node=4048335&amp;amp;i=2&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&lt;div&gt;— Trustin Lee, &lt;a href=&quot;http://gleamynode.net/&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;http://gleamynode.net/&lt;/a&gt;&lt;/div&gt;


&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;/div&gt;
</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/Can-you-share-ChannelFactory-worker-threads-in-a-p2p-app-tp4048241p4048535.html" />
	<thr:in-reply-to ref="tag:n2.nabble.com,2006:post-4048335"/>
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4048335</id>
	<title>Re: Can you share ChannelFactory / worker threads in a p2p app?</title>
	<published>2009-11-22T16:10:11Z</published>
	<updated>2009-11-22T16:10:11Z</updated>
	<author>
		<name>Trustin Lee</name>
	</author>
	<content type="html">When I design Netty API, sharing worker threads for client and server
&lt;br&gt;side seemed to complicate the API too much comparing to the gained
&lt;br&gt;performance, and therefore the worker threads are not shared by
&lt;br&gt;different ChannelFactories.
&lt;br&gt;&lt;br&gt;If there is obvious advantage in performance, I'd like to implement it
&lt;br&gt;though. &amp;nbsp;Please let me know if you find something.
&lt;br&gt;&lt;br&gt;Thanks
&lt;br&gt;&lt;br&gt;— Trustin Lee, &lt;a href=&quot;http://gleamynode.net/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://gleamynode.net/&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;On Mon, Nov 23, 2009 at 8:42 AM, Thingfish &amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4048335&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Hi
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I'm currently in the process of coding a peer 2 peer app on top of Netty. By
&lt;br&gt;&amp;gt; definition each peer acts as both a server and a client, which means that I
&lt;br&gt;&amp;gt; currently make use of both the ClientBootstrap and ServerBootstrap   to
&lt;br&gt;&amp;gt; support &amp;quot;connection setup&amp;quot; in both directions. Once established &amp;quot;incomming&amp;quot;
&lt;br&gt;&amp;gt; and &amp;quot;outgoing&amp;quot; connections are indistinct able, and for this reason they
&lt;br&gt;&amp;gt; share the same pipeline factory.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; My question is, if its possible to also have them share the same worker
&lt;br&gt;&amp;gt; threads and selectors? Currently the use of seperate NioClient and NioServer
&lt;br&gt;&amp;gt; SocketChannelFactories means, that two disjoint sets of worker threads and
&lt;br&gt;&amp;gt; I/O resources are created. As both these worker pools deliver the exact same
&lt;br&gt;&amp;gt; service, it would be more efficient to avoid the extra threads.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; View this message in context: &lt;a href=&quot;http://n2.nabble.com/Can-you-share-ChannelFactory-worker-threads-in-a-p2p-app-tp4048241p4048241.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://n2.nabble.com/Can-you-share-ChannelFactory-worker-threads-in-a-p2p-app-tp4048241p4048241.html&lt;/a&gt;&lt;br&gt;&amp;gt; Sent from the Netty User Group mailing list archive at Nabble.com.
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; netty-users mailing list
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4048335&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&amp;gt; &lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;netty-users mailing list
&lt;br&gt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4048335&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&lt;div class=&quot;signature&quot;&gt;— Trustin Lee, &lt;a href=&quot;http://gleamynode.net/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://gleamynode.net/&lt;/a&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/Can-you-share-ChannelFactory-worker-threads-in-a-p2p-app-tp4048241p4048335.html" />
	<thr:in-reply-to ref="tag:n2.nabble.com,2006:post-4048241"/>
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4048241</id>
	<title>Can you share ChannelFactory / worker threads in a p2p app?</title>
	<published>2009-11-22T15:42:47Z</published>
	<updated>2009-11-22T15:42:47Z</updated>
	<author>
		<name>Thingfish</name>
	</author>
	<content type="html">Hi
&lt;br&gt;&lt;br&gt;I'm currently in the process of coding a peer 2 peer app on top of Netty. By definition each peer acts as both a server and a client, which means that I currently make use of both the ClientBootstrap and ServerBootstrap &amp;nbsp; to support &amp;quot;connection setup&amp;quot; in both directions. Once established &amp;quot;incomming&amp;quot; and &amp;quot;outgoing&amp;quot; connections are indistinct able, and for this reason they share the same pipeline factory. 
&lt;br&gt;&lt;br&gt;My question is, if its possible to also have them share the same worker threads and selectors? Currently the use of seperate NioClient and NioServer SocketChannelFactories means, that two disjoint sets of worker threads and I/O resources are created. As both these worker pools deliver the exact same service, it would be more efficient to avoid the extra threads.
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/Can-you-share-ChannelFactory-worker-threads-in-a-p2p-app-tp4048241p4048241.html" />
	
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4039723</id>
	<title>Re: Not receiving all data after attempting to close the channel.</title>
	<published>2009-11-20T11:50:14Z</published>
	<updated>2009-11-20T11:50:14Z</updated>
	<author>
		<name>Mike McGrady</name>
	</author>
	<content type="html">Exactly, Stephen. &amp;nbsp;They are apples and oranges, if not apples and &amp;nbsp;
&lt;br&gt;onions.
&lt;br&gt;&lt;br&gt;Mike
&lt;br&gt;&lt;br&gt;On Nov 20, 2009, at 11:27 AM, Stephen Pape wrote:
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I just thought I'd mention that I don't have any problems, with the &amp;nbsp;
&lt;br&gt;&amp;gt; exact
&lt;br&gt;&amp;gt; same code, when I switch to the Oio factory. I don't think that's
&lt;br&gt;&amp;gt; surprising, since writes are blocking in this case.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I still haven't been able to address the issue when using Nio.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; -Stephen
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Stephen Pape wrote:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Hello,
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; I'm having a problem with both 3.2.0.ALPHA1 and 3.1.5.GA (haven't &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; tested
&lt;br&gt;&amp;gt;&amp;gt; other versions).
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Basically, in order to make sure that all pending data is written, &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; I have
&lt;br&gt;&amp;gt;&amp;gt; something like this:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; private volatile ChannelFuture writeFuture = null;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;private volatile Channel channel = null; // Set later
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; public void write(Object obj)
&lt;br&gt;&amp;gt;&amp;gt; {
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; writeFuture = channel.write(obj);
&lt;br&gt;&amp;gt;&amp;gt; }
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; public void close()
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; {
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;If(this.writeFuture != null)
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; this.writeFuture.addListener(this);
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;else
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; this.channel.close();
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; }
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; public void operationComplete(ChannelFuture future)
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; {
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;// Thread.sleep(1000);
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;future.getChannel.close();
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; }
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; This class is being used to write Objects in a loop. Immediately &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; after the
&lt;br&gt;&amp;gt;&amp;gt; loop the close method is called.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; I verified that the correct writeFuture is being used in the close()
&lt;br&gt;&amp;gt;&amp;gt; method,
&lt;br&gt;&amp;gt;&amp;gt; but the remote side is not receiving all of the data. When I write 10
&lt;br&gt;&amp;gt;&amp;gt; objects across, sometimes only 7 or 8 will make it through.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; If I uncomment Thread.sleep(), all of the data is consistently &amp;nbsp;
&lt;br&gt;&amp;gt;&amp;gt; received by
&lt;br&gt;&amp;gt;&amp;gt; the remote side, so it would seem somehow I'm closing the channel too
&lt;br&gt;&amp;gt;&amp;gt; early.
&lt;br&gt;&amp;gt;&amp;gt; Is there something I'm doing wrong?
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Thanks!
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; -Stephen
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt;&amp;gt; netty-users mailing list
&lt;br&gt;&amp;gt;&amp;gt; &lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4039723&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&amp;gt;&amp;gt; &lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; -- 
&lt;br&gt;&amp;gt; View this message in context: &lt;a href=&quot;http://n2.nabble.com/Not-receiving-all-data-after-attempting-to-close-the-channel-tp4033482p4039588.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://n2.nabble.com/Not-receiving-all-data-after-attempting-to-close-the-channel-tp4033482p4039588.html&lt;/a&gt;&lt;br&gt;&amp;gt; Sent from the Netty User Group mailing list archive at Nabble.com.
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; netty-users mailing list
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4039723&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&amp;gt; &lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;/div&gt;&lt;br&gt;Mike McGrady
&lt;br&gt;Principal Investigator AF081-028 AFRL SBIR
&lt;br&gt;Senior Engineer
&lt;br&gt;Topia Technology, Inc
&lt;br&gt;1.253.720.3365
&lt;br&gt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4039723&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;netty-users mailing list
&lt;br&gt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4039723&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/Not-receiving-all-data-after-attempting-to-close-the-channel-tp4033482p4039723.html" />
	<thr:in-reply-to ref="tag:n2.nabble.com,2006:post-4039588"/>
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4039588</id>
	<title>Re: Not receiving all data after attempting to close the channel.</title>
	<published>2009-11-20T11:27:33Z</published>
	<updated>2009-11-20T11:27:33Z</updated>
	<author>
		<name>Stephen Pape</name>
	</author>
	<content type="html">I just thought I'd mention that I don't have any problems, with the exact same code, when I switch to the Oio factory. I don't think that's surprising, since writes are blocking in this case. 
&lt;br&gt;&lt;br&gt;I still haven't been able to address the issue when using Nio.
&lt;br&gt;&lt;br&gt;-Stephen
&lt;br&gt;&lt;br&gt;&lt;blockquote class=&quot;quote light-black dark-border-color&quot;&gt;&lt;div class=&quot;quote light-border-color&quot;&gt;
&lt;div class=&quot;quote-author&quot; style=&quot;font-weight: bold;&quot;&gt;Stephen Pape wrote:&lt;/div&gt;
&lt;div class=&quot;quote-message shrinkable-quote&quot;&gt;Hello,
&lt;br&gt;&lt;br&gt;&amp;nbsp;
&lt;br&gt;&lt;br&gt;I'm having a problem with both 3.2.0.ALPHA1 and 3.1.5.GA (haven't tested
&lt;br&gt;other versions).
&lt;br&gt;&lt;br&gt;&amp;nbsp;
&lt;br&gt;&lt;br&gt;Basically, in order to make sure that all pending data is written, I have
&lt;br&gt;something like this:
&lt;br&gt;&lt;br&gt;&amp;nbsp;
&lt;br&gt;&lt;br&gt;private volatile ChannelFuture writeFuture = null;
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private volatile Channel channel = null; // Set later
&lt;br&gt;&lt;br&gt;&amp;nbsp;
&lt;br&gt;&lt;br&gt;public void write(Object obj)
&lt;br&gt;{
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp;writeFuture = channel.write(obj);
&lt;br&gt;}
&lt;br&gt;&lt;br&gt;&amp;nbsp;
&lt;br&gt;&lt;br&gt;public void close()
&lt;br&gt;&lt;br&gt;{
&lt;br&gt;&lt;br&gt;&amp;nbsp; If(this.writeFuture != null)
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;this.writeFuture.addListener(this);
&lt;br&gt;&lt;br&gt;&amp;nbsp; else 
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;this.channel.close();
&lt;br&gt;&lt;br&gt;}
&lt;br&gt;&lt;br&gt;&amp;nbsp;
&lt;br&gt;&lt;br&gt;public void operationComplete(ChannelFuture future)
&lt;br&gt;&lt;br&gt;{
&lt;br&gt;&lt;br&gt;&amp;nbsp; // Thread.sleep(1000);
&lt;br&gt;&lt;br&gt;&amp;nbsp; future.getChannel.close();
&lt;br&gt;&lt;br&gt;}
&lt;br&gt;&lt;br&gt;&amp;nbsp;
&lt;br&gt;&lt;br&gt;&amp;nbsp;
&lt;br&gt;&lt;br&gt;This class is being used to write Objects in a loop. Immediately after the
&lt;br&gt;loop the close method is called.
&lt;br&gt;&lt;br&gt;&amp;nbsp;
&lt;br&gt;&lt;br&gt;I verified that the correct writeFuture is being used in the close() method,
&lt;br&gt;but the remote side is not receiving all of the data. When I write 10
&lt;br&gt;objects across, sometimes only 7 or 8 will make it through. 
&lt;br&gt;&lt;br&gt;&amp;nbsp;
&lt;br&gt;&lt;br&gt;If I uncomment Thread.sleep(), all of the data is consistently received by
&lt;br&gt;the remote side, so it would seem somehow I'm closing the channel too early.
&lt;br&gt;Is there something I'm doing wrong?
&lt;br&gt;&lt;br&gt;&amp;nbsp;
&lt;br&gt;&lt;br&gt;Thanks!
&lt;br&gt;&lt;br&gt;&amp;nbsp;
&lt;br&gt;&lt;br&gt;-Stephen
&lt;br&gt;&lt;br&gt;&lt;br&gt;&amp;nbsp;
&lt;br&gt;_______________________________________________
&lt;br&gt;netty-users mailing list
&lt;br&gt;netty-users@lists.jboss.org
&lt;br&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;&lt;/blockquote&gt;
</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/Not-receiving-all-data-after-attempting-to-close-the-channel-tp4033482p4039588.html" />
	<thr:in-reply-to ref="tag:n2.nabble.com,2006:post-4033482"/>
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4051709</id>
	<title>RE: Not receiving all data after attempting to close the channel.</title>
	<published>2009-11-23T07:25:07Z</published>
	<updated>2009-11-23T07:25:07Z</updated>
	<author>
		<name>Stephen Pape</name>
	</author>
	<content type="html">Hi Trustin,
&lt;br&gt;&lt;br&gt;I finally narrowed down the problem to be my own.
&lt;br&gt;I had made soLinger a configurable option, and it was initialized to 0 by default. 
&lt;br&gt;&lt;br&gt;For future reference, when it's set to zero:
&lt;br&gt;&amp;quot;
&lt;br&gt;A close() returns immediately. The underlying stack discards any unsent data, and, in the case of connection-oriented protocols such as TCP, sends a RST (reset) to the peer (this is termed a hard or abortive close). All subsequent attempts by the peer's application to read()/recv() data will result in an ECONNRESET.
&lt;br&gt;&amp;quot;
&lt;br&gt;&lt;br&gt;So I'll use a default value of -1 and not call setOption() if the value is still at -1.
&lt;br&gt;&lt;br&gt;Thanks!
&lt;br&gt;&lt;br&gt;-Stephen
&lt;br&gt;&lt;br&gt;-----Original Message-----
&lt;br&gt;From: Trustin Lee [via Netty Forums and Mailing Lists] [mailto:&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4051709&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;] 
&lt;br&gt;Sent: Friday, November 20, 2009 10:26 PM
&lt;br&gt;To: Pape, Stephen R CTR USAF AFMC AFRL/RISE
&lt;br&gt;Subject: Re: Not receiving all data after attempting to close the channel.
&lt;br&gt;&lt;br&gt;Hi Stephen, 
&lt;br&gt;&lt;br&gt;On Fri, Nov 20, 2009 at 4:24 AM, Stephen Pape 
&lt;br&gt;&amp;lt;[hidden email] &amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4041435&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4041435&amp;i=0&lt;/a&gt;&amp;gt; &amp;gt; wrote: 
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Thanks for the reply. Isn't what you're doing essentially the same thing? 
&lt;br&gt;&amp;gt; You're getting notified via operationComplete() that the write was 
&lt;br&gt;&amp;gt; (supposedly) completed, then allowing execution to continue. That seems like 
&lt;br&gt;&amp;gt; what I'm doing, except I immediately close the channel. 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; I found a similar thread about this topic here: 
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://www.jboss.org/netty/community.html#nabble-td3398725&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.jboss.org/netty/community.html#nabble-td3398725&lt;/a&gt;|a3398725 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Trustin Lee wrote: 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; You can achieve this pretty simply: 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; channel.write(ChannelBuffers.EMPTY_BUFFER) 
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.addListener(ChannelFutureListener.CLOSE); 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Given that response, I assumed my method should work. I was doing the same 
&lt;br&gt;&amp;gt; thing, adding a listener to close after the last write completed. I wasn't 
&lt;br&gt;&amp;gt; using an empty buffer because my channel pipeline couldn't accept a 
&lt;br&gt;&amp;gt; ChannelBuffer directly. 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Is there some reason that the channel can't be closed immediately after a 
&lt;br&gt;&amp;gt; write has completed? 
&lt;/div&gt;&lt;/div&gt;I think you are closing the connection properly. &amp;nbsp;I never experienced 
&lt;br&gt;the same problem, but it worths an investigation just in case. &amp;nbsp; Can 
&lt;br&gt;you reproduce the problem with loopback connection? &amp;nbsp;Do you have a 
&lt;br&gt;simple application that reproduces the problem? 
&lt;br&gt;&lt;br&gt;Thanks 
&lt;br&gt;T 
&lt;br&gt;&lt;br&gt;_______________________________________________ 
&lt;br&gt;netty-users mailing list 
&lt;br&gt;[hidden email] &amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4041435&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4041435&amp;i=1&lt;/a&gt;&amp;gt; &amp;nbsp;
&lt;br&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&lt;br&gt;— Trustin Lee, &lt;a href=&quot;http://gleamynode.net/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://gleamynode.net/&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;________________________________
&lt;br&gt;&lt;br&gt;View message @ &lt;a href=&quot;http://n2.nabble.com/Not-receiving-all-data-after-attempting-to-close-the-channel-tp4033482p4041435.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://n2.nabble.com/Not-receiving-all-data-after-attempting-to-close-the-channel-tp4033482p4041435.html&lt;/a&gt;&amp;nbsp;
&lt;br&gt;To unsubscribe from Re: Not receiving all data after attempting to close the channel., click here &amp;lt;&lt;a target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;&amp;lt;Link Removed&amp;gt;&lt;/a&gt;&amp;gt; . 
&lt;br&gt;&lt;br&gt;&lt;br /&gt; &lt;div class=&quot;small&quot;&gt;&lt;br/&gt;&lt;img src=&quot;http://n2.nabble.com/images/icon_attachment.gif&quot; &gt; &lt;strong&gt;smime.p7s&lt;/strong&gt; (6K) &lt;a href=&quot;http://n2.nabble.com/attachment/4051709/0/smime.p7s&quot; target=&quot;_top&quot;&gt;Download Attachment&lt;/a&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/Not-receiving-all-data-after-attempting-to-close-the-channel-tp4033482p4051709.html" />
	<thr:in-reply-to ref="tag:n2.nabble.com,2006:post-4041435"/>
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4041435</id>
	<title>Re: Not receiving all data after attempting to close the channel.</title>
	<published>2009-11-20T19:19:45Z</published>
	<updated>2009-11-20T19:19:45Z</updated>
	<author>
		<name>Trustin Lee</name>
	</author>
	<content type="html">Hi Stephen,
&lt;br&gt;&lt;br&gt;On Fri, Nov 20, 2009 at 4:24 AM, Stephen Pape
&lt;br&gt;&amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4041435&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Thanks for the reply. Isn't what you're doing essentially the same thing?
&lt;br&gt;&amp;gt; You're getting notified via operationComplete() that the write was
&lt;br&gt;&amp;gt; (supposedly) completed, then allowing execution to continue. That seems like
&lt;br&gt;&amp;gt; what I'm doing, except I immediately close the channel.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I found a similar thread about this topic here:
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://www.jboss.org/netty/community.html#nabble-td3398725&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.jboss.org/netty/community.html#nabble-td3398725&lt;/a&gt;|a3398725
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Trustin Lee wrote:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; You can achieve this pretty simply:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;   channel.write(ChannelBuffers.EMPTY_BUFFER)
&lt;br&gt;&amp;gt;&amp;gt;          .addListener(ChannelFutureListener.CLOSE);
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Given that response, I assumed my method should work. I was doing the same
&lt;br&gt;&amp;gt; thing, adding a listener to close after the last write completed. I wasn't
&lt;br&gt;&amp;gt; using an empty buffer because my channel pipeline couldn't accept a
&lt;br&gt;&amp;gt; ChannelBuffer directly.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Is there some reason that the channel can't be closed immediately after a
&lt;br&gt;&amp;gt; write has completed?
&lt;/div&gt;&lt;br&gt;I think you are closing the connection properly. &amp;nbsp;I never experienced
&lt;br&gt;the same problem, but it worths an investigation just in case. &amp;nbsp; Can
&lt;br&gt;you reproduce the problem with loopback connection? &amp;nbsp;Do you have a
&lt;br&gt;simple application that reproduces the problem?
&lt;br&gt;&lt;br&gt;Thanks
&lt;br&gt;T
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;netty-users mailing list
&lt;br&gt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4041435&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&lt;div class=&quot;signature&quot;&gt;— Trustin Lee, &lt;a href=&quot;http://gleamynode.net/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://gleamynode.net/&lt;/a&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/Not-receiving-all-data-after-attempting-to-close-the-channel-tp4033482p4041435.html" />
	<thr:in-reply-to ref="tag:n2.nabble.com,2006:post-4033860"/>
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4034151</id>
	<title>RE: Not receiving all data after attempting to close the channel.</title>
	<published>2009-11-19T12:13:45Z</published>
	<updated>2009-11-19T12:13:45Z</updated>
	<author>
		<name>Stephen Pape</name>
	</author>
	<content type="html">I'm not sure what you mean, as you can see I register a callback for when
&lt;br&gt;the write is supposed to be completed. This should not be closing the
&lt;br&gt;channel before it is done writing... (?)
&lt;br&gt;&lt;br&gt;After the write is *completed* (supposedly), I'm immediately closing the
&lt;br&gt;channel. I don't know why there would be a problem doing this, but it's what
&lt;br&gt;I was asking about.
&lt;br&gt;&lt;br&gt;-Stephen
&lt;br&gt;&lt;br&gt;-----Original Message-----
&lt;br&gt;From: &lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4034151&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;[mailto:&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4034151&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;] On Behalf Of Michael McGrady
&lt;br&gt;Sent: Thursday, November 19, 2009 3:01 PM
&lt;br&gt;To: Netty Users
&lt;br&gt;Subject: Re: Not receiving all data after attempting to close the channel.
&lt;br&gt;&lt;br&gt;Right. &amp;nbsp;If you close the channel before it is done, guess what? &amp;nbsp;It won't
&lt;br&gt;get done. &amp;nbsp;LOL &amp;nbsp;Hope you take this in the light way it is intended. &amp;nbsp;The
&lt;br&gt;serious point is that you have to not close before you are done.
&lt;br&gt;&lt;br&gt;What the difference is between your version and what Trustin suggested I
&lt;br&gt;don't know. &amp;nbsp;I do think I am correct that you cannot close the channel
&lt;br&gt;before it is complete without buggering up the send.
&lt;br&gt;&lt;br&gt;Mike
&lt;br&gt;&lt;br&gt;On Nov 19, 2009, at 11:24 AM, Stephen Pape wrote:
&lt;br&gt;&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Thanks for the reply. Isn't what you're doing essentially the same thing?
&lt;br&gt;&amp;gt; You're getting notified via operationComplete() that the write was
&lt;br&gt;&amp;gt; (supposedly) completed, then allowing execution to continue. That seems
&lt;br&gt;like
&lt;div class='shrinkable-quote'&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; what I'm doing, except I immediately close the channel.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; I found a similar thread about this topic here:
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://www.jboss.org/netty/community.html#nabble-td3398725&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.jboss.org/netty/community.html#nabble-td3398725&lt;/a&gt;|a3398725
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Trustin Lee wrote:
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; You can achieve this pretty simply:
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;channel.write(ChannelBuffers.EMPTY_BUFFER)
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .addListener(ChannelFutureListener.CLOSE);
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Given that response, I assumed my method should work. I was doing the same
&lt;br&gt;&amp;gt; thing, adding a listener to close after the last write completed. I wasn't
&lt;br&gt;&amp;gt; using an empty buffer because my channel pipeline couldn't accept a
&lt;br&gt;&amp;gt; ChannelBuffer directly. 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Is there some reason that the channel can't be closed immediately after a
&lt;br&gt;&amp;gt; write has completed?
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; -Stephen
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Mike McGrady wrote:
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; My solution was to use monitors with the asynchronous Netty
&lt;/div&gt;functionality.
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; Here is the monitor:
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 	private class WriteKarmaManagerMonitor {
&lt;br&gt;&amp;gt;&amp;gt; 		private final AtomicBoolean managerIsSent = new
&lt;/div&gt;AtomicBoolean(false);
&lt;div class='shrinkable-quote'&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 		protected void managerIsSent() {
&lt;br&gt;&amp;gt;&amp;gt; 			this.managerIsSent.set(true);
&lt;br&gt;&amp;gt;&amp;gt; 		}
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 		protected AtomicBoolean isManagerSent() {
&lt;br&gt;&amp;gt;&amp;gt; 			return this.managerIsSent;
&lt;br&gt;&amp;gt;&amp;gt; 		}
&lt;br&gt;&amp;gt;&amp;gt; 	}
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; And here is its use:
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 		while (!this.channel.isWritable()) {
&lt;br&gt;&amp;gt;&amp;gt; 			try {
&lt;br&gt;&amp;gt;&amp;gt; 				Thread.sleep(3);
&lt;br&gt;&amp;gt;&amp;gt; 			} catch (InterruptedException e) {
&lt;br&gt;&amp;gt;&amp;gt; 				logger.log(InternalLogLevel.ERROR,
&lt;/div&gt;e.getMessage());
&lt;br&gt;&amp;gt;&amp;gt; 			}
&lt;br&gt;&amp;gt;&amp;gt; 		}
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 		ChannelFuture future = this.channel.write(buffer);
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 		future.addListener(new ChannelFutureListener() {
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 			public void operationComplete(ChannelFuture future)
&lt;/div&gt;{
&lt;br&gt;&amp;gt;&amp;gt; 				// Notify that snnd is complete monitor.
&lt;br&gt;&amp;gt;&amp;gt; 				synchronized
&lt;br&gt;(NettyKarmaSender.this.writeManagerMonitor) {
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;NettyKarmaSender.this.writeManagerMonitor.managerIsSent();
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;NettyKarmaSender.this.writeManagerMonitor.notifyAll();
&lt;div class='shrinkable-quote'&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;&amp;gt; 					NettyKarmaSender.this.managerSent++;
&lt;br&gt;&amp;gt;&amp;gt; 					count++;
&lt;br&gt;&amp;gt;&amp;gt; 				}
&lt;br&gt;&amp;gt;&amp;gt; 			}
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 		});
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 		// Make sure manager is written before proceeding.
&lt;br&gt;&amp;gt;&amp;gt; 		synchronized (this.writeManagerMonitor) {
&lt;br&gt;&amp;gt;&amp;gt; 			if (!this.writeManagerMonitor.isManagerSent().get())
&lt;/div&gt;{
&lt;br&gt;&amp;gt;&amp;gt; 				try {
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 					this.writeManagerMonitor.wait();
&lt;br&gt;&amp;gt;&amp;gt; 				} catch (InterruptedException e) {
&lt;br&gt;&amp;gt;&amp;gt; 					logger.log(InternalLogLevel.ERROR,
&lt;/div&gt;e.getMessage());
&lt;div class='shrinkable-quote'&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;&amp;gt; 				}
&lt;br&gt;&amp;gt;&amp;gt; 			}
&lt;br&gt;&amp;gt;&amp;gt; 		}
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; From: &amp;quot;Pape, Stephen R CTR USAF AFMC AFRL/RISE&amp;quot;
&lt;br&gt;&amp;gt;&amp;gt; &amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4034151&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Date: November 19, 2009 7:24:17 AM PST
&lt;br&gt;&amp;gt;&amp;gt; To: &amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4034151&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Subject: Not receiving all data after attempting to close the channel.
&lt;br&gt;&amp;gt;&amp;gt; Reply-To: Netty Users &amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4034151&amp;i=4&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; Hello,
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; I'm having a problem with both 3.2.0.ALPHA1 and 3.1.5.GA (haven't tested
&lt;br&gt;&amp;gt;&amp;gt; other versions).
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; Basically, in order to make sure that all pending data is written, I have
&lt;br&gt;&amp;gt;&amp;gt; something like this:
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; private volatile ChannelFuture writeFuture = null;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;private volatile Channel channel = null; // Set later
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; public void write(Object obj)
&lt;br&gt;&amp;gt;&amp;gt; {
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; writeFuture = channel.write(obj);
&lt;br&gt;&amp;gt;&amp;gt; }
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; public void close()
&lt;br&gt;&amp;gt;&amp;gt; {
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;If(this.writeFuture != null)
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; this.writeFuture.addListener(this);
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;else
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; this.channel.close();
&lt;br&gt;&amp;gt;&amp;gt; }
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; public void operationComplete(ChannelFuture future)
&lt;br&gt;&amp;gt;&amp;gt; {
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;// Thread.sleep(1000);
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;future.getChannel.close();
&lt;br&gt;&amp;gt;&amp;gt; }
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; This class is being used to write Objects in a loop. Immediately after
&lt;/div&gt;the
&lt;br&gt;&amp;gt;&amp;gt; loop the close method is called.
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; I verified that the correct writeFuture is being used in the close()
&lt;br&gt;&amp;gt;&amp;gt; method, but the remote side is not receiving all of the data. When I
&lt;/div&gt;write
&lt;br&gt;&amp;gt;&amp;gt; 10 objects across, sometimes only 7 or 8 will make it through.
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; If I uncomment Thread.sleep(), all of the data is consistently received
&lt;br&gt;by
&lt;div class='shrinkable-quote'&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;&amp;gt; the remote side, so it would seem somehow I'm closing the channel too
&lt;br&gt;&amp;gt;&amp;gt; early. Is there something I'm doing wrong?
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; Thanks!
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; -Stephen
&lt;br&gt;&amp;gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt;&amp;gt; netty-users mailing list
&lt;br&gt;&amp;gt;&amp;gt; &lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4034151&amp;i=5&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&amp;gt;&amp;gt; &lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; From: &amp;quot;Pape, Stephen R CTR USAF AFMC AFRL/RISE&amp;quot;
&lt;br&gt;&amp;gt;&amp;gt; &amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4034151&amp;i=6&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Date: November 19, 2009 7:24:17 AM PST
&lt;br&gt;&amp;gt;&amp;gt; To: &amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4034151&amp;i=7&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Subject: Not receiving all data after attempting to close the channel.
&lt;br&gt;&amp;gt;&amp;gt; Reply-To: Netty Users &amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4034151&amp;i=8&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; Hello,
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; I'm having a problem with both 3.2.0.ALPHA1 and 3.1.5.GA (haven't tested
&lt;br&gt;&amp;gt;&amp;gt; other versions).
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; Basically, in order to make sure that all pending data is written, I have
&lt;br&gt;&amp;gt;&amp;gt; something like this:
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; private volatile ChannelFuture writeFuture = null;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;private volatile Channel channel = null; // Set later
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; public void write(Object obj)
&lt;br&gt;&amp;gt;&amp;gt; {
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; writeFuture = channel.write(obj);
&lt;br&gt;&amp;gt;&amp;gt; }
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; public void close()
&lt;br&gt;&amp;gt;&amp;gt; {
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;If(this.writeFuture != null)
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; this.writeFuture.addListener(this);
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;else
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; this.channel.close();
&lt;br&gt;&amp;gt;&amp;gt; }
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; public void operationComplete(ChannelFuture future)
&lt;br&gt;&amp;gt;&amp;gt; {
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;// Thread.sleep(1000);
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;future.getChannel.close();
&lt;br&gt;&amp;gt;&amp;gt; }
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; This class is being used to write Objects in a loop. Immediately after
&lt;/div&gt;the
&lt;br&gt;&amp;gt;&amp;gt; loop the close method is called.
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; I verified that the correct writeFuture is being used in the close()
&lt;br&gt;&amp;gt;&amp;gt; method, but the remote side is not receiving all of the data. When I
&lt;/div&gt;write
&lt;br&gt;&amp;gt;&amp;gt; 10 objects across, sometimes only 7 or 8 will make it through.
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; If I uncomment Thread.sleep(), all of the data is consistently received
&lt;br&gt;by
&lt;div class='shrinkable-quote'&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;&amp;gt; the remote side, so it would seem somehow I'm closing the channel too
&lt;br&gt;&amp;gt;&amp;gt; early. Is there something I'm doing wrong?
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; Thanks!
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; -Stephen
&lt;br&gt;&amp;gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt;&amp;gt; netty-users mailing list
&lt;br&gt;&amp;gt;&amp;gt; &lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4034151&amp;i=9&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&amp;gt;&amp;gt; &lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; On Nov 19, 2009, at 7:24 AM, Pape, Stephen R CTR USAF AFMC AFRL/RISE
&lt;br&gt;&amp;gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; Hello,
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; I'm having a problem with both 3.2.0.ALPHA1 and 3.1.5.GA (haven't tested
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; other versions).
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; Basically, in order to make sure that all pending data is written, I
&lt;/div&gt;have
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; something like this:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; private volatile ChannelFuture writeFuture = null;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;private volatile Channel channel = null; // Set later
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; public void write(Object obj)
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; {
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp; writeFuture = channel.write(obj);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; }
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; public void close()
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; {
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp;If(this.writeFuture != null)
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; this.writeFuture.addListener(this);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp;else
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; this.channel.close();
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; }
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; public void operationComplete(ChannelFuture future)
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; {
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp;// Thread.sleep(1000);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp;future.getChannel.close();
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; }
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; This class is being used to write Objects in a loop. Immediately after
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; the loop the close method is called.
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; I verified that the correct writeFuture is being used in the close()
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; method, but the remote side is not receiving all of the data. When I
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; write 10 objects across, sometimes only 7 or 8 will make it through.
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; If I uncomment Thread.sleep(), all of the data is consistently received
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; by the remote side, so it would seem somehow I'm closing the channel too
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; early. Is there something I'm doing wrong?
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; Thanks!
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; -Stephen
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; netty-users mailing list
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4034151&amp;i=10&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt;&amp;gt; netty-users mailing list
&lt;br&gt;&amp;gt;&amp;gt; &lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4034151&amp;i=11&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&amp;gt;&amp;gt; &lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; -- 
&lt;br&gt;&amp;gt; View this message in context:
&lt;/div&gt;&lt;a href=&quot;http://n2.nabble.com/Not-receiving-all-data-after-attempting-to-close-the-ch&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://n2.nabble.com/Not-receiving-all-data-after-attempting-to-close-the-ch&lt;/a&gt;&lt;/div&gt;annel-tp4033482p4033860.html
&lt;br&gt;&amp;gt; Sent from the Netty User Group mailing list archive at Nabble.com.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; netty-users mailing list
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4034151&amp;i=12&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&amp;gt; &lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&lt;br&gt;Mike McGrady
&lt;br&gt;Principal Investigator AF081-028 AFRL SBIR
&lt;br&gt;Senior Engineer
&lt;br&gt;Topia Technology, Inc
&lt;br&gt;1.253.720.3365
&lt;br&gt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4034151&amp;i=13&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;netty-users mailing list
&lt;br&gt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4034151&amp;i=14&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&lt;br /&gt; &lt;br /&gt;_______________________________________________
&lt;br&gt;netty-users mailing list
&lt;br&gt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4034151&amp;i=15&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&lt;div class=&quot;small&quot;&gt;&lt;br/&gt;&lt;img src=&quot;http://n2.nabble.com/images/icon_attachment.gif&quot; &gt; &lt;strong&gt;smime.p7s&lt;/strong&gt; (6K) &lt;a href=&quot;http://n2.nabble.com/attachment/4034151/0/smime.p7s&quot; target=&quot;_top&quot;&gt;Download Attachment&lt;/a&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/Not-receiving-all-data-after-attempting-to-close-the-channel-tp4033482p4034151.html" />
	<thr:in-reply-to ref="tag:n2.nabble.com,2006:post-4034088"/>
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4034088</id>
	<title>Re: Not receiving all data after attempting to close the channel.</title>
	<published>2009-11-19T12:00:56Z</published>
	<updated>2009-11-19T12:00:56Z</updated>
	<author>
		<name>Mike McGrady</name>
	</author>
	<content type="html">Right. &amp;nbsp;If you close the channel before it is done, guess what? &amp;nbsp;It won't get done. &amp;nbsp;LOL &amp;nbsp;Hope you take this in the light way it is intended. &amp;nbsp;The serious point is that you have to not close before you are done.
&lt;br&gt;&lt;br&gt;What the difference is between your version and what Trustin suggested I don't know. &amp;nbsp;I do think I am correct that you cannot close the channel before it is complete without buggering up the send.
&lt;br&gt;&lt;br&gt;Mike
&lt;br&gt;&lt;br&gt;On Nov 19, 2009, at 11:24 AM, Stephen Pape wrote:
&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Thanks for the reply. Isn't what you're doing essentially the same thing?
&lt;br&gt;&amp;gt; You're getting notified via operationComplete() that the write was
&lt;br&gt;&amp;gt; (supposedly) completed, then allowing execution to continue. That seems like
&lt;br&gt;&amp;gt; what I'm doing, except I immediately close the channel.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; I found a similar thread about this topic here:
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://www.jboss.org/netty/community.html#nabble-td3398725&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.jboss.org/netty/community.html#nabble-td3398725&lt;/a&gt;|a3398725
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Trustin Lee wrote:
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; You can achieve this pretty simply:
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;channel.write(ChannelBuffers.EMPTY_BUFFER)
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .addListener(ChannelFutureListener.CLOSE);
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Given that response, I assumed my method should work. I was doing the same
&lt;br&gt;&amp;gt; thing, adding a listener to close after the last write completed. I wasn't
&lt;br&gt;&amp;gt; using an empty buffer because my channel pipeline couldn't accept a
&lt;br&gt;&amp;gt; ChannelBuffer directly. 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Is there some reason that the channel can't be closed immediately after a
&lt;br&gt;&amp;gt; write has completed?
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; -Stephen
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; Mike McGrady wrote:
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; My solution was to use monitors with the asynchronous Netty functionality.
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; Here is the monitor:
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 	private class WriteKarmaManagerMonitor {
&lt;br&gt;&amp;gt;&amp;gt; 		private final AtomicBoolean managerIsSent = new AtomicBoolean(false);
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 		protected void managerIsSent() {
&lt;br&gt;&amp;gt;&amp;gt; 			this.managerIsSent.set(true);
&lt;br&gt;&amp;gt;&amp;gt; 		}
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 		protected AtomicBoolean isManagerSent() {
&lt;br&gt;&amp;gt;&amp;gt; 			return this.managerIsSent;
&lt;br&gt;&amp;gt;&amp;gt; 		}
&lt;br&gt;&amp;gt;&amp;gt; 	}
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; And here is its use:
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 		while (!this.channel.isWritable()) {
&lt;br&gt;&amp;gt;&amp;gt; 			try {
&lt;br&gt;&amp;gt;&amp;gt; 				Thread.sleep(3);
&lt;br&gt;&amp;gt;&amp;gt; 			} catch (InterruptedException e) {
&lt;br&gt;&amp;gt;&amp;gt; 				logger.log(InternalLogLevel.ERROR, e.getMessage());
&lt;br&gt;&amp;gt;&amp;gt; 			}
&lt;br&gt;&amp;gt;&amp;gt; 		}
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 		ChannelFuture future = this.channel.write(buffer);
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 		future.addListener(new ChannelFutureListener() {
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 			public void operationComplete(ChannelFuture future) {
&lt;br&gt;&amp;gt;&amp;gt; 				// Notify that snnd is complete monitor.
&lt;br&gt;&amp;gt;&amp;gt; 				synchronized (NettyKarmaSender.this.writeManagerMonitor) {
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 					NettyKarmaSender.this.writeManagerMonitor.managerIsSent();
&lt;br&gt;&amp;gt;&amp;gt; 					NettyKarmaSender.this.writeManagerMonitor.notifyAll();
&lt;br&gt;&amp;gt;&amp;gt; 					NettyKarmaSender.this.managerSent++;
&lt;br&gt;&amp;gt;&amp;gt; 					count++;
&lt;br&gt;&amp;gt;&amp;gt; 				}
&lt;br&gt;&amp;gt;&amp;gt; 			}
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 		});
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 		// Make sure manager is written before proceeding.
&lt;br&gt;&amp;gt;&amp;gt; 		synchronized (this.writeManagerMonitor) {
&lt;br&gt;&amp;gt;&amp;gt; 			if (!this.writeManagerMonitor.isManagerSent().get()) {
&lt;br&gt;&amp;gt;&amp;gt; 				try {
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 					this.writeManagerMonitor.wait();
&lt;br&gt;&amp;gt;&amp;gt; 				} catch (InterruptedException e) {
&lt;br&gt;&amp;gt;&amp;gt; 					logger.log(InternalLogLevel.ERROR, e.getMessage());
&lt;br&gt;&amp;gt;&amp;gt; 				}
&lt;br&gt;&amp;gt;&amp;gt; 			}
&lt;br&gt;&amp;gt;&amp;gt; 		}
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; From: &amp;quot;Pape, Stephen R CTR USAF AFMC AFRL/RISE&amp;quot;
&lt;br&gt;&amp;gt;&amp;gt; &amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4034088&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Date: November 19, 2009 7:24:17 AM PST
&lt;br&gt;&amp;gt;&amp;gt; To: &amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4034088&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Subject: Not receiving all data after attempting to close the channel.
&lt;br&gt;&amp;gt;&amp;gt; Reply-To: Netty Users &amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4034088&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; Hello,
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; I’m having a problem with both 3.2.0.ALPHA1 and 3.1.5.GA (haven’t tested
&lt;br&gt;&amp;gt;&amp;gt; other versions).
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; Basically, in order to make sure that all pending data is written, I have
&lt;br&gt;&amp;gt;&amp;gt; something like this:
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; private volatile ChannelFuture writeFuture = null;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;private volatile Channel channel = null; // Set later
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; public void write(Object obj)
&lt;br&gt;&amp;gt;&amp;gt; {
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; writeFuture = channel.write(obj);
&lt;br&gt;&amp;gt;&amp;gt; }
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; public void close()
&lt;br&gt;&amp;gt;&amp;gt; {
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;If(this.writeFuture != null)
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; this.writeFuture.addListener(this);
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;else
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; this.channel.close();
&lt;br&gt;&amp;gt;&amp;gt; }
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; public void operationComplete(ChannelFuture future)
&lt;br&gt;&amp;gt;&amp;gt; {
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;// Thread.sleep(1000);
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;future.getChannel.close();
&lt;br&gt;&amp;gt;&amp;gt; }
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; This class is being used to write Objects in a loop. Immediately after the
&lt;br&gt;&amp;gt;&amp;gt; loop the close method is called.
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; I verified that the correct writeFuture is being used in the close()
&lt;br&gt;&amp;gt;&amp;gt; method, but the remote side is not receiving all of the data. When I write
&lt;br&gt;&amp;gt;&amp;gt; 10 objects across, sometimes only 7 or 8 will make it through.
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; If I uncomment Thread.sleep(), all of the data is consistently received by
&lt;br&gt;&amp;gt;&amp;gt; the remote side, so it would seem somehow I’m closing the channel too
&lt;br&gt;&amp;gt;&amp;gt; early. Is there something I’m doing wrong?
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; Thanks!
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; -Stephen
&lt;br&gt;&amp;gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt;&amp;gt; netty-users mailing list
&lt;br&gt;&amp;gt;&amp;gt; &lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4034088&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&amp;gt;&amp;gt; &lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; From: &amp;quot;Pape, Stephen R CTR USAF AFMC AFRL/RISE&amp;quot;
&lt;br&gt;&amp;gt;&amp;gt; &amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4034088&amp;i=4&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Date: November 19, 2009 7:24:17 AM PST
&lt;br&gt;&amp;gt;&amp;gt; To: &amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4034088&amp;i=5&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Subject: Not receiving all data after attempting to close the channel.
&lt;br&gt;&amp;gt;&amp;gt; Reply-To: Netty Users &amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4034088&amp;i=6&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; Hello,
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; I’m having a problem with both 3.2.0.ALPHA1 and 3.1.5.GA (haven’t tested
&lt;br&gt;&amp;gt;&amp;gt; other versions).
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; Basically, in order to make sure that all pending data is written, I have
&lt;br&gt;&amp;gt;&amp;gt; something like this:
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; private volatile ChannelFuture writeFuture = null;
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;private volatile Channel channel = null; // Set later
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; public void write(Object obj)
&lt;br&gt;&amp;gt;&amp;gt; {
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; writeFuture = channel.write(obj);
&lt;br&gt;&amp;gt;&amp;gt; }
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; public void close()
&lt;br&gt;&amp;gt;&amp;gt; {
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;If(this.writeFuture != null)
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; this.writeFuture.addListener(this);
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;else
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; this.channel.close();
&lt;br&gt;&amp;gt;&amp;gt; }
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; public void operationComplete(ChannelFuture future)
&lt;br&gt;&amp;gt;&amp;gt; {
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;// Thread.sleep(1000);
&lt;br&gt;&amp;gt;&amp;gt; &amp;nbsp;future.getChannel.close();
&lt;br&gt;&amp;gt;&amp;gt; }
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; This class is being used to write Objects in a loop. Immediately after the
&lt;br&gt;&amp;gt;&amp;gt; loop the close method is called.
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; I verified that the correct writeFuture is being used in the close()
&lt;br&gt;&amp;gt;&amp;gt; method, but the remote side is not receiving all of the data. When I write
&lt;br&gt;&amp;gt;&amp;gt; 10 objects across, sometimes only 7 or 8 will make it through.
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; If I uncomment Thread.sleep(), all of the data is consistently received by
&lt;br&gt;&amp;gt;&amp;gt; the remote side, so it would seem somehow I’m closing the channel too
&lt;br&gt;&amp;gt;&amp;gt; early. Is there something I’m doing wrong?
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; Thanks!
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; -Stephen
&lt;br&gt;&amp;gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt;&amp;gt; netty-users mailing list
&lt;br&gt;&amp;gt;&amp;gt; &lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4034088&amp;i=7&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&amp;gt;&amp;gt; &lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; On Nov 19, 2009, at 7:24 AM, Pape, Stephen R CTR USAF AFMC AFRL/RISE
&lt;br&gt;&amp;gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; Hello,
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; I’m having a problem with both 3.2.0.ALPHA1 and 3.1.5.GA (haven’t tested
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; other versions).
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; Basically, in order to make sure that all pending data is written, I have
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; something like this:
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; private volatile ChannelFuture writeFuture = null;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;private volatile Channel channel = null; // Set later
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; public void write(Object obj)
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; {
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp; writeFuture = channel.write(obj);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; }
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; public void close()
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; {
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp;If(this.writeFuture != null)
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; this.writeFuture.addListener(this);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp;else
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp; &amp;nbsp; this.channel.close();
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; }
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; public void operationComplete(ChannelFuture future)
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; {
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp;// Thread.sleep(1000);
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &amp;nbsp;future.getChannel.close();
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; }
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; This class is being used to write Objects in a loop. Immediately after
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; the loop the close method is called.
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; I verified that the correct writeFuture is being used in the close()
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; method, but the remote side is not receiving all of the data. When I
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; write 10 objects across, sometimes only 7 or 8 will make it through.
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; If I uncomment Thread.sleep(), all of the data is consistently received
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; by the remote side, so it would seem somehow I’m closing the channel too
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; early. Is there something I’m doing wrong?
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; Thanks!
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; -Stephen
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; netty-users mailing list
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4034088&amp;i=8&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&amp;gt;&amp;gt;&amp;gt; &lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt;&amp;gt; netty-users mailing list
&lt;br&gt;&amp;gt;&amp;gt; &lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4034088&amp;i=9&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&amp;gt;&amp;gt; &lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt;&amp;gt; 
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; -- 
&lt;br&gt;&amp;gt; View this message in context: &lt;a href=&quot;http://n2.nabble.com/Not-receiving-all-data-after-attempting-to-close-the-channel-tp4033482p4033860.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://n2.nabble.com/Not-receiving-all-data-after-attempting-to-close-the-channel-tp4033482p4033860.html&lt;/a&gt;&lt;br&gt;&amp;gt; Sent from the Netty User Group mailing list archive at Nabble.com.
&lt;br&gt;&amp;gt; 
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; netty-users mailing list
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4034088&amp;i=10&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&amp;gt; &lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;/div&gt;&lt;br&gt;Mike McGrady
&lt;br&gt;Principal Investigator AF081-028 AFRL SBIR
&lt;br&gt;Senior Engineer
&lt;br&gt;Topia Technology, Inc
&lt;br&gt;1.253.720.3365
&lt;br&gt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4034088&amp;i=11&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;netty-users mailing list
&lt;br&gt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4034088&amp;i=12&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/Not-receiving-all-data-after-attempting-to-close-the-channel-tp4033482p4034088.html" />
	<thr:in-reply-to ref="tag:n2.nabble.com,2006:post-4033860"/>
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4033860</id>
	<title>Re: Not receiving all data after attempting to close the channel.</title>
	<published>2009-11-19T11:24:43Z</published>
	<updated>2009-11-19T11:24:43Z</updated>
	<author>
		<name>Stephen Pape</name>
	</author>
	<content type="html">Thanks for the reply. Isn't what you're doing essentially the same thing? You're getting notified via operationComplete() that the write was (supposedly) completed, then allowing execution to continue. That seems like what I'm doing, except I immediately close the channel.
&lt;br&gt;&lt;br&gt;I found a similar thread about this topic here: &lt;a href=&quot;http://www.jboss.org/netty/community.html#nabble-td3398725&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.jboss.org/netty/community.html#nabble-td3398725&lt;/a&gt;|a3398725
&lt;br&gt;&lt;br&gt;&lt;blockquote class=&quot;quote light-black dark-border-color&quot;&gt;&lt;div class=&quot;quote light-border-color&quot;&gt;
&lt;div class=&quot;quote-author&quot; style=&quot;font-weight: bold;&quot;&gt;Trustin Lee wrote:&lt;/div&gt;
&lt;div class=&quot;quote-message&quot;&gt;You can achieve this pretty simply:
&lt;br&gt;&lt;br&gt;&amp;nbsp; channel.write(ChannelBuffers.EMPTY_BUFFER)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.addListener(ChannelFutureListener.CLOSE);
&lt;/div&gt;
&lt;/div&gt;&lt;/blockquote&gt;
Given that response, I assumed my method should work. I was doing the same thing, adding a listener to close after the last write completed. I wasn't using an empty buffer because my channel pipeline couldn't accept a ChannelBuffer directly. 
&lt;br&gt;&lt;br&gt;Is there some reason that the channel can't be closed immediately after a write has completed?
&lt;br&gt;&lt;br&gt;-Stephen
&lt;br&gt;&lt;br&gt;&lt;blockquote class=&quot;quote light-black dark-border-color&quot;&gt;&lt;div class=&quot;quote light-border-color&quot;&gt;
&lt;div class=&quot;quote-author&quot; style=&quot;font-weight: bold;&quot;&gt;Mike McGrady wrote:&lt;/div&gt;
&lt;div class=&quot;quote-message shrinkable-quote&quot;&gt;My solution was to use monitors with the asynchronous Netty functionality.
&lt;br&gt;&lt;br&gt;Here is the monitor:
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private class WriteKarmaManagerMonitor {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private final AtomicBoolean managerIsSent = new AtomicBoolean(false);
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; protected void managerIsSent() {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.managerIsSent.set(true);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; protected AtomicBoolean isManagerSent() {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return this.managerIsSent;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&lt;br&gt;And here is its use:
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; while (!this.channel.isWritable()) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Thread.sleep(3);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } catch (InterruptedException e) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; logger.log(InternalLogLevel.ERROR, e.getMessage());
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ChannelFuture future = this.channel.write(buffer);
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; future.addListener(new ChannelFutureListener() {
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public void operationComplete(ChannelFuture future) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Notify that snnd is complete monitor.
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; synchronized (NettyKarmaSender.this.writeManagerMonitor) {
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; NettyKarmaSender.this.writeManagerMonitor.managerIsSent();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; NettyKarmaSender.this.writeManagerMonitor.notifyAll();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; NettyKarmaSender.this.managerSent++;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; count++;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; });
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Make sure manager is written before proceeding.
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; synchronized (this.writeManagerMonitor) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (!this.writeManagerMonitor.isManagerSent().get()) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try {
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.writeManagerMonitor.wait();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } catch (InterruptedException e) {
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; logger.log(InternalLogLevel.ERROR, e.getMessage());
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&lt;br&gt;&lt;br&gt;From: &amp;quot;Pape, Stephen R CTR USAF AFMC AFRL/RISE&amp;quot; &amp;lt;Stephen.Pape.ctr@RL.af.mil&amp;gt;
&lt;br&gt;Date: November 19, 2009 7:24:17 AM PST
&lt;br&gt;To: &amp;lt;netty-users@lists.jboss.org&amp;gt;
&lt;br&gt;Subject: Not receiving all data after attempting to close the channel.
&lt;br&gt;Reply-To: Netty Users &amp;lt;netty-users@lists.jboss.org&amp;gt;
&lt;br&gt;&lt;br&gt;Hello,
&lt;br&gt;&amp;nbsp;
&lt;br&gt;I’m having a problem with both 3.2.0.ALPHA1 and 3.1.5.GA (haven’t tested other versions).
&lt;br&gt;&amp;nbsp;
&lt;br&gt;Basically, in order to make sure that all pending data is written, I have something like this:
&lt;br&gt;&amp;nbsp;
&lt;br&gt;private volatile ChannelFuture writeFuture = null;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private volatile Channel channel = null; // Set later
&lt;br&gt;&amp;nbsp;
&lt;br&gt;public void write(Object obj)
&lt;br&gt;{
&lt;br&gt;&amp;nbsp; &amp;nbsp;writeFuture = channel.write(obj);
&lt;br&gt;}
&lt;br&gt;&amp;nbsp;
&lt;br&gt;public void close()
&lt;br&gt;{
&lt;br&gt;&amp;nbsp; If(this.writeFuture != null)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;this.writeFuture.addListener(this);
&lt;br&gt;&amp;nbsp; else
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;this.channel.close();
&lt;br&gt;}
&lt;br&gt;&amp;nbsp;
&lt;br&gt;public void operationComplete(ChannelFuture future)
&lt;br&gt;{
&lt;br&gt;&amp;nbsp; // Thread.sleep(1000);
&lt;br&gt;&amp;nbsp; future.getChannel.close();
&lt;br&gt;}
&lt;br&gt;&amp;nbsp;
&lt;br&gt;&amp;nbsp;
&lt;br&gt;This class is being used to write Objects in a loop. Immediately after the loop the close method is called.
&lt;br&gt;&amp;nbsp;
&lt;br&gt;I verified that the correct writeFuture is being used in the close() method, but the remote side is not receiving all of the data. When I write 10 objects across, sometimes only 7 or 8 will make it through.
&lt;br&gt;&amp;nbsp;
&lt;br&gt;If I uncomment Thread.sleep(), all of the data is consistently received by the remote side, so it would seem somehow I’m closing the channel too early. Is there something I’m doing wrong?
&lt;br&gt;&amp;nbsp;
&lt;br&gt;Thanks!
&lt;br&gt;&amp;nbsp;
&lt;br&gt;-Stephen
&lt;br&gt;_______________________________________________
&lt;br&gt;netty-users mailing list
&lt;br&gt;netty-users@lists.jboss.org
&lt;br&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;From: &amp;quot;Pape, Stephen R CTR USAF AFMC AFRL/RISE&amp;quot; &amp;lt;Stephen.Pape.ctr@RL.af.mil&amp;gt;
&lt;br&gt;Date: November 19, 2009 7:24:17 AM PST
&lt;br&gt;To: &amp;lt;netty-users@lists.jboss.org&amp;gt;
&lt;br&gt;Subject: Not receiving all data after attempting to close the channel.
&lt;br&gt;Reply-To: Netty Users &amp;lt;netty-users@lists.jboss.org&amp;gt;
&lt;br&gt;&lt;br&gt;Hello,
&lt;br&gt;&amp;nbsp;
&lt;br&gt;I’m having a problem with both 3.2.0.ALPHA1 and 3.1.5.GA (haven’t tested other versions).
&lt;br&gt;&amp;nbsp;
&lt;br&gt;Basically, in order to make sure that all pending data is written, I have something like this:
&lt;br&gt;&amp;nbsp;
&lt;br&gt;private volatile ChannelFuture writeFuture = null;
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private volatile Channel channel = null; // Set later
&lt;br&gt;&amp;nbsp;
&lt;br&gt;public void write(Object obj)
&lt;br&gt;{
&lt;br&gt;&amp;nbsp; &amp;nbsp;writeFuture = channel.write(obj);
&lt;br&gt;}
&lt;br&gt;&amp;nbsp;
&lt;br&gt;public void close()
&lt;br&gt;{
&lt;br&gt;&amp;nbsp; If(this.writeFuture != null)
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;this.writeFuture.addListener(this);
&lt;br&gt;&amp;nbsp; else
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;this.channel.close();
&lt;br&gt;}
&lt;br&gt;&amp;nbsp;
&lt;br&gt;public void operationComplete(ChannelFuture future)
&lt;br&gt;{
&lt;br&gt;&amp;nbsp; // Thread.sleep(1000);
&lt;br&gt;&amp;nbsp; future.getChannel.close();
&lt;br&gt;}
&lt;br&gt;&amp;nbsp;
&lt;br&gt;&amp;nbsp;
&lt;br&gt;This class is being used to write Objects in a loop. Immediately after the loop the close method is called.
&lt;br&gt;&amp;nbsp;
&lt;br&gt;I verified that the correct writeFuture is being used in the close() method, but the remote side is not receiving all of the data. When I write 10 objects across, sometimes only 7 or 8 will make it through.
&lt;br&gt;&amp;nbsp;
&lt;br&gt;If I uncomment Thread.sleep(), all of the data is consistently received by the remote side, so it would seem somehow I’m closing the channel too early. Is there something I’m doing wrong?
&lt;br&gt;&amp;nbsp;
&lt;br&gt;Thanks!
&lt;br&gt;&amp;nbsp;
&lt;br&gt;-Stephen
&lt;br&gt;_______________________________________________
&lt;br&gt;netty-users mailing list
&lt;br&gt;netty-users@lists.jboss.org
&lt;br&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;On Nov 19, 2009, at 7:24 AM, Pape, Stephen R CTR USAF AFMC AFRL/RISE wrote:
&lt;br&gt;&lt;br&gt;&amp;gt; Hello,
&lt;br&gt;&amp;gt; &amp;nbsp;
&lt;br&gt;&amp;gt; I’m having a problem with both 3.2.0.ALPHA1 and 3.1.5.GA (haven’t tested other versions).
&lt;br&gt;&amp;gt; &amp;nbsp;
&lt;br&gt;&amp;gt; Basically, in order to make sure that all pending data is written, I have something like this:
&lt;br&gt;&amp;gt; &amp;nbsp;
&lt;br&gt;&amp;gt; private volatile ChannelFuture writeFuture = null;
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private volatile Channel channel = null; // Set later
&lt;br&gt;&amp;gt; &amp;nbsp;
&lt;br&gt;&amp;gt; public void write(Object obj)
&lt;br&gt;&amp;gt; {
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp;writeFuture = channel.write(obj);
&lt;br&gt;&amp;gt; }
&lt;br&gt;&amp;gt; &amp;nbsp;
&lt;br&gt;&amp;gt; public void close()
&lt;br&gt;&amp;gt; {
&lt;br&gt;&amp;gt; &amp;nbsp; If(this.writeFuture != null)
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;this.writeFuture.addListener(this);
&lt;br&gt;&amp;gt; &amp;nbsp; else
&lt;br&gt;&amp;gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;this.channel.close();
&lt;br&gt;&amp;gt; }
&lt;br&gt;&amp;gt; &amp;nbsp;
&lt;br&gt;&amp;gt; public void operationComplete(ChannelFuture future)
&lt;br&gt;&amp;gt; {
&lt;br&gt;&amp;gt; &amp;nbsp; // Thread.sleep(1000);
&lt;br&gt;&amp;gt; &amp;nbsp; future.getChannel.close();
&lt;br&gt;&amp;gt; }
&lt;br&gt;&amp;gt; &amp;nbsp;
&lt;br&gt;&amp;gt; &amp;nbsp;
&lt;br&gt;&amp;gt; This class is being used to write Objects in a loop. Immediately after the loop the close method is called.
&lt;br&gt;&amp;gt; &amp;nbsp;
&lt;br&gt;&amp;gt; I verified that the correct writeFuture is being used in the close() method, but the remote side is not receiving all of the data. When I write 10 objects across, sometimes only 7 or 8 will make it through.
&lt;br&gt;&amp;gt; &amp;nbsp;
&lt;br&gt;&amp;gt; If I uncomment Thread.sleep(), all of the data is consistently received by the remote side, so it would seem somehow I’m closing the channel too early. Is there something I’m doing wrong?
&lt;br&gt;&amp;gt; &amp;nbsp;
&lt;br&gt;&amp;gt; Thanks!
&lt;br&gt;&amp;gt; &amp;nbsp;
&lt;br&gt;&amp;gt; -Stephen
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; netty-users mailing list
&lt;br&gt;&amp;gt; netty-users@lists.jboss.org
&lt;br&gt;&amp;gt; &lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;netty-users mailing list
&lt;br&gt;netty-users@lists.jboss.org
&lt;br&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;&lt;/blockquote&gt;
</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/Not-receiving-all-data-after-attempting-to-close-the-channel-tp4033482p4033860.html" />
	<thr:in-reply-to ref="tag:n2.nabble.com,2006:post-4033766"/>
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4033766</id>
	<title>Re: Not receiving all data after attempting to close the channel.</title>
	<published>2009-11-19T10:59:41Z</published>
	<updated>2009-11-19T10:59:41Z</updated>
	<author>
		<name>Mike McGrady</name>
	</author>
	<content type="html">&lt;base href=&quot;x-msg://24/&quot;&gt;My solution was to use monitors with the asynchronous Netty functionality.&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Here is the monitor:&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; min-height: 15px; &quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; min-height: 15px; &quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;&lt;span style=&quot;color: #931a68&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #931a68&quot;&gt;class&lt;/span&gt; WriteKarmaManagerMonitor {&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;&lt;span style=&quot;color: #931a68&quot;&gt;private&lt;/span&gt; &lt;span style=&quot;color: #931a68&quot;&gt;final&lt;/span&gt; AtomicBoolean &lt;span style=&quot;color: #0326cc&quot;&gt;managerIsSent&lt;/span&gt; = &lt;span style=&quot;color: #931a68&quot;&gt;new&lt;/span&gt; AtomicBoolean(&lt;span style=&quot;color: #931a68&quot;&gt;false&lt;/span&gt;);&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; min-height: 15px; &quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;&lt;span style=&quot;color: #931a68&quot;&gt;protected&lt;/span&gt; &lt;span style=&quot;color: #931a68&quot;&gt;void&lt;/span&gt; managerIsSent() {&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(3, 38, 204); &quot;&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #931a68&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #000000&quot;&gt;.&lt;/span&gt;managerIsSent&lt;span style=&quot;color: #000000&quot;&gt;.set(&lt;/span&gt;&lt;span style=&quot;color: #931a68&quot;&gt;true&lt;/span&gt;&lt;span style=&quot;color: #000000&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; min-height: 15px; &quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;&lt;span style=&quot;color: #931a68&quot;&gt;protected&lt;/span&gt; AtomicBoolean isManagerSent() {&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(3, 38, 204); &quot;&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #931a68&quot;&gt;return&lt;/span&gt;&lt;span style=&quot;color: #000000&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #931a68&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #000000&quot;&gt;.&lt;/span&gt;managerIsSent&lt;span style=&quot;color: #000000&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;	&lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;And here is its use:&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; min-height: 15px; &quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; min-height: 15px; &quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;&lt;span style=&quot;color: #931a68&quot;&gt;while&lt;/span&gt; (!&lt;span style=&quot;color: #931a68&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #0326cc&quot;&gt;channel&lt;/span&gt;.isWritable()) {&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;&lt;span style=&quot;color: #931a68&quot;&gt;try&lt;/span&gt; {&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;Thread.sleep(3);&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;} &lt;span style=&quot;color: #931a68&quot;&gt;catch&lt;/span&gt; (InterruptedException e) {&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;&lt;span style=&quot;color: #0326cc&quot;&gt;logger&lt;/span&gt;.log(InternalLogLevel.&lt;span style=&quot;color: #0326cc&quot;&gt;ERROR&lt;/span&gt;, e.getMessage());&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; min-height: 15px; &quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;ChannelFuture future = &lt;span style=&quot;color: #931a68&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #0326cc&quot;&gt;channel&lt;/span&gt;.write(buffer);&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; min-height: 15px; &quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;future.addListener(&lt;span style=&quot;color: #931a68&quot;&gt;new&lt;/span&gt; ChannelFutureListener() {&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; min-height: 15px; &quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;&lt;span style=&quot;color: #931a68&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #931a68&quot;&gt;void&lt;/span&gt; operationComplete(ChannelFuture future) {&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(78, 144, 114); &quot;&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;&lt;/span&gt;// Notify that snnd is complete monitor.&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;&lt;span style=&quot;color: #931a68&quot;&gt;synchronized&lt;/span&gt; (NettyKarmaSender.&lt;span style=&quot;color: #931a68&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #0326cc&quot;&gt;writeManagerMonitor&lt;/span&gt;) {&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; min-height: 15px; &quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;					&lt;/span&gt;NettyKarmaSender.&lt;span style=&quot;color: #931a68&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #0326cc&quot;&gt;writeManagerMonitor&lt;/span&gt;.managerIsSent();&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;					&lt;/span&gt;NettyKarmaSender.&lt;span style=&quot;color: #931a68&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #0326cc&quot;&gt;writeManagerMonitor&lt;/span&gt;.notifyAll();&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;					&lt;/span&gt;NettyKarmaSender.&lt;span style=&quot;color: #931a68&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #0326cc&quot;&gt;managerSent&lt;/span&gt;++;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;					&lt;/span&gt;&lt;span style=&quot;color: #0326cc&quot;&gt;count&lt;/span&gt;++;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; min-height: 15px; &quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;});&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; min-height: 15px; &quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(78, 144, 114); &quot;&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;&lt;/span&gt;// Make sure manager is written before proceeding.&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(3, 38, 204); &quot;&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #931a68&quot;&gt;synchronized&lt;/span&gt;&lt;span style=&quot;color: #000000&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;color: #931a68&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #000000&quot;&gt;.&lt;/span&gt;writeManagerMonitor&lt;span style=&quot;color: #000000&quot;&gt;) {&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;&lt;span style=&quot;color: #931a68&quot;&gt;if&lt;/span&gt; (!&lt;span style=&quot;color: #931a68&quot;&gt;this&lt;/span&gt;.&lt;span style=&quot;color: #0326cc&quot;&gt;writeManagerMonitor&lt;/span&gt;.isManagerSent().get()) {&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;&lt;span style=&quot;color: #931a68&quot;&gt;try&lt;/span&gt; {&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; min-height: 15px; &quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(3, 38, 204); &quot;&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;					&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #931a68&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #000000&quot;&gt;.&lt;/span&gt;writeManagerMonitor&lt;span style=&quot;color: #000000&quot;&gt;.wait();&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;} &lt;span style=&quot;color: #931a68&quot;&gt;catch&lt;/span&gt; (InterruptedException e) {&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;					&lt;/span&gt;&lt;span style=&quot;color: #0326cc&quot;&gt;logger&lt;/span&gt;.log(InternalLogLevel.&lt;span style=&quot;color: #0326cc&quot;&gt;ERROR&lt;/span&gt;, e.getMessage());&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;				&lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;			&lt;/span&gt;}&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; &quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space:pre&quot;&gt;		&lt;/span&gt;}&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 37px; text-indent: -37px; font: normal normal normal 12px/normal Helvetica; &quot;&gt;&lt;span style=&quot;color: #7f7f7f&quot;&gt;&lt;b&gt;From: &lt;/b&gt;&lt;/span&gt;&quot;Pape, Stephen R CTR USAF AFMC AFRL/RISE&quot; &amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4033766&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 34px; text-indent: -34px; font: normal normal normal 12px/normal Helvetica; &quot;&gt;&lt;span style=&quot;color: #7f7f7f&quot;&gt;&lt;b&gt;Date: &lt;/b&gt;&lt;/span&gt;November 19, 2009 7:24:17 AM PST&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 21px; text-indent: -21px; font: normal normal normal 12px/normal Helvetica; &quot;&gt;&lt;span style=&quot;color: #7f7f7f&quot;&gt;&lt;b&gt;To: &lt;/b&gt;&lt;/span&gt;&amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4033766&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 50px; text-indent: -50px; font: normal normal normal 12px/normal Helvetica; &quot;&gt;&lt;span style=&quot;color: #7f7f7f&quot;&gt;&lt;b&gt;Subject: &lt;/b&gt;&lt;/span&gt;&lt;b&gt;Not receiving all data after attempting to close the channel.&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 58px; text-indent: -58px; font: normal normal normal 12px/normal Helvetica; &quot;&gt;&lt;span style=&quot;color: #7f7f7f&quot;&gt;&lt;b&gt;Reply-To: &lt;/b&gt;&lt;/span&gt;Netty Users &amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4033766&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; min-height: 14px; &quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 15px/normal Calibri; &quot;&gt;Hello,&lt;/div&gt;&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Calibri&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 15px/normal Calibri; &quot;&gt;I’m having a problem with both 3.2.0.ALPHA1 and 3.1.5.GA (haven’t tested other versions).&lt;/div&gt;&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Calibri&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 15px/normal Calibri; &quot;&gt;Basically, in order to make sure that all pending data is written, I have something like this:&lt;/div&gt;&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Calibri&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 48px; font: normal normal normal 15px/normal Calibri; &quot;&gt;private volatile ChannelFuture writeFuture = null;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 15px/normal Calibri; &quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private volatile Channel channel = null; // Set later&lt;/div&gt;&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Calibri&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 48px; font: normal normal normal 15px/normal Calibri; &quot;&gt;public void write(Object obj)&lt;br&gt;
{&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 48px; font: normal normal normal 15px/normal Calibri; &quot;&gt;&amp;nbsp;&amp;nbsp; writeFuture = channel.write(obj);&lt;br&gt;
}&lt;/div&gt;&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Calibri&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 48px; font: normal normal normal 15px/normal Calibri; &quot;&gt;public void close()&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 48px; font: normal normal normal 15px/normal Calibri; &quot;&gt;{&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 48px; font: normal normal normal 15px/normal Calibri; &quot;&gt;&amp;nbsp;&amp;nbsp;If(this.writeFuture != null)&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 48px; font: normal normal normal 15px/normal Calibri; &quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;this.writeFuture.addListener(this);&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 48px; font: normal normal normal 15px/normal Calibri; &quot;&gt;&amp;nbsp; else&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 48px; font: normal normal normal 15px/normal Calibri; &quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.channel.close();&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 48px; font: normal normal normal 15px/normal Calibri; &quot;&gt;}&lt;/div&gt;&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 48.0px; font: 15.0px Calibri&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 48px; font: normal normal normal 15px/normal Calibri; &quot;&gt;public void operationComplete(ChannelFuture future)&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 48px; font: normal normal normal 15px/normal Calibri; &quot;&gt;{&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 48px; font: normal normal normal 15px/normal Calibri; &quot;&gt;&amp;nbsp; // Thread.sleep(1000);&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 48px; font: normal normal normal 15px/normal Calibri; &quot;&gt;&amp;nbsp; future.getChannel.close();&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 48px; font: normal normal normal 15px/normal Calibri; &quot;&gt;}&lt;/div&gt;&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Calibri&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Calibri&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 15px/normal Calibri; &quot;&gt;This class is being used to write Objects in a loop. Immediately after the loop the close method is called.&lt;/div&gt;&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Calibri&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 15px/normal Calibri; &quot;&gt;I verified that the correct writeFuture is being used in the close() method, but the remote side is not receiving all of the data. When I write 10 objects across, sometimes only 7 or 8 will make it through.&lt;/div&gt;&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Calibri&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 15px/normal Calibri; &quot;&gt;If I uncomment Thread.sleep(), all of the data is consistently received by the remote side, so it would seem somehow I’m closing the channel too early. Is there something I’m doing wrong?&lt;/div&gt;&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Calibri&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 15px/normal Calibri; &quot;&gt;Thanks!&lt;/div&gt;&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Calibri&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 15px/normal Calibri; &quot;&gt;-Stephen&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; &quot;&gt;_______________________________________________&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; &quot;&gt;netty-users mailing list&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; &quot;&gt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4033766&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; &quot;&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 37px; text-indent: -37px; font: normal normal normal 12px/normal Helvetica; &quot;&gt;&lt;span style=&quot;color: #7f7f7f&quot;&gt;&lt;b&gt;From: &lt;/b&gt;&lt;/span&gt;&quot;Pape, Stephen R CTR USAF AFMC AFRL/RISE&quot; &amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4033766&amp;i=4&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 34px; text-indent: -34px; font: normal normal normal 12px/normal Helvetica; &quot;&gt;&lt;span style=&quot;color: #7f7f7f&quot;&gt;&lt;b&gt;Date: &lt;/b&gt;&lt;/span&gt;November 19, 2009 7:24:17 AM PST&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 21px; text-indent: -21px; font: normal normal normal 12px/normal Helvetica; &quot;&gt;&lt;span style=&quot;color: #7f7f7f&quot;&gt;&lt;b&gt;To: &lt;/b&gt;&lt;/span&gt;&amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4033766&amp;i=5&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 50px; text-indent: -50px; font: normal normal normal 12px/normal Helvetica; &quot;&gt;&lt;span style=&quot;color: #7f7f7f&quot;&gt;&lt;b&gt;Subject: &lt;/b&gt;&lt;/span&gt;&lt;b&gt;Not receiving all data after attempting to close the channel.&lt;/b&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 58px; text-indent: -58px; font: normal normal normal 12px/normal Helvetica; &quot;&gt;&lt;span style=&quot;color: #7f7f7f&quot;&gt;&lt;b&gt;Reply-To: &lt;/b&gt;&lt;/span&gt;Netty Users &amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4033766&amp;i=6&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; min-height: 14px; &quot;&gt;&lt;br&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 15px/normal Calibri; &quot;&gt;Hello,&lt;/div&gt;&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Calibri&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 15px/normal Calibri; &quot;&gt;I’m having a problem with both 3.2.0.ALPHA1 and 3.1.5.GA (haven’t tested other versions).&lt;/div&gt;&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Calibri&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 15px/normal Calibri; &quot;&gt;Basically, in order to make sure that all pending data is written, I have something like this:&lt;/div&gt;&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Calibri&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 48px; font: normal normal normal 15px/normal Calibri; &quot;&gt;private volatile ChannelFuture writeFuture = null;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 15px/normal Calibri; &quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private volatile Channel channel = null; // Set later&lt;/div&gt;&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Calibri&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 48px; font: normal normal normal 15px/normal Calibri; &quot;&gt;public void write(Object obj)&lt;br&gt;
{&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 48px; font: normal normal normal 15px/normal Calibri; &quot;&gt;&amp;nbsp;&amp;nbsp; writeFuture = channel.write(obj);&lt;br&gt;
}&lt;/div&gt;&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Calibri&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 48px; font: normal normal normal 15px/normal Calibri; &quot;&gt;public void close()&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 48px; font: normal normal normal 15px/normal Calibri; &quot;&gt;{&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 48px; font: normal normal normal 15px/normal Calibri; &quot;&gt;&amp;nbsp;&amp;nbsp;If(this.writeFuture != null)&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 48px; font: normal normal normal 15px/normal Calibri; &quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;this.writeFuture.addListener(this);&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 48px; font: normal normal normal 15px/normal Calibri; &quot;&gt;&amp;nbsp; else&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 48px; font: normal normal normal 15px/normal Calibri; &quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.channel.close();&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 48px; font: normal normal normal 15px/normal Calibri; &quot;&gt;}&lt;/div&gt;&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 48.0px; font: 15.0px Calibri&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 48px; font: normal normal normal 15px/normal Calibri; &quot;&gt;public void operationComplete(ChannelFuture future)&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 48px; font: normal normal normal 15px/normal Calibri; &quot;&gt;{&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 48px; font: normal normal normal 15px/normal Calibri; &quot;&gt;&amp;nbsp; // Thread.sleep(1000);&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 48px; font: normal normal normal 15px/normal Calibri; &quot;&gt;&amp;nbsp; future.getChannel.close();&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 48px; font: normal normal normal 15px/normal Calibri; &quot;&gt;}&lt;/div&gt;&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Calibri&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Calibri&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 15px/normal Calibri; &quot;&gt;This class is being used to write Objects in a loop. Immediately after the loop the close method is called.&lt;/div&gt;&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Calibri&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 15px/normal Calibri; &quot;&gt;I verified that the correct writeFuture is being used in the close() method, but the remote side is not receiving all of the data. When I write 10 objects across, sometimes only 7 or 8 will make it through.&lt;/div&gt;&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Calibri&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 15px/normal Calibri; &quot;&gt;If I uncomment Thread.sleep(), all of the data is consistently received by the remote side, so it would seem somehow I’m closing the channel too early. Is there something I’m doing wrong?&lt;/div&gt;&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Calibri&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 15px/normal Calibri; &quot;&gt;Thanks!&lt;/div&gt;&lt;p style=&quot;margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Calibri&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 15px/normal Calibri; &quot;&gt;-Stephen&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; &quot;&gt;_______________________________________________&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; &quot;&gt;netty-users mailing list&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; &quot;&gt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4033766&amp;i=7&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 12px/normal Helvetica; &quot;&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;On Nov 19, 2009, at 7:24 AM, Pape, Stephen R CTR USAF AFMC AFRL/RISE wrote:&lt;/div&gt;&lt;br class=&quot;Apple-interchange-newline&quot;&gt;&lt;blockquote type=&quot;cite&quot;&gt;&lt;div lang=&quot;EN-US&quot; link=&quot;blue&quot; vlink=&quot;purple&quot;&gt;&lt;div class=&quot;Section1&quot;&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;Hello,&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;I’m having a problem with both 3.2.0.ALPHA1 and 3.1.5.GA (haven’t tested other versions).&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;Basically, in order to make sure that all pending data is written, I have something like this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0.5in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;private volatile ChannelFuture writeFuture = null;&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private volatile Channel channel = null; // Set later&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0.5in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;public void write(Object obj)&lt;br&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0.5in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;&amp;nbsp;&amp;nbsp; writeFuture = channel.write(obj);&lt;br&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0.5in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;public void close()&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0.5in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0.5in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;&amp;nbsp;&amp;nbsp;If(this.writeFuture != null)&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0.5in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;this.writeFuture.addListener(this);&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0.5in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;&amp;nbsp; else&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0.5in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.channel.close();&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0.5in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0.5in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0.5in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;public void operationComplete(ChannelFuture future)&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0.5in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0.5in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;&amp;nbsp; // Thread.sleep(1000);&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0.5in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;&amp;nbsp; future.getChannel.close();&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0.5in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;This class is being used to write Objects in a loop. Immediately after the loop the close method is called.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;I verified that the correct writeFuture is being used in the close() method, but the remote side is not receiving all of the data. When I write 10 objects across, sometimes only 7 or 8 will make it through.&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;If I uncomment Thread.sleep(), all of the data is consistently received by the remote side, so it would seem somehow I’m closing the channel too early. Is there something I’m doing wrong?&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;Thanks!&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/div&gt;&lt;div style=&quot;margin-top: 0in; margin-right: 0in; margin-bottom: 0.0001pt; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif; &quot;&gt;-Stephen&lt;o:p&gt;&lt;/o:p&gt;&lt;/div&gt;&lt;/div&gt;_______________________________________________&lt;br&gt;netty-users mailing list&lt;br&gt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4033766&amp;i=8&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&lt;br&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; style=&quot;color: blue; text-decoration: underline; &quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;br&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;_______________________________________________
&lt;br&gt;netty-users mailing list
&lt;br&gt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4033766&amp;i=9&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/Not-receiving-all-data-after-attempting-to-close-the-channel-tp4033482p4033766.html" />
	<thr:in-reply-to ref="tag:n2.nabble.com,2006:post-4033482"/>
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4033482</id>
	<title>Not receiving all data after attempting to close the channel.</title>
	<published>2009-11-19T07:24:17Z</published>
	<updated>2009-11-19T07:24:17Z</updated>
	<author>
		<name>Stephen Pape</name>
	</author>
	<content type="html">


&lt;META HTTP-EQUIV=&quot;Content-Type&quot; CONTENT=&quot;text/html; charset=us-ascii&quot;&gt;
&lt;meta name=Generator content=&quot;Microsoft Word 12 (filtered medium)&quot;&gt;

&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
 &lt;o:shapedefaults v:ext=&quot;edit&quot; spidmax=&quot;1026&quot; /&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
 &lt;o:shapelayout v:ext=&quot;edit&quot;&gt;
  &lt;o:idmap v:ext=&quot;edit&quot; data=&quot;1&quot; /&gt;
 &lt;/o:shapelayout&gt;&lt;/xml&gt;&lt;![endif]--&gt;




&lt;div class=Section1&gt;

&lt;p class=MsoNormal&gt;Hello,&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;I&amp;#8217;m having a problem with both 3.2.0.ALPHA1 and 3.1.5.GA
(haven&amp;#8217;t tested other versions).&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;Basically, in order to make sure that all pending data is
written, I have something like this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-left:.5in'&gt;private volatile ChannelFuture
writeFuture = null;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; private volatile Channel channel = null; //
Set later&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-left:.5in'&gt;public void write(Object obj)&lt;br&gt;
{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-left:.5in'&gt;&amp;nbsp;&amp;nbsp; writeFuture =
channel.write(obj);&lt;br&gt;
}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-left:.5in'&gt;public void close()&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-left:.5in'&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-left:.5in'&gt;&amp;nbsp;&amp;nbsp;If(this.writeFuture != null)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-left:.5in'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;this.writeFuture.addListener(this);&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-left:.5in'&gt;&amp;nbsp; else &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-left:.5in'&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.channel.close();&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-left:.5in'&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-left:.5in'&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-left:.5in'&gt;public void operationComplete(ChannelFuture
future)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-left:.5in'&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-left:.5in'&gt;&amp;nbsp; // Thread.sleep(1000);&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-left:.5in'&gt;&amp;nbsp; future.getChannel.close();&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal style='margin-left:.5in'&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;This class is being used to write Objects in a loop.
Immediately after the loop the close method is called.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;I verified that the correct writeFuture is being used in the
close() method, but the remote side is not receiving all of the data. When I
write 10 objects across, sometimes only 7 or 8 will make it through. &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;If I uncomment Thread.sleep(), all of the data is consistently
received by the remote side, so it would seem somehow I&amp;#8217;m closing the
channel too early. Is there something I&amp;#8217;m doing wrong?&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;Thanks!&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;

&lt;p class=MsoNormal&gt;-Stephen&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;

&lt;/div&gt;




&lt;br /&gt; &lt;br /&gt;_______________________________________________
&lt;br&gt;netty-users mailing list
&lt;br&gt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4033482&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&lt;div class=&quot;small&quot;&gt;&lt;br/&gt;&lt;img src=&quot;http://n2.nabble.com/images/icon_attachment.gif&quot; &gt; &lt;strong&gt;smime.p7s&lt;/strong&gt; (6K) &lt;a href=&quot;http://n2.nabble.com/attachment/4033482/0/smime.p7s&quot; target=&quot;_top&quot;&gt;Download Attachment&lt;/a&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/Not-receiving-all-data-after-attempting-to-close-the-channel-tp4033482p4033482.html" />
	
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4041680</id>
	<title>Re: synchronous client send/rcv help</title>
	<published>2009-11-20T21:03:36Z</published>
	<updated>2009-11-20T21:03:36Z</updated>
	<author>
		<name>Trustin Lee</name>
	</author>
	<content type="html">Hi Jason,
&lt;br&gt;&lt;br&gt;I would not suggest using a lock or semaphore. &amp;nbsp;The most efficient way
&lt;br&gt;is to design the state machine carefully so that the premature write
&lt;br&gt;request is not made at all. &amp;nbsp;If it is not easy to implement, you can
&lt;br&gt;store the write requests in the queue while handshake is in progress,
&lt;br&gt;and then flush them all after the handshake.
&lt;br&gt;&lt;br&gt;HTH
&lt;br&gt;&lt;br&gt;— Trustin Lee, &lt;a href=&quot;http://gleamynode.net/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://gleamynode.net/&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;On Thu, Nov 19, 2009 at 7:24 AM, Jason Ward &amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4041680&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; I'm looking for some advice on a good design for the following problem.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I have a need to perform an app-level handshake once the channel is
&lt;br&gt;&amp;gt; connected. I've implemented this via a handshake method call fired from
&lt;br&gt;&amp;gt; the channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) of
&lt;br&gt;&amp;gt; my IoHandler (extending SimpleChannelUpstreamHandler).
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; The crux of the issue is a need for this app-level handshake to occur
&lt;br&gt;&amp;gt; synchronously blocking each subsequent send (in the handshake) until a
&lt;br&gt;&amp;gt; previous response from the peer is rcvd and validated. I've found that
&lt;br&gt;&amp;gt; blocking during my handshake method in fact blocks the I/O thread
&lt;br&gt;&amp;gt; altogether. I can see the peer actually receives the req and sends a
&lt;br&gt;&amp;gt; response, but a corresponding messageReceived(ChannelHandlerContext ctx,
&lt;br&gt;&amp;gt; MessageEvent e) isn't fired until after my originating caller times
&lt;br&gt;&amp;gt; out... which just so happens to initiate a disconnect and disposal of
&lt;br&gt;&amp;gt; resources as well.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I can easily workaround this issue by chaining messageReceived
&lt;br&gt;&amp;gt; callbacks, but I'm looking for a more elegant solution. Does anyone have
&lt;br&gt;&amp;gt; advice on how I can pull this off? Is there any example of how to force
&lt;br&gt;&amp;gt; only some requests to be blocking? I've seen the thread on the forum
&lt;br&gt;&amp;gt; where Trustin indicates adding a LinkedBlockingQueue is a solution, but
&lt;br&gt;&amp;gt; the original poster's use-case is quite different from mine in that all
&lt;br&gt;&amp;gt; requests needed to be blocking, and as best I understand it, I'm
&lt;br&gt;&amp;gt; effectively doing the same thing but creating a problem because I'm
&lt;br&gt;&amp;gt; calling my blocking method from channelConnected()... altho I might be
&lt;br&gt;&amp;gt; totally wrong.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Any advice is greatly appreciated.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Note : Because this might be a simple problem with my I/O thread pools,
&lt;br&gt;&amp;gt; I'll include my client code here (only slightly redacted for protected
&lt;br&gt;&amp;gt; info).
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;            ClientSocketChannelFactory factory = new
&lt;br&gt;&amp;gt; NioClientSocketChannelFactory(
&lt;br&gt;&amp;gt;                    Executors.newCachedThreadPool(new
&lt;br&gt;&amp;gt; NamedThreadFactory(&amp;quot;NioClientSocketChannelFactoryBoss_&amp;quot;+name)),
&lt;br&gt;&amp;gt;                    Executors.newCachedThreadPool(new
&lt;br&gt;&amp;gt; NamedThreadFactory(&amp;quot;NioClientSocketChannelFactory_&amp;quot;+name))
&lt;br&gt;&amp;gt;            );
&lt;br&gt;&amp;gt;            bootstrap = new ClientBootstrap(factory);
&lt;br&gt;&amp;gt;            bootstrap.setOption(&amp;quot;tcpNoDelay&amp;quot;, true);
&lt;br&gt;&amp;gt;            bootstrap.setOption(&amp;quot;keepAlive&amp;quot;, true);
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;            OrderedMemoryAwareThreadPoolExecutor threadPool = new
&lt;br&gt;&amp;gt; OrderedMemoryAwareThreadPoolExecutor(
&lt;br&gt;&amp;gt;                    corePoolSize, 0, 0, keepAliveTime, TimeUnit.SECONDS,
&lt;br&gt;&amp;gt; new NamedThreadFactory(&amp;quot;XXX&amp;quot;+name));
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;            ChannelPipeline pipeline = bootstrap.getPipeline();
&lt;br&gt;&amp;gt;            pipeline.addLast(&amp;quot;exec&amp;quot;, new ExecutionHandler(threadPool));
&lt;br&gt;&amp;gt;            pipeline.addLast(&amp;quot;decoder&amp;quot;, new AsyncMSGIoDecoder());
&lt;br&gt;&amp;gt;            pipeline.addLast(&amp;quot;encoder&amp;quot;, new AsyncMSGIoEncoder());
&lt;br&gt;&amp;gt;            pipeline.addLast(&amp;quot;handler&amp;quot;, new MSGIoHandler(this));
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;            channelFuture = bootstrap.connect(new
&lt;br&gt;&amp;gt; InetSocketAddress(host, port));
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Thanks in advance,
&lt;br&gt;&amp;gt; JW
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; netty-users mailing list
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4041680&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&amp;gt; &lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;netty-users mailing list
&lt;br&gt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4041680&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&lt;div class=&quot;signature&quot;&gt;— Trustin Lee, &lt;a href=&quot;http://gleamynode.net/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://gleamynode.net/&lt;/a&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/synchronous-client-send-rcv-help-tp4028785p4041680.html" />
	<thr:in-reply-to ref="tag:n2.nabble.com,2006:post-4028785"/>
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4028785</id>
	<title>synchronous client send/rcv help</title>
	<published>2009-11-18T14:24:44Z</published>
	<updated>2009-11-18T14:24:44Z</updated>
	<author>
		<name>Jason Ward-6</name>
	</author>
	<content type="html">I'm looking for some advice on a good design for the following problem.
&lt;br&gt;&lt;br&gt;I have a need to perform an app-level handshake once the channel is 
&lt;br&gt;connected. I've implemented this via a handshake method call fired from 
&lt;br&gt;the channelConnected(ChannelHandlerContext ctx, ChannelStateEvent e) of 
&lt;br&gt;my IoHandler (extending SimpleChannelUpstreamHandler).
&lt;br&gt;&lt;br&gt;The crux of the issue is a need for this app-level handshake to occur 
&lt;br&gt;synchronously blocking each subsequent send (in the handshake) until a 
&lt;br&gt;previous response from the peer is rcvd and validated. I've found that 
&lt;br&gt;blocking during my handshake method in fact blocks the I/O thread 
&lt;br&gt;altogether. I can see the peer actually receives the req and sends a 
&lt;br&gt;response, but a corresponding messageReceived(ChannelHandlerContext ctx, 
&lt;br&gt;MessageEvent e) isn't fired until after my originating caller times 
&lt;br&gt;out... which just so happens to initiate a disconnect and disposal of 
&lt;br&gt;resources as well.
&lt;br&gt;&lt;br&gt;I can easily workaround this issue by chaining messageReceived 
&lt;br&gt;callbacks, but I'm looking for a more elegant solution. Does anyone have 
&lt;br&gt;advice on how I can pull this off? Is there any example of how to force 
&lt;br&gt;only some requests to be blocking? I've seen the thread on the forum 
&lt;br&gt;where Trustin indicates adding a LinkedBlockingQueue is a solution, but 
&lt;br&gt;the original poster's use-case is quite different from mine in that all 
&lt;br&gt;requests needed to be blocking, and as best I understand it, I'm 
&lt;br&gt;effectively doing the same thing but creating a problem because I'm 
&lt;br&gt;calling my blocking method from channelConnected()... altho I might be 
&lt;br&gt;totally wrong.
&lt;br&gt;&lt;br&gt;&lt;br&gt;Any advice is greatly appreciated.
&lt;br&gt;&lt;br&gt;&lt;br&gt;Note : Because this might be a simple problem with my I/O thread pools, 
&lt;br&gt;I'll include my client code here (only slightly redacted for protected 
&lt;br&gt;info).
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ClientSocketChannelFactory factory = new 
&lt;br&gt;NioClientSocketChannelFactory(
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Executors.newCachedThreadPool(new 
&lt;br&gt;NamedThreadFactory(&amp;quot;NioClientSocketChannelFactoryBoss_&amp;quot;+name)),
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Executors.newCachedThreadPool(new 
&lt;br&gt;NamedThreadFactory(&amp;quot;NioClientSocketChannelFactory_&amp;quot;+name))
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; );
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; bootstrap = new ClientBootstrap(factory);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; bootstrap.setOption(&amp;quot;tcpNoDelay&amp;quot;, true);
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; bootstrap.setOption(&amp;quot;keepAlive&amp;quot;, true);
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; OrderedMemoryAwareThreadPoolExecutor threadPool = new 
&lt;br&gt;OrderedMemoryAwareThreadPoolExecutor(
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; corePoolSize, 0, 0, keepAliveTime, TimeUnit.SECONDS, 
&lt;br&gt;new NamedThreadFactory(&amp;quot;XXX&amp;quot;+name));
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ChannelPipeline pipeline = bootstrap.getPipeline();
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pipeline.addLast(&amp;quot;exec&amp;quot;, new ExecutionHandler(threadPool));
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pipeline.addLast(&amp;quot;decoder&amp;quot;, new AsyncMSGIoDecoder());
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pipeline.addLast(&amp;quot;encoder&amp;quot;, new AsyncMSGIoEncoder());
&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pipeline.addLast(&amp;quot;handler&amp;quot;, new MSGIoHandler(this));
&lt;br&gt;&lt;br&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; channelFuture = bootstrap.connect(new 
&lt;br&gt;InetSocketAddress(host, port));
&lt;br&gt;&lt;br&gt;&lt;br&gt;Thanks in advance,
&lt;br&gt;JW
&lt;br&gt;_______________________________________________
&lt;br&gt;netty-users mailing list
&lt;br&gt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4028785&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/synchronous-client-send-rcv-help-tp4028785p4028785.html" />
	
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4041973</id>
	<title>Re: Postponing of ChunkedWriteHandlers hasNextChunk retrieval after  write operation</title>
	<published>2009-11-21T00:12:47Z</published>
	<updated>2009-11-21T00:12:47Z</updated>
	<author>
		<name>Trustin Lee</name>
	</author>
	<content type="html">Hi Tuomas,
&lt;br&gt;&lt;br&gt;On Wed, Nov 18, 2009 at 9:01 PM, Tuomas Kiviaho &amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4041973&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I was having a deadlock in my simple unit test using PipedInputStream and
&lt;br&gt;&amp;gt; PipedOutputStream with ChunkedWriteHandler. I discovered that
&lt;br&gt;&amp;gt; ChunkedWriteHandler checks for next chunk prior writing out the current
&lt;br&gt;&amp;gt; chunk.
&lt;br&gt;&lt;br&gt;Are you mentioning the 182nd line of ChunkedWriteHandler that calls
&lt;br&gt;ChunkedInput.hasNextChunk()? &amp;nbsp;It would be nice if you could include
&lt;br&gt;the full thread dump.
&lt;br&gt;&lt;br&gt;&amp;gt; What if next chunk check is postponed after write operation? It doesn't seem
&lt;br&gt;&amp;gt; to be impossible at first glance but I guess there's a good reason for this
&lt;br&gt;&amp;gt; kind of implementation.
&lt;br&gt;&lt;br&gt;Yes, the next chunk check could be postponed after Channels.write(...)
&lt;br&gt;call at line 214. &amp;nbsp;However, before making the modification, I'd like
&lt;br&gt;to know why dead lock occurs.
&lt;br&gt;&lt;br&gt;Thanks
&lt;br&gt;— Trustin Lee, &lt;a href=&quot;http://gleamynode.net/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://gleamynode.net/&lt;/a&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;netty-users mailing list
&lt;br&gt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4041973&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&lt;div class=&quot;signature&quot;&gt;— Trustin Lee, &lt;a href=&quot;http://gleamynode.net/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://gleamynode.net/&lt;/a&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/Postponing-of-ChunkedWriteHandlers-hasNextChunk-retrieval-after-write-operation-tp4024971p4041973.html" />
	<thr:in-reply-to ref="tag:n2.nabble.com,2006:post-4024971"/>
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4024971</id>
	<title>Postponing of ChunkedWriteHandlers hasNextChunk retrieval after write operation</title>
	<published>2009-11-18T04:01:33Z</published>
	<updated>2009-11-18T04:01:33Z</updated>
	<author>
		<name>Tuomas Kiviaho</name>
	</author>
	<content type="html">I was having a deadlock in my simple unit test sing PipedInputStream and PipedOutputStream with ChunkedWriteHandler. I discovered that ChunkedWriteHandler checks for next chunk prior writing out the current chunk. 
&lt;br&gt;&lt;br&gt;What if next chunk check is postponed after write operation? It doesn't seem to be impossible at first glance but I guess there's a good reason for this kind of implementation.
&lt;br&gt;&lt;br&gt;--
&lt;br&gt;Tuomas</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/Postponing-of-ChunkedWriteHandlers-hasNextChunk-retrieval-after-write-operation-tp4024971p4024971.html" />
	
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4042241</id>
	<title>Re: http tunnel not as servlet</title>
	<published>2009-11-21T02:45:26Z</published>
	<updated>2009-11-21T02:45:26Z</updated>
	<author>
		<name>miarkus</name>
	</author>
	<content type="html">Hi Adam,
&lt;br&gt;&lt;br&gt;I'll def take a look at your LittleProxy. Still I'd appreciate some help 
&lt;br&gt;with netty's native support for tunnelling and having this feature build-in 
&lt;br&gt;into server apart from having it as deployed as servlet.
&lt;br&gt;&lt;br&gt;Best,
&lt;br&gt;&lt;br&gt;Pete
&lt;br&gt;&lt;br&gt;&lt;br&gt;----- Original Message ----- 
&lt;br&gt;From: &amp;quot;Adam Fisk&amp;quot; &amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4042241&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt;
&lt;br&gt;To: &amp;quot;Netty Users&amp;quot; &amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4042241&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt;
&lt;br&gt;Sent: Wednesday, November 18, 2009 9:13 AM
&lt;br&gt;Subject: Re: http tunnel not as servlet
&lt;br&gt;&lt;br&gt;&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; LittleProxy supports tunneling. It's still in its infancy, but it's
&lt;br&gt;&amp;gt; been working well in our tests:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://dev.littleshoot.org:8084/display/proxy/LittleShoot+Java+HTTP+Proxy+-+LittleProxy&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://dev.littleshoot.org:8084/display/proxy/LittleShoot+Java+HTTP+Proxy+-+LittleProxy&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; -Adam
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; On Tue, Nov 17, 2009 at 12:24 PM, miarkus &amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4042241&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Please advise me what steps should I take to have http tunnel built-in 
&lt;br&gt;&amp;gt;&amp;gt; into
&lt;br&gt;&amp;gt;&amp;gt; NETTY server, so it won't have to run as servlet.
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Thanks
&lt;br&gt;&amp;gt;&amp;gt; --
&lt;br&gt;&amp;gt;&amp;gt; View this message in context: 
&lt;br&gt;&amp;gt;&amp;gt; &lt;a href=&quot;http://n2.nabble.com/http-tunnel-not-as-servlet-tp4021041p4021041.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://n2.nabble.com/http-tunnel-not-as-servlet-tp4021041p4021041.html&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt; Sent from the Netty User Group mailing list archive at Nabble.com.
&lt;br&gt;&amp;gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt;&amp;gt; netty-users mailing list
&lt;br&gt;&amp;gt;&amp;gt; &lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4042241&amp;i=3&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&amp;gt;&amp;gt; &lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; -- 
&lt;br&gt;&amp;gt; Adam Fisk
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://www.littleshoot.org&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.littleshoot.org&lt;/a&gt;&amp;nbsp;| &lt;a href=&quot;http://adamfisk.wordpress.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://adamfisk.wordpress.com&lt;/a&gt;&amp;nbsp;|
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://twitter.com/adamfisk&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://twitter.com/adamfisk&lt;/a&gt;&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; netty-users mailing list
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4042241&amp;i=4&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&amp;gt; &lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&amp;nbsp;
&lt;/div&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;netty-users mailing list
&lt;br&gt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4042241&amp;i=5&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/http-tunnel-not-as-servlet-tp4021041p4042241.html" />
	<thr:in-reply-to ref="tag:n2.nabble.com,2006:post-4024029"/>
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4024029</id>
	<title>Re: http tunnel not as servlet</title>
	<published>2009-11-18T00:13:45Z</published>
	<updated>2009-11-18T00:13:45Z</updated>
	<author>
		<name>Adam Fisk</name>
	</author>
	<content type="html">LittleProxy supports tunneling. It's still in its infancy, but it's
&lt;br&gt;been working well in our tests:
&lt;br&gt;&lt;br&gt;&lt;a href=&quot;http://dev.littleshoot.org:8084/display/proxy/LittleShoot+Java+HTTP+Proxy+-+LittleProxy&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://dev.littleshoot.org:8084/display/proxy/LittleShoot+Java+HTTP+Proxy+-+LittleProxy&lt;/a&gt;&lt;br&gt;&lt;br&gt;-Adam
&lt;br&gt;&lt;br&gt;&lt;br&gt;On Tue, Nov 17, 2009 at 12:24 PM, miarkus &amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4024029&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Please advise me what steps should I take to have http tunnel built-in into
&lt;br&gt;&amp;gt; NETTY server, so it won't have to run as servlet.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Thanks
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; View this message in context: &lt;a href=&quot;http://n2.nabble.com/http-tunnel-not-as-servlet-tp4021041p4021041.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://n2.nabble.com/http-tunnel-not-as-servlet-tp4021041p4021041.html&lt;/a&gt;&lt;br&gt;&amp;gt; Sent from the Netty User Group mailing list archive at Nabble.com.
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; netty-users mailing list
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4024029&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&amp;gt; &lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Adam Fisk
&lt;br&gt;&lt;a href=&quot;http://www.littleshoot.org&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.littleshoot.org&lt;/a&gt;&amp;nbsp;| &lt;a href=&quot;http://adamfisk.wordpress.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://adamfisk.wordpress.com&lt;/a&gt;&amp;nbsp;|
&lt;br&gt;&lt;a href=&quot;http://twitter.com/adamfisk&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://twitter.com/adamfisk&lt;/a&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;netty-users mailing list
&lt;br&gt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4024029&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/http-tunnel-not-as-servlet-tp4021041p4024029.html" />
	<thr:in-reply-to ref="tag:n2.nabble.com,2006:post-4021041"/>
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4021041</id>
	<title>http tunnel not as servlet</title>
	<published>2009-11-17T12:24:14Z</published>
	<updated>2009-11-17T12:24:14Z</updated>
	<author>
		<name>miarkus</name>
	</author>
	<content type="html">Please advise me what steps should I take to have http tunnel built-in into NETTY server, so it won't have to run as servlet.
&lt;br&gt;&lt;br&gt;Thanks</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/http-tunnel-not-as-servlet-tp4021041p4021041.html" />
	
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4024044</id>
	<title>Re: Netty 3.2.0.ALPHA1 released: New Journey to the Next Level</title>
	<published>2009-11-18T00:15:58Z</published>
	<updated>2009-11-18T00:15:58Z</updated>
	<author>
		<name>Adam Fisk</name>
	</author>
	<content type="html">Great work Trustin. The compression and decompression handlers are
&lt;br&gt;quite a feat - looking forward to checking out the code!
&lt;br&gt;&lt;br&gt;-Adam
&lt;br&gt;&lt;br&gt;&lt;br&gt;On Mon, Nov 16, 2009 at 5:39 AM, Trustin Lee (이희승) &amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4024044&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt; Hi folks,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Netty 3.2.0.ALPHA1, the first milestone in the 3.2 branch, has been released.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; The Netty project is an effort to provide an asynchronous,
&lt;br&gt;&amp;gt; event-driven network application framework and tools for rapid
&lt;br&gt;&amp;gt; development of maintainable, high-performance, high-scalability
&lt;br&gt;&amp;gt; protocol servers and clients.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; In other words, Netty is a NIO client server framework that enables
&lt;br&gt;&amp;gt; quick and easy development of network applications such as protocol
&lt;br&gt;&amp;gt; servers and clients. It simplifies and streamlines network programming
&lt;br&gt;&amp;gt; such as TCP and UDP socket servers
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Please visit our web site to download it.  Your feed back is more than
&lt;br&gt;&amp;gt; appreciated - please visit the discussion forum and leave some
&lt;br&gt;&amp;gt; comments and questions:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;  * &lt;a href=&quot;http://www.jboss.org/netty/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.jboss.org/netty/&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Compression Handlers
&lt;br&gt;&amp;gt; ====================
&lt;br&gt;&amp;gt; The ability to compress and decompress a connection transparently was
&lt;br&gt;&amp;gt; one of the early feature requests in Netty development.  The
&lt;br&gt;&amp;gt; compression handlers introduced in this release add complete support
&lt;br&gt;&amp;gt; for both GZIP and ZLIB compression encoding, which is not found in any
&lt;br&gt;&amp;gt; other NIO application frameworks.  For more information, please look
&lt;br&gt;&amp;gt; at the org.jboss.netty.handler.codec.compression package.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; On top of the new compression handlers, HTTP content compression /
&lt;br&gt;&amp;gt; decompression support has been added, too.  Please take a look at the
&lt;br&gt;&amp;gt; HTTP snoop client / server example for more information.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; New Testimonial
&lt;br&gt;&amp;gt; ===============
&lt;br&gt;&amp;gt; Dave Siracusa from Perfware LLC sent a nice testimonial for Netty
&lt;br&gt;&amp;gt; recently.  You will find it very interesting; he succeeded to write an
&lt;br&gt;&amp;gt; HTTP server which is capable of processing 15,000 messages per second
&lt;br&gt;&amp;gt; on top of Netty.  Check his recommendation and other testimonials
&lt;br&gt;&amp;gt; here: &lt;a href=&quot;http://www.jboss.org/netty/testimonials.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.jboss.org/netty/testimonials.html&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Upcoming Releases
&lt;br&gt;&amp;gt; =================
&lt;br&gt;&amp;gt; Although we did not add many new features in this first alpha, we have
&lt;br&gt;&amp;gt; bunch of new features planned, and they are all public in our issue
&lt;br&gt;&amp;gt; tracker and mailing list.  Please feel free to join the discussion and
&lt;br&gt;&amp;gt; keep us updated with any ideas for new features, bugs, design issues,
&lt;br&gt;&amp;gt; API usability feed back, and questions - your idea is the future of
&lt;br&gt;&amp;gt; Netty!
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Miscellaneous
&lt;br&gt;&amp;gt; =============
&lt;br&gt;&amp;gt; For the full changelog, please visit here:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;  * &lt;a href=&quot;http://jira.jboss.org/jira/browse/NETTY&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://jira.jboss.org/jira/browse/NETTY&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Cheers,
&lt;br&gt;&amp;gt; Trustin
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; — Trustin Lee, &lt;a href=&quot;http://gleamynode.net/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://gleamynode.net/&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; netty-users mailing list
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4024044&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&amp;gt; &lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;-- 
&lt;br&gt;Adam Fisk
&lt;br&gt;&lt;a href=&quot;http://www.littleshoot.org&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.littleshoot.org&lt;/a&gt;&amp;nbsp;| &lt;a href=&quot;http://adamfisk.wordpress.com&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://adamfisk.wordpress.com&lt;/a&gt;&amp;nbsp;|
&lt;br&gt;&lt;a href=&quot;http://twitter.com/adamfisk&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://twitter.com/adamfisk&lt;/a&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;netty-users mailing list
&lt;br&gt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4024044&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/Netty-3-2-0-ALPHA1-released-New-Journey-to-the-Next-Level-tp4012091p4024044.html" />
	<thr:in-reply-to ref="tag:n2.nabble.com,2006:post-4012091"/>
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4012091</id>
	<title>Netty 3.2.0.ALPHA1 released: New Journey to the Next Level</title>
	<published>2009-11-16T05:39:55Z</published>
	<updated>2009-11-16T05:39:55Z</updated>
	<author>
		<name>Trustin Lee</name>
	</author>
	<content type="html">Hi folks,
&lt;br&gt;&lt;br&gt;Netty 3.2.0.ALPHA1, the first milestone in the 3.2 branch, has been released.
&lt;br&gt;&lt;br&gt;The Netty project is an effort to provide an asynchronous,
&lt;br&gt;event-driven network application framework and tools for rapid
&lt;br&gt;development of maintainable, high-performance, high-scalability
&lt;br&gt;protocol servers and clients.
&lt;br&gt;&lt;br&gt;In other words, Netty is a NIO client server framework that enables
&lt;br&gt;quick and easy development of network applications such as protocol
&lt;br&gt;servers and clients. It simplifies and streamlines network programming
&lt;br&gt;such as TCP and UDP socket servers
&lt;br&gt;&lt;br&gt;Please visit our web site to download it. &amp;nbsp;Your feed back is more than
&lt;br&gt;appreciated - please visit the discussion forum and leave some
&lt;br&gt;comments and questions:
&lt;br&gt;&lt;br&gt;&amp;nbsp; * &lt;a href=&quot;http://www.jboss.org/netty/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.jboss.org/netty/&lt;/a&gt;&lt;br&gt;&lt;br&gt;Compression Handlers
&lt;br&gt;====================
&lt;br&gt;The ability to compress and decompress a connection transparently was
&lt;br&gt;one of the early feature requests in Netty development. &amp;nbsp;The
&lt;br&gt;compression handlers introduced in this release add complete support
&lt;br&gt;for both GZIP and ZLIB compression encoding, which is not found in any
&lt;br&gt;other NIO application frameworks. &amp;nbsp;For more information, please look
&lt;br&gt;at the org.jboss.netty.handler.codec.compression package.
&lt;br&gt;&lt;br&gt;On top of the new compression handlers, HTTP content compression /
&lt;br&gt;decompression support has been added, too. &amp;nbsp;Please take a look at the
&lt;br&gt;HTTP snoop client / server example for more information.
&lt;br&gt;&lt;br&gt;New Testimonial
&lt;br&gt;===============
&lt;br&gt;Dave Siracusa from Perfware LLC sent a nice testimonial for Netty
&lt;br&gt;recently. &amp;nbsp;You will find it very interesting; he succeeded to write an
&lt;br&gt;HTTP server which is capable of processing 15,000 messages per second
&lt;br&gt;on top of Netty. &amp;nbsp;Check his recommendation and other testimonials
&lt;br&gt;here: &lt;a href=&quot;http://www.jboss.org/netty/testimonials.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://www.jboss.org/netty/testimonials.html&lt;/a&gt;&lt;br&gt;&lt;br&gt;Upcoming Releases
&lt;br&gt;=================
&lt;br&gt;Although we did not add many new features in this first alpha, we have
&lt;br&gt;bunch of new features planned, and they are all public in our issue
&lt;br&gt;tracker and mailing list. &amp;nbsp;Please feel free to join the discussion and
&lt;br&gt;keep us updated with any ideas for new features, bugs, design issues,
&lt;br&gt;API usability feed back, and questions - your idea is the future of
&lt;br&gt;Netty!
&lt;br&gt;&lt;br&gt;Miscellaneous
&lt;br&gt;=============
&lt;br&gt;For the full changelog, please visit here:
&lt;br&gt;&lt;br&gt;&amp;nbsp; * &lt;a href=&quot;http://jira.jboss.org/jira/browse/NETTY&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://jira.jboss.org/jira/browse/NETTY&lt;/a&gt;&lt;br&gt;&lt;br&gt;Cheers,
&lt;br&gt;Trustin
&lt;br&gt;&lt;br&gt;— Trustin Lee, &lt;a href=&quot;http://gleamynode.net/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://gleamynode.net/&lt;/a&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;netty-users mailing list
&lt;br&gt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4012091&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&lt;div class=&quot;signature&quot;&gt;— Trustin Lee, &lt;a href=&quot;http://gleamynode.net/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://gleamynode.net/&lt;/a&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/Netty-3-2-0-ALPHA1-released-New-Journey-to-the-Next-Level-tp4012091p4012091.html" />
	
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4007637</id>
	<title>Re: Netty client in Java 1.4</title>
	<published>2009-11-15T06:06:36Z</published>
	<updated>2009-11-15T06:06:36Z</updated>
	<author>
		<name>tstat</name>
	</author>
	<content type="html">Virat,
&lt;br&gt;&amp;nbsp;Thanks for the reply. &amp;nbsp;Of course... &amp;nbsp;Makes perfect sense. &amp;nbsp;
&lt;br&gt;I was blinded by the cool technology. &amp;nbsp;But, I won't be able
&lt;br&gt;to pad my resume ;(.
&lt;br&gt;&lt;br&gt;Aaron
&lt;br&gt;&lt;br&gt;&lt;blockquote class=&quot;quote light-black dark-border-color&quot;&gt;&lt;div class=&quot;quote light-border-color&quot;&gt;
&lt;div class=&quot;quote-author&quot; style=&quot;font-weight: bold;&quot;&gt;Virat Gohil-3 wrote:&lt;/div&gt;
&lt;div class=&quot;quote-message shrinkable-quote&quot;&gt;Hi,
&lt;br&gt;&lt;br&gt;There is a third option too:
&lt;br&gt;&lt;br&gt;3. Write the application using the Old I/O (blocking) approach.
&lt;br&gt;&lt;br&gt;Netty can work with non-NIO clients as well. Write your application as
&lt;br&gt;if you are communicating to a regular server.
&lt;br&gt;&lt;br&gt;HTH,
&lt;br&gt;&lt;br&gt;Virat
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;On Sat, Nov 14, 2009 at 11:01 PM, tstat &amp;lt;asmith@proliphix.com&amp;gt; wrote:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I have been tasked to write a client that will be talking to a server running
&lt;br&gt;&amp;gt; Netty.
&lt;br&gt;&amp;gt; Unfortunately, the client environment only provides Java 1.4.2.
&lt;br&gt;&amp;gt; I have attempted to use Retrotranslator but have met with many
&lt;br&gt;&amp;gt; exceptions and unexplained crashes.  Does anyone know of what might
&lt;br&gt;&amp;gt; be an alternative.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; 1. JBoss Retro?
&lt;br&gt;&amp;gt; 2. Bite the bullet and write the client using regular NIO etc...
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Thanks for your help.
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; View this message in context: &lt;a href=&quot;http://n2.nabble.com/Netty-client-in-Java-1-4-tp4004933p4004933.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://n2.nabble.com/Netty-client-in-Java-1-4-tp4004933p4004933.html&lt;/a&gt;&lt;br&gt;&amp;gt; Sent from the Netty User Group mailing list archive at Nabble.com.
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; netty-users mailing list
&lt;br&gt;&amp;gt; netty-users@lists.jboss.org
&lt;br&gt;&amp;gt; &lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;netty-users mailing list
&lt;br&gt;netty-users@lists.jboss.org
&lt;br&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;&lt;/blockquote&gt;
</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/Netty-client-in-Java-1-4-tp4004933p4007637.html" />
	<thr:in-reply-to ref="tag:n2.nabble.com,2006:post-4006671"/>
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4006671</id>
	<title>Re: Netty client in Java 1.4</title>
	<published>2009-11-14T21:07:28Z</published>
	<updated>2009-11-14T21:07:28Z</updated>
	<author>
		<name>Virat Gohil-3</name>
	</author>
	<content type="html">Hi,
&lt;br&gt;&lt;br&gt;There is a third option too:
&lt;br&gt;&lt;br&gt;3. Write the application using the Old I/O (blocking) approach.
&lt;br&gt;&lt;br&gt;Netty can work with non-NIO clients as well. Write your application as
&lt;br&gt;if you are communicating to a regular server.
&lt;br&gt;&lt;br&gt;HTH,
&lt;br&gt;&lt;br&gt;Virat
&lt;br&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;On Sat, Nov 14, 2009 at 11:01 PM, tstat &amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4006671&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I have been tasked to write a client that will be talking to a server running
&lt;br&gt;&amp;gt; Netty.
&lt;br&gt;&amp;gt; Unfortunately, the client environment only provides Java 1.4.2.
&lt;br&gt;&amp;gt; I have attempted to use Retrotranslator but have met with many
&lt;br&gt;&amp;gt; exceptions and unexplained crashes.  Does anyone know of what might
&lt;br&gt;&amp;gt; be an alternative.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; 1. JBoss Retro?
&lt;br&gt;&amp;gt; 2. Bite the bullet and write the client using regular NIO etc...
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Thanks for your help.
&lt;br&gt;&amp;gt; --
&lt;br&gt;&amp;gt; View this message in context: &lt;a href=&quot;http://n2.nabble.com/Netty-client-in-Java-1-4-tp4004933p4004933.html&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://n2.nabble.com/Netty-client-in-Java-1-4-tp4004933p4004933.html&lt;/a&gt;&lt;br&gt;&amp;gt; Sent from the Netty User Group mailing list archive at Nabble.com.
&lt;br&gt;&amp;gt; _______________________________________________
&lt;br&gt;&amp;gt; netty-users mailing list
&lt;br&gt;&amp;gt; &lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4006671&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&amp;gt; &lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&amp;gt;
&lt;/div&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;netty-users mailing list
&lt;br&gt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4006671&amp;i=2&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/Netty-client-in-Java-1-4-tp4004933p4006671.html" />
	<thr:in-reply-to ref="tag:n2.nabble.com,2006:post-4004933"/>
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4004933</id>
	<title>Netty client in Java 1.4</title>
	<published>2009-11-14T09:31:13Z</published>
	<updated>2009-11-14T09:31:13Z</updated>
	<author>
		<name>tstat</name>
	</author>
	<content type="html">I have been tasked to write a client that will be talking to a server running Netty.
&lt;br&gt;Unfortunately, the client environment only provides Java 1.4.2.
&lt;br&gt;I have attempted to use Retrotranslator but have met with many
&lt;br&gt;exceptions and unexplained crashes. &amp;nbsp;Does anyone know of what might
&lt;br&gt;be an alternative.
&lt;br&gt;&lt;br&gt;1. JBoss Retro?
&lt;br&gt;2. Bite the bullet and write the client using regular NIO etc...
&lt;br&gt;&lt;br&gt;Thanks for your help.</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/Netty-client-in-Java-1-4-tp4004933p4004933.html" />
	
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4018176</id>
	<title>Re: GPS trackers</title>
	<published>2009-11-17T04:03:22Z</published>
	<updated>2009-11-17T04:03:22Z</updated>
	<author>
		<name>Trustin Lee</name>
	</author>
	<content type="html">Hi QP,
&lt;br&gt;&lt;br&gt;On Sat, Nov 14, 2009 at 8:40 AM, qp &amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4018176&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt; wrote:
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Hi,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; I have a dude. There are many GPS devices that send locations. Is possible
&lt;br&gt;&amp;gt; to configure ip and port but can't install a some socket client. So probably
&lt;br&gt;&amp;gt; they sent locations in standard binary sockets. I don't now much about nio,
&lt;br&gt;&amp;gt; but I suppose that to use nio you have to use client that support nio.
&lt;br&gt;&lt;br&gt;As long as the GPS devices communicate via TCP/IP or UDP/IP, you can
&lt;br&gt;use any networking API (NIO, old java.io, C, whatever) to communicate
&lt;br&gt;with them. &amp;nbsp;You don't need to use NIO on the both side.
&lt;br&gt;&lt;br&gt;&amp;gt; Using netty, can I process the incoming sockets from the GPS devices?
&lt;br&gt;&lt;br&gt;Sure you can, if the GPS device speak TCP/IP or UDP/IP.
&lt;br&gt;&lt;br&gt;HTH,
&lt;br&gt;&lt;br&gt;— Trustin Lee, &lt;a href=&quot;http://gleamynode.net/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://gleamynode.net/&lt;/a&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;netty-users mailing list
&lt;br&gt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4018176&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&lt;div class=&quot;signature&quot;&gt;— Trustin Lee, &lt;a href=&quot;http://gleamynode.net/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://gleamynode.net/&lt;/a&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/GPS-trackers-tp4002167p4018176.html" />
	<thr:in-reply-to ref="tag:n2.nabble.com,2006:post-4002167"/>
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4002167</id>
	<title>GPS trackers</title>
	<published>2009-11-13T15:40:16Z</published>
	<updated>2009-11-13T15:40:16Z</updated>
	<author>
		<name>qp</name>
	</author>
	<content type="html">Hi,
&lt;br&gt;&lt;br&gt;I have a dude. There are many GPS devices that send locations. Is possible to configure ip and port but can't install a some socket client. So probably they sent locations in standard binary sockets. I don't now much about nio, but I suppose that to use nio you have to use client that support nio.
&lt;br&gt;&lt;br&gt;Using netty, can I process the incoming sockets from the GPS devices? </content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/GPS-trackers-tp4002167p4002167.html" />
	
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4017187</id>
	<title>Re: Usefull ByteBuffer methods are not present in ChannelBuffer</title>
	<published>2009-11-17T00:13:56Z</published>
	<updated>2009-11-17T00:13:56Z</updated>
	<author>
		<name>Trustin Lee</name>
	</author>
	<content type="html">On Tue, Nov 17, 2009 at 4:26 PM, Atra &amp;lt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4017187&amp;i=0&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;&amp;gt; wrote:
&lt;div class='shrinkable-quote'&gt;&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Thomas Bocek wrote:
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Hi Atra,
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; You can use longBitsToDouble(long), doubleToRawLongBits(double value),
&lt;br&gt;&amp;gt;&amp;gt; doubleToLongBits(double value), etc. and use putLong()/getLong()
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Cheers,
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt; Thomas
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;&amp;gt;
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Hi Thomas,
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; thanks for the usefull hint. Yes, with float and double this will work. With
&lt;br&gt;&amp;gt; char it is also possible to do some bits operations (just looking at
&lt;br&gt;&amp;gt; ByteBuffer source). But the general idea is to not reinvent the wheel. I'm
&lt;br&gt;&amp;gt; pretty sure everyone who deals with some custom protocol needs those methods
&lt;br&gt;&amp;gt; and its not good to reinvent the wheel.
&lt;br&gt;&amp;gt;
&lt;br&gt;&amp;gt; Btw may be I should create a feature request in JIRA?
&lt;/div&gt;&lt;br&gt;That would be great. &amp;nbsp;Thanks in advance! :)
&lt;br&gt;&lt;br&gt;Cheers
&lt;br&gt;&lt;br&gt;— Trustin Lee, &lt;a href=&quot;http://gleamynode.net/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://gleamynode.net/&lt;/a&gt;&lt;br&gt;&lt;br&gt;_______________________________________________
&lt;br&gt;netty-users mailing list
&lt;br&gt;&lt;a href=&quot;http://n2.nabble.com/user/SendEmail.jtp?type=node&amp;node=4017187&amp;i=1&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;[hidden email]&lt;/a&gt;
&lt;br&gt;&lt;a href=&quot;https://lists.jboss.org/mailman/listinfo/netty-users&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;https://lists.jboss.org/mailman/listinfo/netty-users&lt;/a&gt;&lt;br&gt;&lt;div class=&quot;signature&quot;&gt;— Trustin Lee, &lt;a href=&quot;http://gleamynode.net/&quot; target=&quot;_top&quot; rel=&quot;nofollow&quot;&gt;http://gleamynode.net/&lt;/a&gt;&lt;/div&gt;</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/Usefull-ByteBuffer-methods-are-not-present-in-ChannelBuffer-tp4000058p4017187.html" />
	<thr:in-reply-to ref="tag:n2.nabble.com,2006:post-4017036"/>
</entry>

<entry>
	<id>tag:n2.nabble.com,2006:post-4017036</id>
	<title>Re: Usefull ByteBuffer methods are not present in ChannelBuffer</title>
	<published>2009-11-16T23:26:47Z</published>
	<updated>2009-11-16T23:26:47Z</updated>
	<author>
		<name>Atra</name>
	</author>
	<content type="html">&lt;blockquote class=&quot;quote light-black dark-border-color&quot;&gt;&lt;div class=&quot;quote light-border-color&quot;&gt;
&lt;div class=&quot;quote-author&quot; style=&quot;font-weight: bold;&quot;&gt;Thomas Bocek wrote:&lt;/div&gt;
&lt;div class=&quot;quote-message shrinkable-quote&quot;&gt;Hi Atra,
&lt;br&gt;&lt;br&gt;You can use longBitsToDouble(long), doubleToRawLongBits(double value),
&lt;br&gt;doubleToLongBits(double value), etc. and use putLong()/getLong()
&lt;br&gt;&lt;br&gt;Cheers,
&lt;br&gt;&lt;br&gt;Thomas
&lt;/div&gt;
&lt;/div&gt;&lt;/blockquote&gt;
Hi Thomas,
&lt;br&gt;&lt;br&gt;thanks for the usefull hint. Yes, with float and double this will work. With char it is also possible to do some bits operations (just looking at ByteBuffer source). But the general idea is to not reinvent the wheel. I'm pretty sure everyone who deals with some custom protocol needs those methods and its not good to reinvent the wheel.
&lt;br&gt;&lt;br&gt;Btw may be I should create a feature request in JIRA?
&lt;br&gt;&lt;br&gt;Regards
&lt;br&gt;</content>
	<link rel="alternate" type="text/html" href="http://n2.nabble.com/Usefull-ByteBuffer-methods-are-not-present-in-ChannelBuffer-tp4000058p4017036.html" />
	<thr:in-reply-to ref="tag:n2.nabble.com,2006:post-4000114"/>
</entry>

</feed>
