You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Kaiser Sose <ca...@live.it> on 2010/02/19 17:08:13 UTC

Internal connection working only behind proxy????

Hi all,
I am wondering how to solve a really strange problem. :confused:
I am building a connection manager that makes dozens of requests to
different URI ... some of these requests are "Internal" (services are
internal to my company network) while for some other I need to set the
Proxy. Everything is working good exception made for ONE "Internal" service,
one of them who I shouldn't use the Proxy. If I try to reach this service I
get an awful "ClientProtocolException" but I really don't understand where
is the problem. For this internal service, if I set the proxy, I get an HTTP
200 RESPONSE .. so the INTERNAL SERVICE WORKS ONLY IF I USE A PROXY... in
order to be sure it was not a network problem I tried to reach the service
via browser (both explorer and firefox) and it works even if I don't set the
proxy, so I should reach this service through HttpClient!

mymanagerfunction(uri, usr, pwd) {

            [I do some jobs]

            // HERE I SET THE PROXY
            HttpGet httpget = new HttpGet(uri);
            if ( (!ProxyAddress.equals("")) && (ProxyPort > 0) ) {
                HttpHost aproxy = new HttpHost(ProxyAddress, ProxyPort);
               
httpget.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, aproxy);
            } 
            // HERE I CHECK IF I HAVE TO AUTHENTICATE FOR THIS HOST
            if (!usr.equals("")) {
                    httpclient.getCredentialsProvider().setCredentials(
                                        new
AuthScope(httpget.getURI().getHost(), 80),
                                        new UsernamePasswordCredentials(usr,
pwd));
            }

            if (!ProxyAddress.equals(""))
                System.out.println("PASSING THROUGH PROXY: " +
ProxyAddress);
            else
                System.out.println("NO PROXY");

            HttpResponse response = httpclient.execute(httpget);
}

I am blocked on this specific service and really have no idea of all that!
How can a proxy avoid such exception???? and why both the browsers get the
page passed as uri even if I don't use the proxy?

best regards, and tia :-)
-- 
View this message in context: http://old.nabble.com/Internal-connection-working-only-behind-proxy-----tp27655291p27655291.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Internal connection working only behind proxy????

Posted by Sam Crawford <sa...@gmail.com>.
Sorry, I'm afraid I don't know why you're not getting an empty header
back under other situations.

I'm seeing the following response headers from that URL, and I note
that the Server header and X-Powered-By headers are different from the
ones posted previously, so I can only assume you're working against a
development environment that may be setup differently (which would
invalidate this testing).

GET http://src-seo.pgol.com/seo/search?ln=1&pag=1&ord=a&tkc=20&cht=1 HTTP/1.1
Host: src-seo.pgol.com
Connection: Keep-Alive

HTTP/1.1 200 OK
Date: Mon, 22 Feb 2010 15:54:05 GMT
Server: Apache/2.2.3 (CentOS)
X-Powered-By: PHP/5.1.6
Content-Type: text/html; charset=UTF-8
Content-Length: 548
Connection: Keep-Alive

Thanks,

Sam


On 22 February 2010 13:57, Kaiser Sose <ca...@live.it> wrote:
>
>
> Sam Crawford wrote:
>>
>> Looks like your server is sending back invalid HTTP headers:
>>
>> DEBUG main org.apache.http.wire - << ": [EOL]"
>>
>> I'd suspect an Apache misconfiguration...
>>
>> Thanks,
>>
>> Sam
>>
>
> Hi Sam,
> debugging too I noticed an empty header arriving who cause the execute to
> crash during the header parsing. What I don't understand are the following
>
> 1 - Why does Firefox/IE works fine even if the server send back an empty
> header?
> 2 - I've tried to parse headers "live" with Firefox addons Live HTTPHeaders
> and that's what it sends back, why can't I see this empty header?
>
> http://src-seo.pgol.com/seo/search?ln=1&pag=1&ord=a&tkc=20&cht=2
>
> GET /seo/search?ln=1&pag=1&ord=a&tkc=20&cht=2 HTTP/1.1
> Host: my.host.net
> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; it; rv:1.9.2)
> Gecko/20100115 Firefox/3.6
> Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
> Accept-Language: it-it,it;q=0.8,en-us;q=0.5,en;q=0.3
> Accept-Encoding: gzip, deflate
> Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
> Keep-Alive: 115
> Connection: keep-alive
>
> HTTP/1.1 200 OK
> Date: Mon, 22 Feb 2010 13:40:57 GMT
> Server: Apache
> Keep-Alive: timeout=1
> Connection: Keep-Alive
> Transfer-Encoding: chunked
> Content-Type: text/xml
>
> Best Regards
> --
> View this message in context: http://old.nabble.com/Internal-connection-working-only-behind-proxy-----tp27655291p27687522.html
> Sent from the HttpClient-User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Internal connection working only behind proxy????

