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]