2

I used Jodd Http library to connect with the proxy:

    ProxyInfo proxyInfoObj = new ProxyInfo(ProxyType.HTTP, "10.30.56.70", 8080, "", "");
    SocketHttpConnectionProvider provider =  new SocketHttpConnectionProvider();
    provider.useProxy(proxyInfoObj);
    HttpRequest request = HttpRequest.get(url);
    request.method("GET");
    request.charset("UTF-8");
    HttpResponse response = request.open(provider).send();
    result = response.bodyText();

But i got this error:

    jodd.http.HttpException: HTTP: Invalid code
    at jodd.http.net.HTTPProxySocketFactory.createHttpProxySocket(HTTPProxySocketFactory.java:113)
    at jodd.http.net.HTTPProxySocketFactory.createSocket(HTTPProxySocketFactory.java:32)

If I use SOCKS4 type, the program hang and don't return anything. Can anyone help me?

But I can connect via proxy using following code:

   Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("10.30.56.70", 8080));
    HttpURLConnection connection =(HttpURLConnection)new URL("http://tvl.csmtalk.vn/api/sms/receive").openConnection(proxy);
    connection.setDoOutput(true);
    connection.setDoInput(true);
    connection.setRequestProperty("Content-type", "text/xml");
    connection.setRequestProperty("Accept", "text/xml, application/xml");
    connection.setRequestMethod("GET");
    connection.connect();
Weasley
  • 21
  • 3
  • It hangs (on my side) because it can not open socket to `10.30.56.70:8080`. When I try to `telnet 10.30.56.70 8080` from command line it hangs as well. – igr Aug 30 '14 at 04:05

1 Answers1

1

For me both codes hangs. When I try Jodd, it hangs because it can not open proxy socket to 10.30.56.70:8080. When I try to

telnet 10.30.56.70 8080

from command line it hangs as well. It looks like proxy is not responding. (You can contact Jodd support if you need more details, or if you want to send some private data regarding the connectivity.)

btw, you don't need to:

request.method("GET");
request.charset("UTF-8");

as method is already set to GET by method get() and charset is not used for requests, but response (to set one if not set by server).

igr
  • 10,199
  • 13
  • 65
  • 111