Posted by Kaiser Sose <ca...@live.it>.

Sam Crawford wrote:
> 
> Looks like your server is sending back invalid HTTP headers:
> 
> DEBUG main org.apache.http.wire - << ": [EOL]"
> 
> I'd suspect an Apache misconfiguration...
> 
> Thanks,
> 
> Sam
> 

Hi Sam,
debugging too I noticed an empty header arriving who cause the execute to
crash during the header parsing. What I don't understand are the following

1 - Why does Firefox/IE works fine even if the server send back an empty
header?
2 - I've tried to parse headers "live" with Firefox addons Live HTTPHeaders
and that's what it sends back, why can't I see this empty header?

http://src-seo.pgol.com/seo/search?ln=1&pag=1&ord=a&tkc=20&cht=2

GET /seo/search?ln=1&pag=1&ord=a&tkc=20&cht=2 HTTP/1.1
Host: my.host.net
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; it; rv:1.9.2)
Gecko/20100115 Firefox/3.6
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: it-it,it;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive

HTTP/1.1 200 OK
Date: Mon, 22 Feb 2010 13:40:57 GMT
Server: Apache
Keep-Alive: timeout=1
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/xml

Best Regards
-- 
View this message in context: http://old.nabble.com/Internal-connection-working-only-behind-proxy-----tp27655291p27687522.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Internal connection working only behind proxy????

Posted by Sam Crawford <sa...@gmail.com>.
Looks like your server is sending back invalid HTTP headers:

DEBUG main org.apache.http.wire - << ": [EOL]"

I'd suspect an Apache misconfiguration...

Thanks,

Sam


