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

83 views
Skip to first unread message

謝昆荃

unread,
Jan 22, 2015, 8:51:58 AM1/22/15
to google-a...@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!

Vinny P

unread,
Jan 27, 2015, 2:12:24 AM1/27/15
to google-a...@googlegroups.com
On Thu, Jan 22, 2015 at 7:51 AM, 謝昆荃 <jets...@gmail.com> wrote:
I'm wonder is there a way can let me open an HttpURLConnection via proxy on google app engine using java?



You can open a HttpURLConnection, but App Engine's security sandbox prevents the use of the proxy aspect of the class. If you do need to connect via a proxy, try running your code on a managed VM: https://cloud.google.com/appengine/docs/java/managed-vms/
 
 
-----------------
-Vinny P
Technology & Media Consultant
Chicago, IL

App Engine Code Samples: http://www.learntogoogleit.com
 
Reply all
Reply to author
Forward
0 new messages