• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem in proxy settings

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic