tohateam / google-api-translate-java

Automatically exported from code.google.com/p/google-api-translate-java
0 stars 0 forks source link

Connect to google api translate thru proxy #52

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I can not use your API in case of connecting to the internet threw proxy 

java.lang.Exception: [google-api-translate-java] Error retrieving translation.
    at com.google.api.translate.Translate.retrieveTranslation(Translate.java:92)
    at com.google.api.translate.Translate.translate(Translate.java:59)
    at com.al3omdah.Application.main(Application.java:18)
Caused by: java.net.UnknownHostException: ajax.googleapis.com
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection$6.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at sun.net.www.protocol.http.HttpURLConnection.getChainedException(Unknown
Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at com.google.api.translate.Translate.retrieveTranslation(Translate.java:88)
    ... 2 more
Caused by: java.net.UnknownHostException: ajax.googleapis.com
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at sun.net.NetworkClient.doConnect(Unknown Source)
    at sun.net.www.http.HttpClient.openServer(Unknown Source)
    at sun.net.www.http.HttpClient.openServer(Unknown Source)
    at sun.net.www.http.HttpClient.<init>(Unknown Source)
    at sun.net.www.http.HttpClient.New(Unknown Source)
    at sun.net.www.http.HttpClient.New(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown
Source)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
    at com.google.api.translate.Translate.retrieveTranslation(Translate.java:82)
    ... 2 more

Original issue reported on code.google.com by e.alblou...@gmail.com on 16 Jun 2009 at 12:29

GoogleCodeExporter commented 8 years ago
How have you setup your proxy connection? Try this code before running the 
translation:

Properties systemSettings = System.getProperties();
systemSettings.put("http.proxyHost", "myProxyServer.com");
systemSettings.put("http.proxyPort", "80");
System.setProperties(systemSettings);

It should work then.

Original comment by rich.mid...@gmail.com on 19 Jun 2009 at 9:15

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
But how can I connect thru proxy with username & password ?? because I still 
hava the
same error !!!

Original comment by e.alblou...@gmail.com on 21 Jun 2009 at 8:58

GoogleCodeExporter commented 8 years ago
I am having the same issue

Original comment by orochima...@hotmail.co.uk on 12 May 2011 at 11:22