Hi Oleg

I was able to get this one working with the simple buffers (slightly modified).. but the OFM errors were common with large payloads, and thus wanted to use throttling too..

However, now I have an issue when keepalive server side sockets are being used. It seems like I need to requestInput() in the server handler's outputReady() when finishing writing the response for a completed request, if I am not going to close the connection. However, at this point (when debugging the IOSession) it seems like there is still data in the buffers still not written into the actual socket channel. The lines in blue are additional information to the log.

2008-05-25 00:59:23,322 [127.0.1.1-asankha] [I/O dispatcher 7] DEBUG IOSessionImpl I/O session server-1 [interested ops: [w]; ready ops: [w]]: 2055 bytes written ......lots of data written....0123456789012345678901234
</exam:echo>
==> Finished processing current request. Requesting to READ again on this keepalive socket <== 2008-05-25 00:59:23,322 [127.0.1.1-asankha] [I/O dispatcher 7] DEBUG IOSessionImpl I/O session server-1 [interested ops: [w]; ready ops: [w]]: Set event [r] 2008-05-25 00:59:23,322 [127.0.1.1-asankha] [I/O dispatcher 7] DEBUG IOSessionImpl I/O session server-1 [interested ops: [rw]; ready ops: [w]]: 0 bytes read
Stack trace for this call:
at org.apache.synapse.transport.nhttp.LoggingIOSession$LoggingByteChannel.read(LoggingIOSession.java:199) at org.apache.http.impl.nio.reactor.SessionInputBufferImpl.fill(SessionInputBufferImpl.java:85) at org.apache.http.impl.nio.codecs.ChunkDecoder.read(ChunkDecoder.java:162) at org.apache.synapse.transport.nhttp.util.SharedInputBuffer.consumeContent(SharedInputBuffer.java:66) at org.apache.synapse.transport.nhttp.ServerHandler.inputReady(ServerHandler.java:157) at org.apache.http.impl.nio.DefaultNHttpServerConnection.consumeInput(DefaultNHttpServerConnection.java:135) at org.apache.http.impl.nio.DefaultServerIOEventDispatch.inputReady(DefaultServerIOEventDispatch.java:98) at org.apache.http.impl.nio.reactor.BaseIOReactor.validate(BaseIOReactor.java:143) at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:146) at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:70) at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:318)
   at java.lang.Thread.run(Thread.java:595)
2008-05-25 00:59:23,323 [127.0.1.1-asankha] [I/O dispatcher 7] DEBUG IOSessionImpl I/O session server-1 [interested ops: [rw]; ready ops: [w]]: 0 bytes read
Stack trace for this call:
at org.apache.synapse.transport.nhttp.LoggingIOSession$LoggingByteChannel.read(LoggingIOSession.java:199) at org.apache.http.impl.nio.reactor.SessionInputBufferImpl.fill(SessionInputBufferImpl.java:85) at org.apache.http.impl.nio.codecs.ChunkDecoder.read(ChunkDecoder.java:162) at org.apache.synapse.transport.nhttp.util.SharedInputBuffer.consumeContent(SharedInputBuffer.java:66) at org.apache.synapse.transport.nhttp.ServerHandler.inputReady(ServerHandler.java:157) at org.apache.http.impl.nio.DefaultNHttpServerConnection.consumeInput(DefaultNHttpServerConnection.java:135) at org.apache.http.impl.nio.DefaultServerIOEventDispatch.inputReady(DefaultServerIOEventDispatch.java:98) at org.apache.http.impl.nio.reactor.BaseIOReactor.validate(BaseIOReactor.java:143) at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:146) at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:70) at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:318)
   at java.lang.Thread.run(Thread.java:595)
2008-05-25 00:59:23,323 [127.0.1.1-asankha] [I/O dispatcher 7] DEBUG IOSessionImpl I/O session server-1 [interested ops: [rw]; ready ops: [w]]: Clear event [r]
Stack trace for this call:
at org.apache.synapse.transport.nhttp.LoggingIOSession.clearEvent(LoggingIOSession.java:122) at org.apache.http.impl.nio.NHttpConnectionBase.suspendInput(NHttpConnectionBase.java:162) at org.apache.synapse.transport.nhttp.util.SharedInputBuffer.consumeContent(SharedInputBuffer.java:73) at org.apache.synapse.transport.nhttp.ServerHandler.inputReady(ServerHandler.java:157) at org.apache.http.impl.nio.DefaultNHttpServerConnection.consumeInput(DefaultNHttpServerConnection.java:135) at org.apache.http.impl.nio.DefaultServerIOEventDispatch.inputReady(DefaultServerIOEventDispatch.java:98) at org.apache.http.impl.nio.reactor.BaseIOReactor.validate(BaseIOReactor.java:143) at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:146) at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:70) at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:318)
   at java.lang.Thread.run(Thread.java:595)
2008-05-25 00:59:23,325 [127.0.1.1-asankha] [I/O dispatcher 7] DEBUG IOSessionImpl I/O session server-1 [interested ops: [w]; ready ops: [w]]: 58 bytes written
Wrote:
2f
</exam:echo></soapenv:Body></soapenv:Envelope>
0
2008-05-25 00:59:23,325 [127.0.1.1-asankha] [I/O dispatcher 7] DEBUG IOSessionImpl I/O session server-1 [interested ops: [w]; ready ops: [w]]: Clear event [w]

==> Second request on keepalive fails, and the connection times out <==
2008-05-25 01:00:21,336 [127.0.1.1-asankha] [I/O dispatcher 7] DEBUG IOSessionImpl I/O session server-1 [interested ops: []; ready ops: [w]]: Shutdown 2008-05-25 01:00:23,015 [127.0.1.1-asankha] [I/O dispatcher 1] DEBUG IOSessionImpl I/O session client-2 [interested ops: []; ready ops: [r]]: Shutdown

I also have a question on the Shared buffer class.. in SharedInputBuffer::consumeContent() <http://hc.apache.org/httpcomponents-core/httpcore-nio/xref/org/apache/http/nio/util/SharedInputBuffer.html#80> why do you suspendInput if totalRead > 0? This does not mean that the buffer is full.. and we could read more? If I change this condition to " if (totalRead > 0) && !this.buffer.hasRemaining()) " my keep alives "seems" to work.. but I am not sure if this is right or just lucky..

thanks
asankha

Reply via email to