Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem in proxy settings  RSS feed

 
viruthachalam arunachalam
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The piece of code works fine in my home.But when iam using this code in my office by setting the proxy settings it throwing error as below.
error
-------
java.net.UnknownHostException: proxynt.pune.gsslco.co.in
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
at java.net.Socket.connect(Socket.java:519)
at java.net.Socket.connect(Socket.java:469)
at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:388)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:500)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:233)
at sun.net.www.http.HttpClient.New(HttpClient.java:306)
at sun.net.www.http.HttpClient.New(HttpClient.java:318)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:792)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:733)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:658)
at javaapplication6.NewMain.connectnet(NewMain.java:59)
at javaapplication6.NewMain.main(NewMain.java:105)
---------------
code

System.setProperty("https.proxyHost", "19.27.24.13");
System.setProperty("https.proxyPort", "83");
try
{
String urlName="http://proxynt.pune.gsslco.co.in:7890/intranet/finance/Annual_reports/annual_report_2000.pdf";
URL url = new URL(urlName);
File dat = new File("data.pdf");
FileOutputStream datStream = new FileOutputStream(dat);
URLConnection connection = url.openConnection();
String input = "username"+ ":" + "passord";
String encoding = new sun.misc.BASE64Encoder().encode (input.getBytes());

connection.setRequestProperty("Authorization", "Basic " + encoding);
connection.setDoOutput(true);
connection.connect();
-----------------------------------
[ July 02, 2007: Message edited by: viruthachalam arunachalam ]
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would imagine that the DNS used in your company doesn't publicize that server name inside of the company, because there are more direct ways of accessing that machine. Have you asked the network admin about this?
 
viruthachalam arunachalam
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have replaced the fuction with
SocketAddress addr = new InetSocketAddress(proxyadd,port);
Proxy proxy = new Proxy(Proxy.Type.HTTP, addr);
URLConnection connection = url.openConnection(proxy);
its working now. thanks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!