Emeka K
Emeka K

Reputation: 3

jetty BadMessage: 400 No Host for HttpChannelOverHttp

I have seen previous posts about Jetty BadMessage: 400 No Host for HttpChannelOverHttp and I can confirm that I am able to repeat the problem.

I have a Jetty route in Camel Blueprint, which creates another request and forwards on to a Dropwizard service via Camel HTTP.

.process(new Processor() {
//Creates Object for request
}

.marshal(jsonFormat)
.convertBodyTo(String.class)
.setHeader(Exchange.HTTP_URI, simple(serviceEndpoint))
.setHeader(Exchange.HTTP_METHOD, constant(HttpMethod.POST))
.to(userviceEndpoint)

When this request executes, I see the following error on Dropwizard

WARN  [2014-11-12 23:15:35,333] org.eclipse.jetty.http.HttpParser: BadMessage: 400 No Host for HttpChannelOverHttp@3aa99dd2{r=0,a=IDLE,uri=-}

This happens constantly, and this problem does not occur when I send a request to the DW service using SOAP-UI (using the serviceEndpoint URL).

Please if anyone has solved this problem, I would like to know how. Thank you.

Upvotes: 0

Views: 10589

Answers (3)

Husmus
Husmus

Reputation: 949

I got this error when I was making a request with incorrectly formatted headers. So instead of having the header as "X_S_ID: ABC" I had "X_S_ID: ["X_S_ID":BLAH]". So the error sometimes may not literally mean you need to pass a Host header.

Fixing the headers fixed this. Print the exact request you are making and make sure all headers are correctly formatted.

Upvotes: 0

Kunnu
Kunnu

Reputation: 79

In my case, I was setting header with null value. After removing header having null value from request solved the issue.

Jetty Version: 9.3.8

Upvotes: 0

Joakim Erdfelt
Joakim Erdfelt

Reputation: 49462

Capture your network traffic, and post the HTTP request headers you are sending to Jetty.

Odds are that your HTTP client is not sending the Host: header (which is required on HTTP/1.1)

Upvotes: 3

Related Questions