Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > HTTP Error 407 Proxy authentication required

Reply
Thread Tools

HTTP Error 407 Proxy authentication required

 
 
ckarunprakash@gmail.com
Guest
Posts: n/a
 
      06-19-2013

I am trying to access the url by using this code

System.setProperty("http.proxyHost", "111.88.15.108");
System.setProperty("http.proxyPort", "8002");
System.setProperty("http.proxyUser", "user");
System.setProperty("http.proxyPassword", "password");
URL oracle = new URL("http://www.google.com/");
URLConnection yc = oracle.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(
yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)

System.out.println(inputLine);
in.close();

This is working fine in my window machine but this is not working in linux machine. i am getting eror like this

Exception in thread "main" java.io.IOException: Server returned HTTP response code: 407 for URL: http://www.google.com/ at sun.net.http://www.protocol.http.HttpURLConn...Stream(Unknown Source) at com.yahoo.Connection.main(Connection.java:31)

Even proxy settings are correct and i tried like this also

java -Dhttp.proxyHost="111.88.15.108" -Dhttp.proxyPort="8002" -Dhttp.proxyUser="user" -Dhttp.proxyPassword="password" -jar yahoo_test3.jar

But Same Error and i tried to set the export http_proxy= in /etc/profile but no use

Any idea where it is going wrong.
 
Reply With Quote
 
 
 
 
Real
Guest
Posts: n/a
 
      06-19-2013
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote in
news:(E-Mail Removed):

>
> I am trying to access the url by using this code
>
> System.setProperty("http.proxyHost", "111.88.15.108");
> System.setProperty("http.proxyPort", "8002");
> System.setProperty("http.proxyUser", "user");
> System.setProperty("http.proxyPassword", "password");
> URL oracle = new URL("http://www.google.com/");
> URLConnection yc = oracle.openConnection();
> BufferedReader in = new BufferedReader(new InputStreamReader(
> yc.getInputStream()));
> String inputLine;
> while ((inputLine = in.readLine()) != null)
>
> System.out.println(inputLine);
> in.close();
>
> This is working fine in my window machine but this is not working in
> linux machine. i am getting eror like this
>
> Exception in thread "main" java.io.IOException: Server returned
> HTTP response code: 407 for URL: http://www.google.com/ at
> sun.net.http://www.protocol.http.HttpURLConn...Stream(Unknown
> Source) at com.yahoo.Connection.main(Connection.java:31)


I believe you you need to use a java.net.Authenticator, something like

// PROXY
System.setProperty("http.proxyHost","proxy.mydomai n.local") ;
System.setProperty("http.proxyPort", "80") ;

Authenticator.setDefault(new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication
("mydomain\\username","password".toCharArray()) ;
}});

Bye.
--
Real Gagnon from Quebec, Canada
* Java, Javascript, VBScript or PowerBuilder snippets
* http://rgagnon.com/howto.html
* http://rgagnon.com/bigindex.html
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HTTP Status 407: Proxy Authentication Required Sau ASP .Net Web Services 2 12-15-2009 11:08 AM
Proxy Authentication Required - Error 407 UJ ASP .Net Web Services 0 08-15-2006 06:23 PM
407 Proxy authentication required? Ily ASP .Net 1 10-31-2005 04:44 PM
request failed with HTTP status 407: Proxy Authentication Required Scott O'Donnell ASP .Net Web Services 0 02-14-2005 12:23 AM
CSoapSocketClientT and HTTP: 407 Access Denied error through Proxy Server Dave Langley ASP .Net Web Services 4 09-04-2003 08:25 PM



Advertisments