On 22 February 2010 11:34, Kaiser Sose <ca...@live.it> wrote:
>
>
> olegk wrote:
>>
>> When expecting help with a non-trivial problem with HttpCient _alway_
>> produce a wire / context log of an HTTP session that exhibits the problem.
>>
>> Oleg
>>
>
> Here are some more information I found ...
>
> Testcase:
> testSEO_doGetRequest(it.seat.pgol.service.httpconnectionpool.HttpConnectionManagerTest):
> Caused an ERROR
> null
> org.apache.http.client.ClientProtocolException
>        at
> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:643)
>        at
> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:576)
>        at
> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:554)
>        at
> it.seat.dol.http.connectionpool.HttpConnectionManager.doGetRequest(HttpConnectionManager.java:303)
>        at
> it.seat.dol.http.connectionpool.HttpConnectionManager.doGetRequest(HttpConnectionManager.java:235)
>        at
> it.seat.pgol.service.httpconnectionpool.HttpConnectionManagerTest.testSEO_doGetRequest(HttpConnectionManagerTest.java:177)
> Caused by: org.apache.http.ProtocolException: Invalid header: :
>        at
> org.apache.http.impl.io.AbstractMessageParser.parseHeaders(AbstractMessageParser.java:184)
>        at
> org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:214)
>        at
> org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:271)
>        at
> org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:227)
>        at
> org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:209)
>        at
> org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:292)
>        at
> org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:126)
>        at
> org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:483)
>        at
> org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:641)
>
> My Log:
>
> DEBUG main org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager -
> ThreadSafeClientConnManager.getConnection:
> HttpRoute[{}->http://src-seo.pgol.com], timeout = 0
> DEBUG main org.apache.http.impl.conn.tsccm.ConnPoolByRoute - Total
> connections kept alive: 0
> DEBUG main org.apache.http.impl.conn.tsccm.ConnPoolByRoute - Total issued
> connections: 0
> DEBUG main org.apache.http.impl.conn.tsccm.ConnPoolByRoute - Total allocated
> connection: 0 out of 100
> DEBUG main org.apache.http.impl.conn.tsccm.ConnPoolByRoute - No free
> connections [HttpRoute[{}->http://src-seo.pgol.com]][null]
> DEBUG main org.apache.http.impl.conn.tsccm.ConnPoolByRoute - Available
> capacity: 5 out of 5 [HttpRoute[{}->http://src-seo.pgol.com]][null]
> DEBUG main org.apache.http.impl.conn.tsccm.ConnPoolByRoute - Creating new
> connection [HttpRoute[{}->http://src-seo.pgol.com]]
> DEBUG main org.apache.http.client.protocol.RequestAddCookies - CookieSpec
> selected: best-match
> DEBUG main org.apache.http.impl.client.DefaultHttpClient - Attempt 1 to
> execute request
> DEBUG main org.apache.http.impl.conn.DefaultClientConnection - Sending
> request: GET /seo/search?ln=1&pag=1&ord=a&tkc=20&cht=1 HTTP/1.1
> DEBUG main org.apache.http.wire - >> "GET
> /seo/search?ln=1&pag=1&ord=a&tkc=20&cht=1 HTTP/1.1[EOL]"
> DEBUG main org.apache.http.wire - >> "Host: src-seo.pgol.com[EOL]"
> DEBUG main org.apache.http.wire - >> "Connection: Keep-Alive[EOL]"
> DEBUG main org.apache.http.wire - >> "[EOL]"
> DEBUG main org.apache.http.headers - >> GET
> /seo/search?ln=1&pag=1&ord=a&tkc=20&cht=1 HTTP/1.1
> DEBUG main org.apache.http.headers - >> Host: src-seo.pgol.com
> DEBUG main org.apache.http.headers - >> Connection: Keep-Alive
> DEBUG main org.apache.http.wire - << "HTTP/1.1 200 OK[EOL]"
> DEBUG main org.apache.http.wire - << "Date: Mon, 22 Feb 2010 11:28:57
> GMT[EOL]"
> DEBUG main org.apache.http.wire - << "Server: Apache[EOL]"
> DEBUG main org.apache.http.wire - << ": [EOL]"
> DEBUG main org.apache.http.wire - << "Keep-Alive: timeout=1[EOL]"
> DEBUG main org.apache.http.wire - << "Connection: Keep-Alive[EOL]"
> DEBUG main org.apache.http.wire - << "Transfer-Encoding: chunked[EOL]"
> DEBUG main org.apache.http.wire - << "Content-Type: text/xml[EOL]"
> DEBUG main org.apache.http.wire - << "[EOL]"
> DEBUG main org.apache.http.impl.conn.DefaultClientConnection - Connection
> closed
> DEBUG main org.apache.http.impl.conn.DefaultClientConnection - Connection
> shut down
> DEBUG main org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager -
> Released connection is not reusable.
> DEBUG main org.apache.http.impl.conn.tsccm.ConnPoolByRoute - Releasing
> connection [HttpRoute[{}->http://src-seo.pgol.com]][null]
> DEBUG main org.apache.http.impl.conn.tsccm.ConnPoolByRoute - Notifying
> no-one, there are no waiting threads
>
> Is it enough?? :confused:
>
>
> --
> View this message in context: http://old.nabble.com/Internal-connection-working-only-behind-proxy-----tp27655291p27685943.html
> Sent from the HttpClient-User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Internal connection working only behind proxy????

Posted by Kaiser Sose <ca...@live.it>.

olegk wrote:
> 
> When expecting help with a non-trivial problem with HttpCient _alway_ 
> produce a wire / context log of an HTTP session that exhibits the problem.
> 
> Oleg
> 

Here are some more information I found ...

Testcase:
testSEO_doGetRequest(it.seat.pgol.service.httpconnectionpool.HttpConnectionManagerTest):       
Caused an ERROR
null
org.apache.http.client.ClientProtocolException
        at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:643)
        at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:576)
        at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:554)
        at
it.seat.dol.http.connectionpool.HttpConnectionManager.doGetRequest(HttpConnectionManager.java:303)
        at
it.seat.dol.http.connectionpool.HttpConnectionManager.doGetRequest(HttpConnectionManager.java:235)
        at
it.seat.pgol.service.httpconnectionpool.HttpConnectionManagerTest.testSEO_doGetRequest(HttpConnectionManagerTest.java:177)
Caused by: org.apache.http.ProtocolException: Invalid header: : 
        at
org.apache.http.impl.io.AbstractMessageParser.parseHeaders(AbstractMessageParser.java:184)
        at
org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:214)
        at
org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:271)
        at
org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:227)
        at
org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:209)
        at
org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:292)
        at
org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:126)
        at
org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:483)
        at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:641)

My Log:

