use of org.apache.http.conn.HttpHostConnectException in project lavaplayer by sedmelluq.
the class ExtendedConnectionOperator method connectWithDestination.
private boolean connectWithDestination(ConnectionSocketFactory socketFactory, HttpContext context, SocketConfig socketConfig, HttpHost host, InetSocketAddress localAddress, int connectTimeout, ManagedHttpClientConnection connection, InetSocketAddress remoteAddress, InetAddress[] addresses, boolean last) throws IOException {
Socket socket = socketFactory.createSocket(context);
configureSocket(socket, socketConfig);
try {
socket = socketFactory.connectSocket(connectTimeout, socket, host, remoteAddress, localAddress, context);
connection.bind(socket);
return true;
} catch (final SocketTimeoutException ex) {
if (last) {
throw new ConnectTimeoutException(ex, host, addresses);
}
} catch (final ConnectException ex) {
if (last) {
final String msg = ex.getMessage();
throw "Connection timed out".equals(msg) ? new ConnectTimeoutException(ex, host, addresses) : new HttpHostConnectException(ex, host, addresses);
}
} catch (final NoRouteToHostException ex) {
if (last) {
throw ex;
}
}
return false;
}
use of org.apache.http.conn.HttpHostConnectException in project tmdm-studio-se by Talend.
the class MDMServerMessageConsole method doMonitor.
private void doMonitor() {
String monitorURL = buildMonitorURL(position);
MessageConsoleStream errorMsgStream = newErrorMessageStream();
InputStream is = null;
BufferedReader br = null;
MessageConsoleStream msgStream = null;
InputStreamReader isr = null;
try {
HttpResponse response = executeByHttpget(monitorURL, serverDef.getUser(), serverDef.getPasswd());
int code = response.getStatusLine().getStatusCode();
if (HTTP_STATUS_OK == code) {
modifyChunkedPosition(response);
if (isEndOfChunk(response)) {
return;
}
is = response.getEntity().getContent();
msgStream = newMessageStream();
isr = new InputStreamReader(is);
br = new BufferedReader(isr);
String line = null;
while ((line = br.readLine()) != null) {
msgStream.println(line);
}
} else {
if (HTTP_STATUS_NO_ACCESS == code) {
errorMsgStream.println(Messages.MDMServerMessageConsole_No_Acess_Message);
disposeTimer();
} else if (HTTP_STSTUS_FORBIDDEN == code) {
errorMsgStream.println(Messages.MDMServerMessageConsole_Forbidden_Message);
disposeTimer();
} else if (HTTP_STATUS_NOT_FOUND == code) {
errorMsgStream.println(Messages.MDMServerMessageConsole_NotConnected_Message);
disposeTimer();
}
}
} catch (HttpHostConnectException ex) {
errorMsgStream.println(ex.getMessage());
disposeTimer();
} catch (IOException e) {
LOG.error(e.getMessage(), e);
errorMsgStream.println(e.getMessage());
disposeTimer();
} catch (SecurityException e) {
errorMsgStream.println(e.getMessage());
} finally {
if (br != null) {
try {
br.close();
} catch (IOException e) {
LOG.error(e.getMessage(), e);
}
}
if (isr != null) {
try {
isr.close();
} catch (IOException e) {
LOG.error(e.getMessage(), e);
}
}
if (is != null) {
try {
is.close();
} catch (IOException e) {
LOG.error(e.getMessage(), e);
}
}
if (msgStream != null) {
try {
msgStream.close();
} catch (IOException e) {
LOG.error(e.getMessage(), e);
}
}
if (errorMsgStream != null) {
try {
errorMsgStream.close();
} catch (IOException e) {
LOG.error(e.getMessage(), e);
}
}
}
}
Aggregations