Two Laptop Bag
The moose likes Sockets and Internet Protocols and the fly likes Problem in proxy settings Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Reply Bookmark "Problem in proxy settings" Watch "Problem in proxy settings" New topic
Author

Problem in proxy settings

viruthachalam arunachalam
Greenhorn

Joined: Jun 29, 2007
Posts: 3
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
Marshal

Joined: Mar 22, 2005
Posts: 35257
    
    7
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?


Android appsImageJ pluginsJava web charts
viruthachalam arunachalam
Greenhorn

Joined: Jun 29, 2007
Posts: 3
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.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Problem in proxy settings
 
Similar Threads
SocketException in WSAD
Why settimeout is not working?
java.net.No Route To Host Exception: Operation timed out:
Connection refused on localhost
how to read files from internet