I am using Apache Camel route for HTTP call. I wanted to add timeout if there is delay from host system.
I am using the following configuration but it is not working. The client request is getting timeout without waiting host system timeout. The client timeout is configured in CXF but the camel timeout is configured in camel route. It should timeout in 4 second and it should go to error processor and but it is not happening.
HTTP
<setHeader headerName="CamelHttpQuery">
<constant>httpclient.soTimeout=4000&bridgeEndpoint=true&throwExceptionOnFailure=false</constant>
<setHeader>
HTTP4
<setHeader headerName="CamelHttpQuery"><constant>httpclient.socketTimout=4000&bridgeEndpoint=true&throwExceptionOnFailure=false</constant>
<setHeader>
Thanks
Please be attentive for syntax. Correct spelling
httpClient.socketTimeout=4000&bridgeEndpoint=true&throwExceptionOnFailure=false
But even after correcting parameters it will not work. Instead of configuring http endpoint you send your parameters as query string of request to server. For set up endpoint just add your parameters to it and use CamelHttpQuery header for request parameters.
Related
I have a Java application which was built with Apache Camel. The application uses Apache Camel to construct an HTTP request to AWS VPC Endpoint.
When the Java application sends out an HTTP request, it receives HTTP Status Code 400 (Bad Request). The VPC Flow Log can be found with the traffic (correct source and destination IP addresses).
On the other hand, if we use curl command to send the same HTTP request, it turns back 200 OK.
What is a possible cause? Is there any configuration in Apache Camel to see what is the exact HTTP content or raw HTTP header/message sent out?
You could check if Content-Type and other mandatory request headers are available at Exchange.in.headers. Just log in.headers within camel-simple tag. I think 400 happening because improper content-type or bad payload.
It might be that you are sending headers that are not allowed by the API since Camel maps message headers automatically to HTTP headers.
Camel's camel-http4 component uses Apache HttpClient 4.x library and you can configure it to log raw http requests.
For instance with log4j you would add to properties:
log4j.logger.org.apache.http=DEBUG
Detailed logging options can be seen from here: https://hc.apache.org/httpcomponents-client-4.5.x/logging.html
I've been trying to use Apache Camel's Http4 component to connect to a HTTPS URL that needs Basic authentication. The connection needs to be done through an authenticated HTTP proxy.
So, according to the docs, I configure the Camel endpoint like this:
.toD("https4://target.host/resource?
bridgeEndpoint=true
&mapHttpMessageBody=false
&proxyAuthHost=my.proxy.host
&proxyAuthPort=myProxyPort
&proxyAuthUsername=proxyUser
&proxyAuthPassword=proxyPassword
&proxyAuthScheme=http4
&authenticationPreemptive=true
&authUsername=myUser
&authPassword=myPassword")
Which results in a 403 - Forbidden response from the target server. Looking through the org.apache.http.wire logs, it shows that the proxy credentials proxyUser / proxyPassword are forwarded to the target server instead of the intended myUser/myPassword in the Authorization header.
Debugging the source for CompositeHTTPConfigurer.configureHttpClient, ProxyHttpClientConfigurer.configureHttpClient and BasicAuthenticationHttpClientConfigurer.configureHttpClient, it seems that because both configurers are setting their credentials to the HttpClientBuilder by means of setDefaultCredentialsProvider, one of them is lost - gets overwritten - in the process.
Looks like it could be a bug in Camel's Http4 component? Or am I missing something?
This is Camel 2.18.2 with Spring Boot 1.5.1.RELEASE.
After raising this question on the Apache Camel Users list, it seems the bug is confirmed.
I solved it using camel-http instead of camel-http4. Endpoint parameters needed a slight tweaking:
.toD("https://target.host/resource?
bridgeEndpoint=true
&proxyHost=my.proxy.host
&proxyPort=myProxyPort
&proxyAuthUsername=proxyUser
&proxyAuthPassword=proxyPassword
&proxyAuthMethod=Basic
&authUsername=myUser
&authPassword=myPassword
&authMethod=Basic
&httpClient.authenticationPreemptive=true")
I want to download a CSV file from HTTPS server and send it to SFTP server and I'm using HTTP4 componenet for HTTPS. Is it possible to combine two routes?
{
from("https4:www.00000/00/downloads/sdn.csv?")
.to("sftp://0000000/myhome/?fileName=${file:name}&\");
}
You need to start with a timer or other "trigger" in order to "get" the file from an http site. By default, 'from uri="http.."' tells Camel to listen on an http port. Also, a Polling Consumer may be helpful.
ref: http://camel.apache.org/timer.html
ref: http://camel.apache.org/polling-consumer.html
Pseudo code:
from("timer:...")
.setHeader(Exchange.HTTP_METHOD, constant(org.apache.camel.component.http4.HttpMethods.GET))
.to("https4:www....") <-- Note: the return is now the ${body} in Camel
.to("sftp://...")
i have a question for you guys, do you know a way how can i send http request with jmeter to my soap webservice(jax-ws library)?. I have a problem to point server name or ip(its localhost so should it be loopback?) and path. I'm using glassfish4 as my web server. I do not want to use option SOAP/XML RPC Request, because when i use it with my web service i can't see that any data have been sent(it's always 0 -in fact maybe you have idea why is that...it's also a solution to my problem because i need http request to see how much data i've sent)
!https://postimg.org/image/mpbai5n1v/
Thanks in advance
Regards!
Use:
Http Request and fill in:
Server Name or IP
IP if different from 443 or 80
Protocol if https
Add a Header Manager under it with :
Content-Type=text/xml; charset=utf-8
Note there is a template that lets you easily create this, see screenshot:
Finally I suggest you read this tutorial:
http://jmeter.apache.org/usermanual/build-ws-test-plan.html
Using org.mortbay.jetty.Server;
I initialized my Jetty server to port 8080 (in the xml ).
server = (Server) applicationContext.getBean("JettyServer");
I am sending HTTP messages (GET,PUT,HEAD) to my server on address: http://localhost:8080.
But instead of handling the requests like i defind with handlrs the server returns 404 "Server out-bound response".
What am i doin wrong?
Thanks.
Have you attached a handler to handle the requests ? See this as demonstrated at http://wiki.eclipse.org/Jetty/Tutorial/Embedding_Jetty - HelloHandler
you will also need to set a contextHandler - See Setting Contexts section in above link and you will need to hit that URL while querying it.