Client disconnect
matthias.s.
matthias.scudlik at pangora.com
Wed May 6 10:56:38 EDT 2009
I found out why this solution doesn't work:
The "problem" is that netty does batch write operations meaning
several writeRequest() calls lead to a single writeCompleted() call.
The fired WriteCompleteionEvent has a Method called getWrittenAmount() which
should do this according to the documentation:
/**
* Returns the amount of data written.
*
* @return the number of written bytes or messages, depending on the
* type of the transport
*/
Well, I am sending Object Messages, but the value is obviously the amount of
bytes and much bigger than the sent object count.
I tried to count the bytes of the messages using a sizeOf Method like this:
private static long sizeOf( Object object ) {
ByteArrayOutputStream bos = null;
ObjectOutputStream oos = null;
try {
bos = new ByteArrayOutputStream();
oos = new CompactObjectOutputStream(bos);
oos.writeObject(object);
byte[] byteArray = bos.toByteArray();
return byteArray.length;
}
catch ( IOException e ) {
return 0;
}
finally {
if ( oos != null ) {
try {
oos.close();
}
catch ( IOException e ) {}
}
if ( bos != null ) {
try {
bos.close();
}
catch ( IOException e ) {}
}
}
}
The CompatcObjectOutputStream is used by the ObjectEncoder, but
unfortunately the complete/request counts don't match. The same happend
using java.io.ObjectOutputStream
--
View this message in context: http://n2.nabble.com/Client-disconnect-tp2798147p2817379.html
Sent from the Netty User Group mailing list archive at Nabble.com.
More information about the netty-users
mailing list