Oleg, I posted the code here: https://github.com/rferreira/hc5 <https://github.com/rferreira/hc5> with a brief readme on how to duplicate the issue (I’m still fairly confident this is a misconfiguration issue on my part).
Thanks again, > On May 15, 2019, at 11:12 AM, Oleg Kalnichevski <[email protected]> wrote: > > On Wed, 2019-05-15 at 09:21 -0700, Rafael Ferreira wrote: >> Hi Oleg and thanks for the response and offer to help, that’s >> extremely gracious of you. >> >> I was able to make some progress and get some things sort of working, >> here’s my latest iteration: >> >> https://gist.github.com/rferreira/76434c01dfa1d5bf4e98976b573fc604 >> <https://gist.github.com/rferreira/76434c01dfa1d5bf4e98976b573fc604> < >> https://gist.github.com/rferreira/76434c01dfa1d5bf4e98976b573fc604 >> <https://gist.github.com/rferreira/76434c01dfa1d5bf4e98976b573fc604>> >> >> The good is that it works and responds to HTTP requests as well as >> parses bodies but I’m still running into an odd issue. It appears >> that there is a resource leak somewhere that causes the server to >> stop working after a few thousand requests. My theory is that the >> entity parsing is not properly closing the input stream but I’m >> unsure of both the efficiency of how I’m parsing it as well as where >> I would force a resource to be closed. >> >> Another question is that I noticed that the HttpRequest >> implementation that contains a http entity has been renamed >> ClassicHttpRequest and that leads me to believe that you would like >> to discourage its usage, if that’s the case, how would you suggest >> one encapsulates a HttpRequest that has a body? >> >> For clarity, my goal here is to build a purposely simple HTTP server >> well suited for micro service usage in a resource constrained >> environment. The surface API I want to expose out to consumers would >> be something like: public HttpResponse handle(HttpRequest, >> HttpContext) {} and most of the inbound requests would be multipart >> form posts used for simple RPC. >> >> Thanks again, > > Hi Rafael > > I could not spot anything obviously wrong with your implementation. If > you add a test case and put your project on Github I will try to run it > under some load and see if I can fix the resource issue. > > Generally I would recommend to not use inherently blocking classic > InputStream / OutputStream APIs with the async protocol handlers unless > there is a very strong reason to do so. > > Oleg > >> >> >>> On May 14, 2019, at 12:06 PM, Oleg Kalnichevski <[email protected]> >>> wrote: >>> >>> On Tue, 2019-05-14 at 07:51 -0700, Rafael Ferreira wrote: >>>> Howdy folks and apologies in advance if the information I’m >>>> looking >>>> for is available somewhere and I simply missed it. >>>> >>>> I’m trying to expand the example file server available here ( >>>> > https://github.com/apache/httpcomponents-core/blob/master/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/examples/Http2FileServerExample.java >>>> < >>>> https://github.com/apache/httpcomponents-core/blob/master/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/examples/Http2FileServerExample.java >>>>> >>>> < >>>> > https://github.com/apache/httpcomponents-core/blob/master/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/examples/Http2FileServerExample.java > > <https://github.com/apache/httpcomponents-core/blob/master/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/examples/Http2FileServerExample.java> >>>> < >>>> https://github.com/apache/httpcomponents-core/blob/master/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/examples/Http2FileServerExample.java >>>> >>>> <https://github.com/apache/httpcomponents-core/blob/master/httpcore5-h2/src/test/java/org/apache/hc/core5/http2/examples/Http2FileServerExample.java> >>>>> >>>>> ) into something that can consume a request with a body (a POST >>>> >>>> request for example) and I’m struggling to make sense of the >>>> interface abstractions, ideally, I would like to adapt the low >>>> level >>>> async interfaces to the classic HttpRequest/HttpResponse ones. >>>> >>>> Can anyone point me in either the direction of a more complex >>>> example >>>> http2 server using hc5 or just more examples of >>>> AsyncServerRequestHandler implementations? >>>> >>>> Big thanks! >>>> >>>> - Rafael >>> >>> Hi Rafael >>> >>> What you might want to do is to start with >>> AbstractServerExchangeHandler and add custom request processing and >>> response generation logic >>> >>> > https://github.com/apache/httpcomponents-core/blob/master/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AbstractServerExchangeHandler.java >>> < >>> https://github.com/apache/httpcomponents-core/blob/master/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AbstractServerExchangeHandler.java >>> >>> <https://github.com/apache/httpcomponents-core/blob/master/httpcore5/src/main/java/org/apache/hc/core5/http/nio/support/AbstractServerExchangeHandler.java> >>>> >>> >>> There is a project containing non-blocking (reactive) JSON message >>> processors with plenty of examples of fairly complex request >>> consumers >>> and response producers. >>> >>> > https://github.com/ok2c/httpcomponents-jackson/tree/master/hc5-async-json/src/main/java/com/ok2c/hc5/json/http > > <https://github.com/ok2c/httpcomponents-jackson/tree/master/hc5-async-json/src/main/java/com/ok2c/hc5/json/http> >>> < >>> https://github.com/ok2c/httpcomponents-jackson/tree/master/hc5-async-json/src/main/java/com/ok2c/hc5/json/http >>> >>> <https://github.com/ok2c/httpcomponents-jackson/tree/master/hc5-async-json/src/main/java/com/ok2c/hc5/json/http> >>>> >>> >>> Does this help in any way? If not, let me know what kind of request >>> messages your server is supposed to receive, what kind of response >>> messages it is supposed to send back and I can try and put together >>> a >>> sample server specifically for such message exchanges. >>> >>> Oleg >>> >>> >>> ----------------------------------------------------------------- >>> ---- >>> To unsubscribe, e-mail: [email protected] >>> <mailto:[email protected]> <mailto: >>> [email protected] <mailto:[email protected]>> >>> For additional commands, e-mail: [email protected] >>> <mailto:[email protected]> <mailto: >>> [email protected] <mailto:[email protected]>> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > <mailto:[email protected]> > For additional commands, e-mail: [email protected] > <mailto:[email protected]>
