|
|
Connection timed out
I want to test this code which establishes SSL connection with theserver. Why it throws the exception as below. Also, how to retrievethe content of the desired page on that host?:import java.io.BufferedReader;import java.io.InputStreamReader;import java.io.PrintWriter;import java.security.Principal;import java.security.cert.X509Certificate;import javax.net.ssl.SSLPeerUnverifiedException;import javax.net.ssl.SSLSession;import javax.net.ssl.SSLSocket;import javax.net.ssl.SSLSocketFactory;public class MainClass { public static void main(String[] args) throws Exception { SSLSocketFactory factory = (SSLSocketFactory)SSLSocketFactory.getDefault(); String hostName = "website.com"; String fileName = ""; SSLSocket sslsock = (SSLSocket) factory.createSocket(hostName,443); SSLSession session = sslsock.getSession(); X509Certificate cert; try { cert = (X509Certificate) session.getPeerCertificates()[0]; } catch (SSLPeerUnverifiedException e) { System.err.println(session.getPeerHost() + " did not present avalid certificate."); return; } System.out.println(session.getPeerHost() + " has presented acertificate belonging to:"); Principal p = cert.getSubjectDN(); System.out.println("\t[" + p.getName() + "]"); System.out.println("The certificate bears the valid signatureof:"); System.out.println("\t[" + cert.getIssuerDN().getName() + "]"); System.out.print("Do you trust this certificate (y/n)? "); System.out.flush(); BufferedReader console = new BufferedReader(newInputStreamReader(System.in)); if (Character.toLowerCase(console.readLine().charAt(0)) != 'y') return; PrintWriter out = new PrintWriter(sslsock.getOutputStream()); out.print("GET " + fileName + " HTTP/1.0\r\n\r\n"); out.flush(); BufferedReader in = new BufferedReader(newInputStreamReader(sslsock.getInputStream())); String line; while ((line = in.readLine()) != null) System.out.println(line); sslsock.close(); }}Exception in thread "main" java.net.ConnectException: Connection timedout: connect at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(Unknown Source) at java.net.PlainSocketImpl.connectToAddress(Unknown Source) at java.net.PlainSocketImpl.connect(Unknown Source) at java.net.SocksSocketImpl.connect(Unknown Source) at java.net.Socket.connect(Unknown Source) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(Unknown Source) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.<init>(Unknown Source) atcom.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl.createSocket(UnknownSource) at SSL.SSLTest.main(SSLTest.java:20)
|
|
0
|
|
|
|
Reply
|
vunet.us (106)
|
10/2/2007 9:00:00 PM |
|
|
0 Replies
260 Views
(page loaded in 0.044 seconds)
Similiar Articles: Connection timed out - comp.lang.java.programmerI want to test this code which establishes SSL connection with theserver. Why it throws the exception as below. Also, how to retrievethe content of th... connection timed out while connecting to localhost - comp.unix ...connection timed out while connecting to localhost - comp.unix ... connection timed out while connecting to localhost - comp.unix ... connection timed out while ... NFS getattr failed: error 5 (RPC: Timed out) - comp.unix.solaris ...I'm having odd problems with a solaris 10 client, talking to a solaris 9 NFS server. every so often, access to an NFS server will have problems, with ... FTP - times out - connection reset - comp.dcom.xdslHello All: I have difficulties to FTP upload+download, I am not hosting FTP. When I use DUN works flawlessly. The client is WS_FTP and the host is SE... NFS client error : NFS write failed for server - comp.unix.solaris ...... server shlight: error 5 (RPC: Timed out) >NFS write failed for server shlight: error 5 (RPC: Timed out) >cp: /export/home/prod/import/a.tar: write: Connection timed out ... How to set HTTP connect timeout - comp.lang.javascriptConnection timed out - comp.lang.java.programmer How to set HTTP connect timeout - comp.lang.javascript idle timeouts (ssh and telnet): where is this set? - comp.unix ... FTP: lost connection while transfering multiple files - comp.unix ...While transfering hundreds of files to our sun solaris 8 box file transfer interupts. This happens with z/OS (OS/390) and Windows NT clients. Time out... How to make the 'default route' permanent across reboots? - comp ...# nslookup sun.com ;; connection timed out; no servers could be reached The file /etc/deraultroute exists, and has the right IP for the router. [BEA][Oracle JDBC Driver]No more data available to read. - comp ...Markus Tazl wrote: > It just looks as if your ResultSet was closed. > This may happen because of a closed connection, > a timed out connection, (it might be even a ... Problem with java connection using soap and wsdl - comp.soft-sys ...... keep crashing out in java on one of the following errors depending on exactly how I invoke the function it seems: java.net.ConnectException: Connection timed out ... Internet Explorer error "connection timed out" when server does ...Explains why you receive an error message when you connect to a Web site that runs for a while before it returns information to Internet Explorer. TCP/IP Error Code 10060: Connection Timed Out | eHow.comThe Internet is essentially a global computer network. When a user directs their Web browser to a particular website, for example, the browser sends a request to ... 7/26/2012 1:14:35 PM
|
|
|
|
|
|
|
|
|