How to open an HttpURLConnection via proxy on google app engine?

11 views
Skip to first unread message

小犬 謝 via StackOverflow

unread,
Jan 22, 2015, 8:26:42 AM1/22/15
to google-appengin...@googlegroups.com

I want to open an HttpURLConnection via proxy on google app engine. I'm using java.

I've tried using the following methods.

Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("xxxxxx", 3128));  
HttpURLConnection conn = (HttpURLConnection) url.openConnection(proxy);  

However it shows exception

java.security.AccessControlException: access denied ("java.net.SocketPermission" "xxxx:3128" "connect,resolve")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:375)
at java.security.AccessController.checkPermission(AccessController.java:565)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)

And I tried another method

    System.setProperty("http.proxyHost", "xxxxx");
    System.setProperty("http.proxyPort", "3128");

And it doesn't work at all.

I'm wonder is there a way can let me open an HttpURLConnection via proxy on google app engine using java?

Thank you!



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/28089835/how-to-open-an-httpurlconnection-via-proxy-on-google-app-engine

小犬 謝 via StackOverflow

unread,
Jan 22, 2015, 9:06:43 AM1/22/15
to google-appengin...@googlegroups.com

I want to open an HttpURLConnection via proxy on google app engine. I'm using java.

I've tried using the following methods.

Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("xxxxxx", 3128));  
HttpURLConnection conn = (HttpURLConnection) url.openConnection(proxy);  

However it shows exception

java.security.AccessControlException: access denied ("java.net.SocketPermission" "xxxx:3128" "connect,resolve")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:375)
at java.security.AccessController.checkPermission(AccessController.java:565)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)

And I tried another method

    System.setProperty("http.proxyHost", "xxxxx");
    System.setProperty("http.proxyPort", "3128");

And it doesn't work at all.

When i run GAE with Proxy using personal computer(not deploy to cloud) , it shows

java.lang.UnsupportedOperationException: Google App Engine does not support the use of proxies.
at com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler.openConnection(URLFetchServiceStreamHandler.java:54)
at com.google.appengine.tools.development.LocalURLFetchServiceStreamHandler.openConnection(LocalURLFetchServiceStreamHandler.java:77)
at java.net.URL.openConnection(Unknown Source)
Reply all
Reply to author
Forward
0 new messages