You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// see http://netty.io/3.9/api/org/jboss/netty/channel/ChannelFuture.html
300
-
connectFuture.awaitUninterruptibly();
301
-
//assert connectFuture.isDone();
302
-
if (connectFuture.isDone()) {
303
-
logger.info("Connected to remote system " + host + ":" + port);
304
-
} else {
305
-
logger.info("Uncompleted connection to remote system " + host + ":" + port);
306
-
}
307
295
308
-
if (connectFuture.isCancelled()) {
309
-
thrownewInterruptedException("connectFuture cancelled by user");
310
-
} elseif (!connectFuture.isSuccess()) {
311
-
if (connectFuture.getCause() instanceoforg.jboss.netty.channel.ConnectTimeoutException) {
312
-
thrownewSmppChannelConnectTimeoutException("Unable to connect to host [" + host + "] and port [" + port + "] within " + connectTimeoutMillis + " ms", connectFuture.getCause());
313
-
} else {
314
-
thrownewSmppChannelConnectException("Unable to connect to host [" + host + "] and port [" + port + "]: " + connectFuture.getCause().getMessage(), connectFuture.getCause());
315
-
}
316
-
}
296
+
297
+
// if (connectFuture.isDone()) {
298
+
// logger.info("Connected to remote system " + host + ":" + port);
299
+
// } else {
300
+
// logger.info("Uncompleted connection to remote system " + host + ":" + port);
301
+
// }
302
+
303
+
// Wait until the connection is made successfully.
304
+
// According to the netty documentation it is bad to use .await(timeout). Instead
305
+
// b.setOption("connectTimeoutMillis", 10000);
306
+
// should be used. See http://netty.io/3.9/api/org/jboss/netty/channel/ChannelFuture.html
307
+
// It turns out that under certain unknown circumstances the connect waits forever: https://github.com/twitter/cloudhopper-smpp/issues/117
308
+
// That's why the future is canceled 1 second after the specified timeout.
309
+
// This is a workaround and hopefully not needed after the switch to netty 4.
310
+
if (!connectFuture.await(connectTimeoutMillis + 1000)) {
311
+
logger.error("connectFuture did not finish in expected time! Try to cancel the connectFuture");
thrownewSmppChannelConnectTimeoutException("Could not connect to the server within timeout");
315
+
}
316
+
317
+
if (connectFuture.isCancelled()) {
318
+
thrownewInterruptedException("connectFuture cancelled by user");
319
+
} elseif (!connectFuture.isSuccess()) {
320
+
if (connectFuture.getCause() instanceoforg.jboss.netty.channel.ConnectTimeoutException) {
321
+
thrownewSmppChannelConnectTimeoutException("Unable to connect to host [" + host + "] and port [" + port + "] within " + connectTimeoutMillis + " ms", connectFuture.getCause());
322
+
} else {
323
+
thrownewSmppChannelConnectException("Unable to connect to host [" + host + "] and port [" + port + "]: " + connectFuture.getCause().getMessage(), connectFuture.getCause());
324
+
}
325
+
}
317
326
318
327
logger.info("Successfully connected to remote system " + host + ":" + port);
319
328
// if we get here, then we were able to connect and get a channel
0 commit comments