Re: host not found when using http4 in docker container

2018-06-06 Thread Tim Dudgeon

OK, I think I worked out how to resolve this.
It seems you need to have a `depends_on` property in the container that 
is posting the HTTP request. The service that is receiving the request 
need to be present in the `depends_on` otherwise Java cannot resolve the 
host names (even though the operating system can). e.g. in my case I 
needed to specify something like this:


    depends_on:
    coreservices:
    condition: service_healthy

Clearly a Docker and Java thing, not really anything to do with Camel or 
the HTTP4 component.

But very strange nonetheless!


On 06/06/18 04:35, Willem Jiang wrote:

Can  you add a link  to the camel container just like this ?

camel:
image: "camel:0.3.0-SNAPSHOT"
hostname: camel
links:
- "otherHost"
- "zipkin:zipkin.io"


Willem Jiang

Twitter: willemjiang
Weibo: 姜宁willem

On Wed, Jun 6, 2018 at 4:40 AM, Tim Dudgeon  wrote:


On 05/06/18 20:40, Robin Vanderhallen wrote:


Are both containers in the same network in the docker compose file?


Yes. Both are in the same network environment, but this is not the default
network.

 networks:
 - xxx

Tim





Re: host not found when using http4 in docker container

2018-06-06 Thread Tim Dudgeon
I don't see how that would help (and the links attribute is a legacy 
feature and not recommended).


My situation is that the two containers are on the same network and can 
see each other. e.g. you can open a shell in one and ping the other 
using its hostname.

So the networking at the container level is perfectly OK.

The problem is that when using the HTTP4 camel component the same 
hostname does not get resolved. It looks like this is being done by the 
org.apache.http.impl.conn.SystemDefaultDnsResolver class in 
httpcomponents [1] which states in its docs: "DNS resolver that uses the 
default OS implementation for resolving host names." But it seems like 
it doesn't do this correctly?



[1] 
https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/conn/SystemDefaultDnsResolver.html


On 06/06/18 04:35, Willem Jiang wrote:

Can  you add a link  to the camel container just like this ?

camel:
image: "camel:0.3.0-SNAPSHOT"
hostname: camel
links:
- "otherHost"
- "zipkin:zipkin.io"


Willem Jiang

Twitter: willemjiang
Weibo: 姜宁willem

On Wed, Jun 6, 2018 at 4:40 AM, Tim Dudgeon  wrote:


On 05/06/18 20:40, Robin Vanderhallen wrote:


Are both containers in the same network in the docker compose file?


Yes. Both are in the same network environment, but this is not the default
network.

 networks:
 - xxx

Tim





Re: host not found when using http4 in docker container

2018-06-05 Thread Willem Jiang
Can  you add a link  to the camel container just like this ?

camel:
image: "camel:0.3.0-SNAPSHOT"
hostname: camel
links:
- "otherHost"
- "zipkin:zipkin.io"


Willem Jiang

Twitter: willemjiang
Weibo: 姜宁willem

On Wed, Jun 6, 2018 at 4:40 AM, Tim Dudgeon  wrote:

> On 05/06/18 20:40, Robin Vanderhallen wrote:
>
>> Are both containers in the same network in the docker compose file?
>>
> Yes. Both are in the same network environment, but this is not the default
> network.
>
> networks:
> - xxx
>
> Tim
>


Re: host not found when using http4 in docker container

2018-06-05 Thread Tim Dudgeon

On 05/06/18 20:40, Robin Vanderhallen wrote:

Are both containers in the same network in the docker compose file?
Yes. Both are in the same network environment, but this is not the 
default network.


    networks:
    - xxx

Tim


Re: host not found when using http4 in docker container

2018-06-05 Thread Robin Vanderhallen
Are both containers in the same network in the docker compose file?
On 5 Jun 2018, 19:29 +0200, Tim Dudgeon , wrote:
> I'm running camel inside a Docker container and trying to use the HTTP4
> component to post a request to a service running in a different
> container (both containers are managed through Docker compose).
> Essentially I'm trying to do a post to a route like this:
> http4:coreservices:8080/coreservices/rest/v1/services
> where coreservices is the name of the other container.
>
> This fails with a  java.net.UnknownHostException (see below).
> But the other container is definitely accessible from this container as
> if I open a shell in it I can the curl the 'coreservices' host.
>
> Any idea what's going wrong here?
>
> Thanks
> Tim
>
>
> 05-Jun-2018 17:09:34.667 SEVERE [localhost-startStop-1]
> org.apache.camel.util.CamelLogger.log Failed delivery for (MessageId:
> ID-4b81ce1e6383-46459-1528218572076-1-3 on ExchangeId:
> ID-4b81ce1e6383-46459-1528218572076-1-2). Exhausted after delivery
> attempt: 1 caught: java.net.UnknownHostException: coreservices: Name or
> service not known
>
> Message History
> ---
> RouteId  ProcessorId Processor Elapsed (ms)
> [route6    ] [route6    ]
> [direct://post-service-descriptors ] [   283]
> [route6    ] [log1  ] [log ] [ 5]
> [route6    ] [process1  ] [Processor@0xa8e9d5 ] [   173]
> [route6    ] [to1   ]
> [http4:coreservices:8080/coreservices/rest/v1/services ] [    95]
>
> Stacktrace
> ---
>  java.net.UnknownHostException: coreservices: Name or service not known
>     at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method)
>     at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928)
>     at
> java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323)
>     at java.net.InetAddress.getAllByName0(InetAddress.java:1276)
>     at java.net.InetAddress.getAllByName(InetAddress.java:1192)
>     at java.net.InetAddress.getAllByName(InetAddress.java:1126)
>     at
> org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:45)
>     at
> org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:111)
>     at
> org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
>     at
> org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
>     at
> org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
>     at
> org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
>     at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
>     at
> org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
>     at
> org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
>     at
> org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
>     at
> org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:55)
>     at
> org.apache.camel.component.http4.HttpProducer.executeMethod(HttpProducer.java:306)
>     at
> org.apache.camel.component.http4.HttpProducer.process(HttpProducer.java:178)
>     at
> org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
>     at
> org.apache.camel.processor.SendProcessor.process(SendProcessor.java:145)
>     at
> org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:77)
>     at
> org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:542)
>     at
> org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
>     at org.apache.camel.processor.Pipeline.process(Pipeline.java:120)
>     at org.apache.camel.processor.Pipeline.process(Pipeline.java:83)
>     at
> org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
>     at
> org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:62)
>     at
> org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:197)
>     at
> org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:97)
>     at
> org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerCache.java:529)
>     at
> org.apache.camel.impl.ProducerCache$1.doInProducer(ProducerCache.java:497)
>     at
> org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:365)
>     at
>