Return-Path: X-Original-To: apmail-hc-httpclient-users-archive@www.apache.org Delivered-To: apmail-hc-httpclient-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 722289E18 for ; Tue, 3 Apr 2012 19:18:47 +0000 (UTC) Received: (qmail 91880 invoked by uid 500); 3 Apr 2012 19:18:47 -0000 Delivered-To: apmail-hc-httpclient-users-archive@hc.apache.org Received: (qmail 91796 invoked by uid 500); 3 Apr 2012 19:18:46 -0000 Mailing-List: contact httpclient-users-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpClient User Discussion" Delivered-To: mailing list httpclient-users@hc.apache.org Received: (qmail 91783 invoked by uid 99); 3 Apr 2012 19:18:46 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Apr 2012 19:18:46 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,NORMAL_HTTP_TO_IP,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of ribeirodesouza.diego@gmail.com designates 209.85.216.179 as permitted sender) Received: from [209.85.216.179] (HELO mail-qc0-f179.google.com) (209.85.216.179) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Apr 2012 19:18:38 +0000 Received: by qcha6 with SMTP id a6so29734qch.10 for ; Tue, 03 Apr 2012 12:18:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=qHBsg4LfkvPCL3ZqxapY2MupH5IEijXZBXYcPK/yzc4=; b=hihkyItJ8sXh29M+LQQML4Re81LFbDTzsyi816Pq6HNnXTvT81EWusctdO5FeeQG4Y tz6A1ypNuBqA0CC4e2hUAnakbLSb9cvoch2xQL781tuQ8VcYB0Aw0zRqfSOTiCjvH387 xSGQupALTqauW9E4ESz6AexE5mckUVs3mUX++GXhbcF8hwr3b8ZsdS0vsWA8bcrS5+nZ 0taQJ5ygAOFBbbJQ/cLDgvxDCcNrCEU739zhSQns5duEUsIPHrKMgBVZe3WcbvP7sgMU 0dFKQOBGn2FXctNsmEBhTLtMQ4mdso8pcNpGxp6TUDZxe0XBk7Wa4B48n4LngZfGS2vH a6Qw== MIME-Version: 1.0 Received: by 10.224.205.1 with SMTP id fo1mr18501331qab.99.1333480697126; Tue, 03 Apr 2012 12:18:17 -0700 (PDT) Received: by 10.229.24.196 with HTTP; Tue, 3 Apr 2012 12:18:16 -0700 (PDT) Date: Tue, 3 Apr 2012 16:18:16 -0300 Message-ID: Subject: Is possible to send a request through 3G moden and a network adapter? From: Diego Ribeiro de Souza To: httpclient-users@hc.apache.org Content-Type: multipart/alternative; boundary=20cf3005dcfc44609c04bccb2bda --20cf3005dcfc44609c04bccb2bda Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi there, I don=B4t have much experience with HttpClient and I=B4m afraid of doing something wrong. I=B4m trying to send a request through a 3G moden and another through my Network Adapter. I manage to send a request individually but whem I tried to send one request through de 3G modem and another through the network adapter only the the 3G Modem works, whem the HttpClient try to send the request through the network adapter this happens= : Response: HTTP/1.1 200 OK with the IP: /187.27.12.199 03/04/2012 13:50:59 org.apache.http.impl.client.DefaultRequestDirector tryConnect INFO: I/O exception (java.net.SocketException) caught when connecting to the target host: Network is unreachable: connect 03/04/2012 13:50:59 org.apache.http.impl.client.DefaultRequestDirector tryConnect INFO: Retrying connect 03/04/2012 13:50:59 org.apache.http.impl.client.DefaultRequestDirector tryConnect INFO: I/O exception (java.net.SocketException) caught when connecting to the target host: Network is unreachable: connect 03/04/2012 13:50:59 org.apache.http.impl.client.DefaultRequestDirector tryConnect INFO: Retrying connect 03/04/2012 13:50:59 org.apache.http.impl.client.DefaultRequestDirector tryConnect INFO: I/O exception (java.net.SocketException) caught when connecting to the target host: Network is unreachable: connect 03/04/2012 13:50:59 org.apache.http.impl.client.DefaultRequestDirector tryConnect INFO: Retrying connect Exception in thread "main" java.net.SocketException: Network is unreachable: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at java.net.Socket.connect(Socket.java:529) at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFac= tory.java:120) at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFac= tory.java:177) at org.apache.http.conn.scheme.SchemeSocketFactoryAdaptor.connectSocket(Scheme= SocketFactoryAdaptor.java:62) at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(De= faultClientConnectionOperator.java:148) at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:149= ) at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConn= Adapter.java:121) at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultReques= tDirector.java:562) at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDi= rector.java:415) at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.j= ava:820) at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.j= ava:754) at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.j= ava:732) at br.com.fiveware.Main.main(Main.java:40) The first line shows that the request went fine through the 3G, but the log and the exception shows that it wasn=B4t possible to find a connection through the network adapter. The code that a wrote is this: package org.test.httpclient; import java.io.*; import java.net.*; import java.util.*; import org.apache.http.*; import org.apache.http.client.*; import org.apache.http.client.methods.*; import org.apache.http.conn.params.*; import org.apache.http.conn.scheme.*; import org.apache.http.impl.client.*; import org.apache.http.impl.conn.tsccm.*; public class Main { private static final int HTTP_PORT =3D 80; @SuppressWarnings("deprecation") public static void main(String[] args) throws ClientProtocolException, IOException, UnhandledException { SchemeRegistry registry =3D new SchemeRegistry(); registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), HTTP_PORT)); ThreadSafeClientConnManager connectionManager =3D new ThreadSafeClientConnManager(); DefaultHttpClient client =3D new DefaultHttpClient(connectionManage= r); List ips =3D new ArrayList(); ips.add(InetAddress.getByName("187.27.12.199")); ips.add(InetAddress.getByName("192.168.1.172")); for (int i =3D 0; i < ips.size(); i++) { HttpGet get =3D new HttpGet("http://www.apache.org/"); get.getParams().setParameter(ConnRouteParams.LOCAL_ADDRESS, ips.get(i)); HttpResponse response =3D client.execute(get); InetAddress ip =3D (InetAddress) response.getParams().getParameter(ConnRouteParams.LOCAL_ADDRESS); System.out.println("Response: " + response.getStatusLine() + " with the IP: " + ip); } } } Is this a OS problem or there is a way of making this work? Thanks, Diego. --20cf3005dcfc44609c04bccb2bda--