[xSocket-develop] ClosedChannelException
Status: Inactive
Brought to you by:
grro
|
From: David A. <da...@st...> - 2008-11-05 02:16:56
|
Hi
I'm trying xsocket for the first time and I quite like the api and
the features.
I'm using a nonblockingpipeline over a multiplexed connection and all
seems fine, until the channel closes and a ClosedChannelException is
thrown.
I'm reasearching some event processing mechanisms and as such I
serialize objects across the client to the server, and it all boils
down to the fact that I always can send 67 and just 67 events.
Strange no?
Any help would be greatly appreciated.
My send/receive code along with the trace is in the end of the email.
Kind regards
David Alves
______________________
Client: (All the connection creation code is done only once then a
generating thread tries to send event through the pipeline)
Creation:
this.nativeConnection = new NonBlockingConnection(this.host, port,
Integer.MAX_VALUE);
this.multiplexedConnection = new
MultiplexedConnection(nativeConnection);
controlPipelineId = multiplexedConnection.createPipeline();
controlPipeline =
multiplexedConnection.getNonBlockingPipeline(controlPipelineId);
Repeat:
FastByteArrayOutputStream fbaos = new FastByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(fbaos);
oos.writeObject(event);
ByteBuffer objectBuffer = fbaos.getByteBuffer();
controlPipeline.write(objectBuffer);
controlPipeline.write(EVENT_SEPARATOR);
________________
Server: (Implements IPipelineDataHandler)
ByteBuffer[] eventsBbs = pipeline
.readByteBufferByDelimiter
(DummyMultiplexedNonBockingAdapter.EVENT_SEPARATOR);
for (ByteBuffer eventBb : eventsBbs) {
FastByteArrayInputStream fbais = new
FastByteArrayInputStream(eventBb);
ObjectInputStream ois = new ObjectInputStream(fbais);
Event event;
try {
event = (Event) ois.readObject();
} catch (ClassNotFoundException e) {
throw new IOException(e);
}
receiveEvent(event);
}
Trace:
Caused by: java.nio.channels.ClosedChannelException
at
org
.xsocket
.connection
.AbstractNonBlockingStream
.ensureStreamIsOpenAndWritable(AbstractNonBlockingStream.java:1472)
at
org
.xsocket
.connection
.AbstractNonBlockingStream.write(AbstractNonBlockingStream.java:1140)
at
pt
.uc
.dei
.fincos
.adapter
.dummy
.remote
.DummyMultiplexedNonBockingAdapter
.send(DummyMultiplexedNonBockingAdapter.java:72)
... 19 more
java.lang.NullPointerException
at
pt
.uc
.dei
.fincos
.adapter
.dummy
.remote
.DummyMultiplexedNonBockingAdapter
.send(DummyMultiplexedNonBockingAdapter.java:72) |