On Mon, 2020-01-06 at 20:56 -0500, Rafael Ferreira wrote: > Hello folks, I’m trying to get a sense of the correct way to handle a > couple corner cases while using httpcommons-core 5.x as a generic H2 > server framework. > > First, I would like idle connections to timeout (ie, client > initiates a socket connection to a IO reactor and does nothing). I > would assume this would be part of the IORector config but I couldn’t > find anything in there related to idle connections. >
Hi Rafael IOReactor#soTimeout is what you want. The socket timeout defines the maximum period of inactivity in an I/O session. The i/o reactor will close out connections that have exceeded their i/o session socket timeout. > Second, I’m trying to write an AsyncEntityConsumer that limits the > amount of data it will accept (to limit the max POST body allowed), > stops processing once a limit is reached and sends back an sensible > HTTP response, here’s my latest failed attempt: > > https://github.com/rferreira/jujube/blob/master/jujube-core/src/main/java/org/ophion/jujube/internal/MultipartEntityConsumer.java#L76 > < > https://github.com/rferreira/jujube/blob/master/jujube-core/src/main/java/org/ophion/jujube/internal/MultipartEntityConsumer.java#L76 > > > And > > https://github.com/rferreira/jujube/blob/master/jujube-core/src/main/java/org/ophion/jujube/internal/JujubeServerExchangeHandler.java#L70 > < > https://github.com/rferreira/jujube/blob/master/jujube-core/src/main/java/org/ophion/jujube/internal/JujubeServerExchangeHandler.java#L70 > > > > Needless to say, the above doesn’t work since it doesn’t tell the > underlying IO handler to stop reading bytes off the stream. > In order to notify the client that it is to stop sending more data the server has to send the so called out of sequence response. AbstractServerExchangeHandler represents an orderly request / response sequence (a response message gets generated only once the request message has been fully processed) and therefore is not suited for your situation. You need to build something similar to EchoHandler from HttpCore Test Module https://github.com/apache/httpcomponents-core/blob/master/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/EchoHandler.java > Lastly, I’m confused what types of exception in the H2ServerBootstrap > are supposed to trigger the callback method ( > https://github.com/rferreira/jujube/blob/master/jujube-core/src/main/java/org/ophion/jujube/Jujube.java#L55 > < > https://github.com/rferreira/jujube/blob/master/jujube-core/src/main/java/org/ophion/jujube/Jujube.java#L55 > >) - in my testing, I haven’t seen that callback method being called > even once. > That is because the callback gets invoked in case of a catastrophic failure when the i/o reactor is unable to continue processing currently active connections and is about to shut down. > Big thanks and if anything I’m asking for above requires changes to > httpcommons-core itself, I’m happy to submit patches with some minor > guidance. > Hope this helps Oleg --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