DEBUG main org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager -
ThreadSafeClientConnManager.getConnection:
HttpRoute[{}->http://src-seo.pgol.com], timeout = 0
DEBUG main org.apache.http.impl.conn.tsccm.ConnPoolByRoute - Total
connections kept alive: 0
DEBUG main org.apache.http.impl.conn.tsccm.ConnPoolByRoute - Total issued
connections: 0
DEBUG main org.apache.http.impl.conn.tsccm.ConnPoolByRoute - Total allocated
connection: 0 out of 100
DEBUG main org.apache.http.impl.conn.tsccm.ConnPoolByRoute - No free
connections [HttpRoute[{}->http://src-seo.pgol.com]][null]
DEBUG main org.apache.http.impl.conn.tsccm.ConnPoolByRoute - Available
capacity: 5 out of 5 [HttpRoute[{}->http://src-seo.pgol.com]][null]
DEBUG main org.apache.http.impl.conn.tsccm.ConnPoolByRoute - Creating new
connection [HttpRoute[{}->http://src-seo.pgol.com]]
DEBUG main org.apache.http.client.protocol.RequestAddCookies - CookieSpec
selected: best-match
DEBUG main org.apache.http.impl.client.DefaultHttpClient - Attempt 1 to
execute request
DEBUG main org.apache.http.impl.conn.DefaultClientConnection - Sending
request: GET /seo/search?ln=1&pag=1&ord=a&tkc=20&cht=1 HTTP/1.1
DEBUG main org.apache.http.wire - >> "GET
/seo/search?ln=1&pag=1&ord=a&tkc=20&cht=1 HTTP/1.1[EOL]"
DEBUG main org.apache.http.wire - >> "Host: src-seo.pgol.com[EOL]"
DEBUG main org.apache.http.wire - >> "Connection: Keep-Alive[EOL]"
DEBUG main org.apache.http.wire - >> "[EOL]"
DEBUG main org.apache.http.headers - >> GET
/seo/search?ln=1&pag=1&ord=a&tkc=20&cht=1 HTTP/1.1
DEBUG main org.apache.http.headers - >> Host: src-seo.pgol.com
DEBUG main org.apache.http.headers - >> Connection: Keep-Alive
DEBUG main org.apache.http.wire - << "HTTP/1.1 200 OK[EOL]"
DEBUG main org.apache.http.wire - << "Date: Mon, 22 Feb 2010 11:28:57
GMT[EOL]"
DEBUG main org.apache.http.wire - << "Server: Apache[EOL]"
DEBUG main org.apache.http.wire - << ": [EOL]"
DEBUG main org.apache.http.wire - << "Keep-Alive: timeout=1[EOL]"
DEBUG main org.apache.http.wire - << "Connection: Keep-Alive[EOL]"
DEBUG main org.apache.http.wire - << "Transfer-Encoding: chunked[EOL]"
DEBUG main org.apache.http.wire - << "Content-Type: text/xml[EOL]"
DEBUG main org.apache.http.wire - << "[EOL]"
DEBUG main org.apache.http.impl.conn.DefaultClientConnection - Connection
closed
DEBUG main org.apache.http.impl.conn.DefaultClientConnection - Connection
shut down
DEBUG main org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager -
Released connection is not reusable.
DEBUG main org.apache.http.impl.conn.tsccm.ConnPoolByRoute - Releasing
connection [HttpRoute[{}->http://src-seo.pgol.com]][null]
DEBUG main org.apache.http.impl.conn.tsccm.ConnPoolByRoute - Notifying
no-one, there are no waiting threads

Is it enough?? :confused:


-- 
View this message in context: http://old.nabble.com/Internal-connection-working-only-behind-proxy-----tp27655291p27685943.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Re: Internal connection working only behind proxy????

Posted by Oleg Kalnichevski <ol...@apache.org>.
Kaiser Sose wrote:
> Hi all,
> I am wondering how to solve a really strange problem. :confused:
> I am building a connection manager that makes dozens of requests to
> different URI ... some of these requests are "Internal" (services are
> internal to my company network) while for some other I need to set the
> Proxy. Everything is working good exception made for ONE "Internal" service,
> one of them who I shouldn't use the Proxy. If I try to reach this service I
> get an awful "ClientProtocolException" but I really don't understand where
> is the problem.

When expecting help with a non-trivial problem with HttpCient _alway_ 
produce a wire / context log of an HTTP session that exhibits the problem.

http://hc.apache.org/httpcomponents-client/logging.html

Oleg


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org