On Wed, 2018-02-07 at 17:07 +0000, COURTAULT Francois wrote:
> Hello Yossi,
>
> Change to: server.awaitTermination(Long.MAX_VALUE,
> TimeUnit.NANOSECONDS);
> But never see "Simple HTTP server using Http Core started. Waiting
> for request ..." message unfortunately :-(
>
Why do you expect to see those lines in the first place?
---
server.start();
server.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS);
System.out.println("...
---
What that basically means is that the server starts and blocks in
#awaitTermination method until one two conditions takes place: the
server terminates or 2'147'483'647 days elapse. Only then the
System.out.println would be executed. You might not want to wait that
long and re-structure your application logic instead.
Oleg
PS: HttpCore does not have a separate user list. One should post
questions regarding HttpCore either to this list or the developer list.
> Best Regards.
>
> -----Original Message-----
> From: Yossi Tamari [mailto:[email protected]]
> Sent: mercredi 7 février 2018 17:57
> To: 'HttpClient User Discussion' <[email protected]>
> Subject: RE: Question about HttP Core
>
> Hi Francois,
>
> I believe the problem is that the implementation of awaitTermination
> in Java requires that the amount of time in *nanoseconds* is no more
> than Long.MAX_VALUE. This has nothing to do with HC.
> To get the maximum possible delay, just do
> server.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS); (This
> gives you close to 300 years, I hope that's enough...)
>
> Yossi.
>
> > -----Original Message-----
> > From: COURTAULT Francois [mailto:[email protected]]
> > Sent: 07 February 2018 18:35
> > To: [email protected]
> > Subject: Question about HttP Core
> >
> > Hello,
> >
> > First I don't know if I use the appropriate mailing-list. If I look
> > at
> > http://hc.apache.org/mail.html , my understanding is that I can't
> > use
>
> neither
> > HttpComponents Commits list nor HttpComponents Dev list, right ?
> >
> > I took a look at http://hc.apache.org/httpcomponents-core-
> > 4.4.x/examples.html and especially Synchronous HTTP file server.
> > I use this sample for my own purpose and I don't understand why
> > some
> > lines
>
> of
> > code are not working.
> > Basically, I have:
> >
> > SocketConfig socketConfig = SocketConfig.custom()
> > .setSoTimeout(15000)
> > .setTcpNoDelay(true)
> > .build();
> >
> > final HttpServer server = ServerBootstrap.bootstrap()
> > .setListenerPort(80)
> > .setServerInfo("My Server/1.1")
> > .setSocketConfig(socketConfig)
> > .setExceptionLogger(new StdErrorExceptionLogger())
> > .registerHandler("/myurl", new MyURLHandler())
> > .create();
> >
> >
> > try {
> > server.start();
> > server.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS);
> > System.out.println("Simple HTTP server using Http Core started.
> > Waiting
>
> for
> > request ..."); } catch (IOException | InterruptedException e) {
> > e.printStackTrace();
> > }
> >
> > Runtime.getRuntime().addShutdownHook(new Thread() {
> > @Override
> > public void run() {
> > server.shutdown(5, TimeUnit.SECONDS);
> > }
> > });
> >
> > If I keep server.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS);,
> > I
> > never saw Simple HTTP server using Http Core started. Waiting for
> > request ...
> > message.
> > Do you know why ?
> >
> > Best Regards.
> > ________________________________
> > This message and any attachments are intended solely for the
> > addressees
>
> and
> > may contain confidential information. Any unauthorized use or
> > disclosure,
>
> either
> > whole or partial, is prohibited.
> > E-mails are susceptible to alteration. Our company shall not be
> > liable
> > for
>
> the
> > message if altered, changed or falsified. If you are not the
> > intended
>
> recipient of
> > this message, please delete it and notify the sender.
> > Although all reasonable efforts have been made to keep this
> > transmission
>
> free
> > from viruses, the sender will not be liable for damages caused by a
>
> transmitted
> > virus.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
> ________________________________
> This message and any attachments are intended solely for the
> addressees and may contain confidential information. Any unauthorized
> use or disclosure, either whole or partial, is prohibited.
> E-mails are susceptible to alteration. Our company shall not be
> liable for the message if altered, changed or falsified. If you are
> not the intended recipient of this message, please delete it and
> notify the sender.
> Although all reasonable efforts have been made to keep this
> transmission free from viruses, the sender will not be liable for
> damages caused by a transmitted virus.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]