Return-Path: X-Original-To: apmail-hc-dev-archive@www.apache.org Delivered-To: apmail-hc-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1B84298B1 for ; Thu, 5 Jan 2012 21:47:19 +0000 (UTC) Received: (qmail 39661 invoked by uid 500); 5 Jan 2012 21:47:18 -0000 Delivered-To: apmail-hc-dev-archive@hc.apache.org Received: (qmail 39578 invoked by uid 500); 5 Jan 2012 21:47:18 -0000 Mailing-List: contact dev-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list dev@hc.apache.org Received: (qmail 39570 invoked by uid 99); 5 Jan 2012 21:47:17 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Jan 2012 21:47:17 +0000 X-ASF-Spam-Status: No, hits=0.7 required=5.0 tests=NORMAL_HTTP_TO_IP,SPF_NEUTRAL,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [217.150.250.48] (HELO kalnich.nine.ch) (217.150.250.48) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Jan 2012 21:47:10 +0000 Received: from [192.168.1.110] (77-57-197-206.dclient.hispeed.ch [77.57.197.206]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by kalnich.nine.ch (Postfix) with ESMTPSA id 2F024B82F86 for ; Thu, 5 Jan 2012 22:46:47 +0100 (CET) Message-ID: <1325800008.1888.16.camel@ubuntu> Subject: RE: httpcore nio SSL/proxy support From: Oleg Kalnichevski To: HttpComponents Project Date: Thu, 05 Jan 2012 22:46:48 +0100 In-Reply-To: References: <20120104164700.GC6388@kalnich.nine.ch> <20120104174247.GA5174@kalnich.nine.ch> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.1- Content-Transfer-Encoding: 7bit Mime-Version: 1.0 On Thu, 2012-01-05 at 19:25 +0000, Yongjian Li wrote: > Hi, one additional help. I tried to use the HttpAsyncClient to do upload via SSL&Proxy. Everything works great, except I have to use host name. If I use IP address, I got exception. Could you please help to see anything I did wrong? How to get around it? THX. > > Code snip: > HttpAsyncClient httpclient = new DefaultHttpAsyncClient(); > > HttpHost proxy = new HttpHost("10.97.196.145", 3128, "http"); > httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy); > > SSLContext ctx = SSLContext.getInstance("TLS"); > ctx.init(null, new X509TrustManager[]{new X509TrustManager(){ > public void checkClientTrusted(X509Certificate[] chain, String authType){;} > public void checkServerTrusted(X509Certificate[] chain, String authType){;} > public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0];} > }}, > null); > > //the allow all host name seems have no effect here > SSLLayeringStrategy sslLS = new SSLLayeringStrategy(ctx, new AllowAllHostnameVerifier()); > > AsyncScheme sch = new AsyncScheme("https", 8443, sslLS); > httpclient.getConnectionManager().getSchemeRegistry().register(sch); > httpclient.start(); > > try { > //will work if changed to host name > String url = "https://10.97.196.123:8443/cfcc/t.jsp"; > HttpUriRequest hp = new HttpPost(url); > > StringEntity se = new StringEntity("my dataddddddddddddddddddddddddddd"); > > ((HttpPost)hp).setEntity(se); > > Future future = httpclient.execute( HttpAsyncMethods.create(hp), new MyResponseConsumer(), null); > > Boolean result = future.get(); > if (result != null && result.booleanValue()) { > System.out.println("Request successfully executed"); > } else { > System.out.println("Request failed"); > } > System.out.println("Shutting down"); > } finally { > httpclient.shutdown(); > } > > > > Exception if using IP address: > > Exception in thread "main" java.util.concurrent.ExecutionException: org.apache.http.ProtocolException: Invalid request U > RI: 10.97.196.123:8443 > at org.apache.http.concurrent.BasicFuture.getResult(BasicFuture.java:61) > at org.apache.http.concurrent.BasicFuture.get(BasicFuture.java:70) > at AsyncClientHttpExchangeStreaming.main(AsyncClientHttpExchangeStreaming.java:124) > Caused by: org.apache.http.ProtocolException: Invalid request URI: 10.97.196.123:8443 > at org.apache.http.impl.client.RequestWrapper.(RequestWrapper.java:83) > at org.apache.http.impl.nio.client.DefaultAsyncRequestDirector.wrapRequest(DefaultAsyncRequestDirector.java:560) > > at org.apache.http.impl.nio.client.DefaultAsyncRequestDirector.generateRequest(DefaultAsyncRequestDirector.java: > 206) > at org.apache.http.nio.protocol.HttpAsyncClientProtocolHandler.requestReady(HttpAsyncClientProtocolHandler.java: > 113) > at org.apache.http.impl.nio.client.LoggingClientProtocolHandler.requestReady(LoggingClientProtocolHandler.java:9 > 0) > at org.apache.http.nio.protocol.HttpAsyncClientProtocolHandler.connected(HttpAsyncClientProtocolHandler.java:65) > > at org.apache.http.impl.nio.client.LoggingClientProtocolHandler.connected(LoggingClientProtocolHandler.java:58) > at org.apache.http.impl.nio.DefaultClientIODispatch.onConnected(DefaultClientIODispatch.java:103) > at org.apache.http.impl.nio.DefaultClientIODispatch.onConnected(DefaultClientIODispatch.java:49) > at org.apache.http.impl.nio.AbstractIODispatch.connected(AbstractIODispatch.java:76) > at org.apache.http.impl.nio.reactor.BaseIOReactor.sessionCreated(BaseIOReactor.java:252) > at org.apache.http.impl.nio.reactor.AbstractIOReactor.processNewChannels(AbstractIOReactor.java:427) > at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:291) > at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:106) > at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:59 > 9) > at java.lang.Thread.run(Thread.java:619) > Caused by: java.net.URISyntaxException: Illegal character in scheme name at index 0: 10.97.196.123:8443 > at java.net.URI$Parser.fail(URI.java:2809) > at java.net.URI$Parser.checkChars(URI.java:2982) > at java.net.URI$Parser.checkChar(URI.java:2992) > at java.net.URI$Parser.parse(URI.java:3008) > at java.net.URI.(URI.java:578) > at org.apache.http.impl.client.RequestWrapper.(RequestWrapper.java:81) > ... 15 more > > What version of HttpAsyncClient are you using? Besides, a wire / context log of the session would quite helpful. Oleg > > -----Original Message----- > From: Oleg Kalnichevski [mailto:olegk@apache.org] > Sent: Wednesday, January 04, 2012 12:43 PM > To: HttpComponents Project > Subject: Re: httpcore nio SSL/proxy support > > On Wed, Jan 04, 2012 at 04:59:34PM +0000, Yongjian Li wrote: > > Hi, thank you very much for your message. I didn't see GA version of HttpAsyncClient, I only see alpha3 build on download page. Is this the GA build? Or it is in HttpClient? THX. > > > > There has been no GA release yes, as HttpAsyncClient is still considered API unstable. It does not mean it is not usable, though. > > Oleg > > > > -----Original Message----- > > From: Oleg Kalnichevski [mailto:olegk@apache.org] > > Sent: Wednesday, January 04, 2012 11:47 AM > > To: dev@hc.apache.org > > Subject: Re: httpcore nio SSL/proxy support > > > > On Wed, 2012-01-04 at 15:59 +0000, Yongjian Li wrote: > > > I read an old post that httpcore nio does not support SSL over proxy. Is this addressed with the latest release? If not, could anyone help to give me some hints what I need to overwrite so that I can get it working? THX. > > > > > > > If you want an asynchronous HTTP client based on HttpCore that supports SSL via proxy among other things, you should be using HttpAsyncClient. > > > > http://hc.apache.org/httpcomponents-asyncclient-dev/index.html > > > > Oleg > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org For additional > > commands, e-mail: dev-help@hc.apache.org > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org For additional > > commands, e-mail: dev-help@hc.apache.org > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org For additional commands, e-mail: dev-help@hc.apache.org > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org > For additional commands, e-mail: dev-help@hc.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org For additional commands, e-mail: dev-help@hc.apache.org