java.net.ConnectException.printStackTrace()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(136)

本文整理了Java中java.net.ConnectException.printStackTrace()方法的一些代码示例,展示了ConnectException.printStackTrace()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ConnectException.printStackTrace()方法的具体详情如下:
包路径:java.net.ConnectException
类名称:ConnectException
方法名:printStackTrace

ConnectException.printStackTrace介绍

暂无

代码示例

代码示例来源:origin: apache/zookeeper

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;
}

代码示例来源:origin: apache/zookeeper

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;
}

代码示例来源:origin: guardianproject/NetCipher

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;
  }
}

代码示例来源:origin: io.snappydata/gemfire-hydra-tests

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;
}

代码示例来源:origin: io.snappydata/gemfire-hydra-tests

/** 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;
}

代码示例来源:origin: zhangdaiscott/jeewx-api

ce.printStackTrace();
logger
    .info("Weixin server connection timed out.");

代码示例来源:origin: limboemu/limbo

Log.w(TAG, "Could not connect to QMP: " + e);
  if(Config.debugQmp)
    e.printStackTrace();
} catch(Exception e) {

代码示例来源:origin: edu.ucar/netcdf

if (showStackTrace) e.printStackTrace();
throw new IOException("** ConnectException on URL: <" + urlString + ">\n" +
  e.getMessage() + "\nServer probably not running");

代码示例来源:origin: edu.ucar/netcdf

if (showStackTrace) e.printStackTrace();
return new HttpResult(-2, "** ConnectException on URL: <" + urlString + ">\n" + e.getMessage() + "\nServer probably not running");

代码示例来源:origin: edu.ucar/netcdf

if (showStackTrace) e.printStackTrace();
throw new IOException("** ConnectException on URL: <" + urlString + ">\n" +
  e.getMessage() + "\nServer probably not running");

代码示例来源:origin: org.fudaa.business/dodico-corba

ce.printStackTrace();
System.err.println("Client: can not connect");
System.err.println("Try to launch receiver, emiter and server");

代码示例来源:origin: org.apache.uima/uimaj-cpe

e.printStackTrace();
 throw new CasProcessorDeploymentException(e);
} catch (Exception e) {

代码示例来源:origin: openpnp/openpnp

e.printStackTrace();
return null;

代码示例来源:origin: org.apache.spark/spark-streaming_2.11

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);
  }
 }
}

代码示例来源:origin: org.apache.spark/spark-streaming_2.10

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);
  }
 }
}

代码示例来源:origin: net.sf.taverna.t2.ui-impl/workbench-impl

ceex.printStackTrace();

代码示例来源:origin: openpnp/openpnp

e.printStackTrace();

代码示例来源:origin: google/sagetv

Sage.rez("Network_Error"), javax.swing.JOptionPane.ERROR_MESSAGE);
System.out.println("Error establishing server connection to " + serverName + " of:" + e);
e.printStackTrace();
return false;

代码示例来源:origin: apache/eagle

} catch (java.net.ConnectException e) {
  LOG.warn("fetch spark application from {} failed, {}", appURL, e);
  e.printStackTrace();
  return true;
} catch (Exception e) {

相关文章