private Socket connectWithoutSSL() throws IOException, InterruptedException { Socket socket = null; int retries = 0; while (retries < MAX_RETRIES) { try { socket = new Socket(); socket.setSoTimeout(TIMEOUT); socket.connect(localServerAddress, TIMEOUT); break; } catch (ConnectException connectException) { connectException.printStackTrace(); forceClose(socket); socket = null; Thread.sleep(TIMEOUT); } retries++; } Assert.assertNotNull("Failed to connect to server without SSL", socket); return socket; }
private SSLSocket connectWithSSL() throws IOException, X509Exception, InterruptedException { SSLSocket sslSocket = null; int retries = 0; while (retries < MAX_RETRIES) { try { sslSocket = x509Util.createSSLSocket(); sslSocket.addHandshakeCompletedListener(new HandshakeCompletedListener() { @Override public void handshakeCompleted(HandshakeCompletedEvent handshakeCompletedEvent) { synchronized (handshakeCompletedLock) { handshakeCompleted = true; handshakeCompletedLock.notifyAll(); } } }); sslSocket.setSoTimeout(TIMEOUT); sslSocket.connect(localServerAddress, TIMEOUT); break; } catch (ConnectException connectException) { connectException.printStackTrace(); forceClose(sslSocket); sslSocket = null; Thread.sleep(TIMEOUT); } retries++; } Assert.assertNotNull("Failed to connect to server with SSL", sslSocket); return sslSocket; }
public static boolean isPortOpen(final String ip, final int port, final int timeout) { try { Socket socket = new Socket(); socket.connect(new InetSocketAddress(ip, port), timeout); socket.close(); return true; } catch (ConnectException ce) { ce.printStackTrace(); return false; } catch (Exception ex) { ex.printStackTrace(); return false; } }
public Socket get(int serverId) throws Exception { Socket sock = socketQueues[serverId].poll(); if (sock == null) { logForDebugging("creating new socket for server " + serverId); try { sock = new Socket(serverAddresses[serverId], BASE_PORT + serverId); sock.setTcpNoDelay(true); } catch (java.net.ConnectException e) { logForInfo("unable to connect to server #" + serverId); e.printStackTrace(); } } return sock; }
/** get all of the sockets needed for messaging */ public Socket[] getFromPool(boolean includeSelf) throws Exception { Socket[] socks = connectionsQueue.poll(); if (socks == null) { socks = new Socket[NUMBER_OF_SERVERS]; logForDebugging("creating new socket collection"); // In GemFire this would not pre-fill the collection with connections. // They would be created and added to the map as needed for sending the current message. for (int index = 0; index < NUMBER_OF_SERVERS; index++) { try { socks[index] = new Socket(serverAddresses[index], BASE_PORT + index); socks[index].setTcpNoDelay(true); } catch (java.net.ConnectException e) { logForInfo("unable to connect to server #" + index); e.printStackTrace(); } } } return socks; }
ce.printStackTrace(); logger .info("Weixin server connection timed out.");
Log.w(TAG, "Could not connect to QMP: " + e); if(Config.debugQmp) e.printStackTrace(); } catch(Exception e) {
if (showStackTrace) e.printStackTrace(); throw new IOException("** ConnectException on URL: <" + urlString + ">\n" + e.getMessage() + "\nServer probably not running");
if (showStackTrace) e.printStackTrace(); return new HttpResult(-2, "** ConnectException on URL: <" + urlString + ">\n" + e.getMessage() + "\nServer probably not running");
if (showStackTrace) e.printStackTrace(); throw new IOException("** ConnectException on URL: <" + urlString + ">\n" + e.getMessage() + "\nServer probably not running");
ce.printStackTrace(); System.err.println("Client: can not connect"); System.err.println("Try to launch receiver, emiter and server");
e.printStackTrace(); throw new CasProcessorDeploymentException(e); } catch (Exception e) {
e.printStackTrace(); return null;
private void receive() { try { Socket socket = null; BufferedReader in = null; try { socket = new Socket(host, port); in = new BufferedReader( new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8)); String userInput; while ((userInput = in.readLine()) != null) { store(userInput); } } finally { Closeables.close(in, /* swallowIOException = */ true); Closeables.close(socket, /* swallowIOException = */ true); } } catch(ConnectException ce) { ce.printStackTrace(); restart("Could not connect", ce); } catch(Throwable t) { t.printStackTrace(); restart("Error receiving data", t); } } }
private void receive() { try { Socket socket = null; BufferedReader in = null; try { socket = new Socket(host, port); in = new BufferedReader( new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8)); String userInput; while ((userInput = in.readLine()) != null) { store(userInput); } } finally { Closeables.close(in, /* swallowIOException = */ true); Closeables.close(socket, /* swallowIOException = */ true); } } catch(ConnectException ce) { ce.printStackTrace(); restart("Could not connect", ce); } catch(Throwable t) { t.printStackTrace(); restart("Error receiving data", t); } } }
Sage.rez("Network_Error"), javax.swing.JOptionPane.ERROR_MESSAGE); System.out.println("Error establishing server connection to " + serverName + " of:" + e); e.printStackTrace(); return false;
} catch (java.net.ConnectException e) { LOG.warn("fetch spark application from {} failed, {}", appURL, e); e.printStackTrace(); return true; } catch (Exception e) {