Not receiving all data after attempting to close the channel.

Michael McGrady mmcgrady at topiatechnology.com
Fri Nov 20 14:50:14 EST 2009


Exactly, Stephen.  They are apples and oranges, if not apples and  
onions.

Mike

On Nov 20, 2009, at 11:27 AM, Stephen Pape wrote:

>
> 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.
>
> I still haven't been able to address the issue when using Nio.
>
> -Stephen
>
>
> Stephen Pape wrote:
>>
>> Hello,
>>
>>
>>
>> I'm having a problem with both 3.2.0.ALPHA1 and 3.1.5.GA (haven't  
>> tested
>> other versions).
>>
>>
>>
>> Basically, in order to make sure that all pending data is written,  
>> I have
>> something like this:
>>
>>
>>
>> private volatile ChannelFuture writeFuture = null;
>>
>>                private volatile Channel channel = null; // Set later
>>
>>
>>
>> public void write(Object obj)
>> {
>>
>>   writeFuture = channel.write(obj);
>> }
>>
>>
>>
>> public void close()
>>
>> {
>>
>>  If(this.writeFuture != null)
>>
>>     this.writeFuture.addListener(this);
>>
>>  else
>>
>>     this.channel.close();
>>
>> }
>>
>>
>>
>> public void operationComplete(ChannelFuture future)
>>
>> {
>>
>>  // Thread.sleep(1000);
>>
>>  future.getChannel.close();
>>
>> }
>>
>>
>>
>>
>>
>> This class is being used to write Objects in a loop. Immediately  
>> after the
>> loop the close method is called.
>>
>>
>>
>> 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.
>>
>>
>>
>> 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?
>>
>>
>>
>> Thanks!
>>
>>
>>
>> -Stephen
>>
>>
>>
>> _______________________________________________
>> netty-users mailing list
>> netty-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/netty-users
>>
>>
>
> -- 
> View this message in context: http://n2.nabble.com/Not-receiving-all-data-after-attempting-to-close-the-channel-tp4033482p4039588.html
> Sent from the Netty User Group mailing list archive at Nabble.com.
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users

Mike McGrady
Principal Investigator AF081-028 AFRL SBIR
Senior Engineer
Topia Technology, Inc
1.253.720.3365
mmcgrady at topiatechnology.com









More information about the netty-users mailing list