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
Fixed issue with connection being stuck on awaitUninterruptibly() as per fizzed#1
Fixed blocking issue at channel write.
Related issue RestComm/smpp-extensions#28
// see http://netty.io/3.9/api/org/jboss/netty/channel/ChannelFuture.html
286
-
connectFuture.awaitUninterruptibly();
287
-
//assert connectFuture.isDone();
288
-
289
-
if (connectFuture.isCancelled()) {
290
-
thrownewInterruptedException("connectFuture cancelled by user");
291
-
} elseif (!connectFuture.isSuccess()) {
292
-
if (connectFuture.getCause() instanceoforg.jboss.netty.channel.ConnectTimeoutException) {
293
-
thrownewSmppChannelConnectTimeoutException("Unable to connect to host [" + host + "] and port [" + port + "] within " + connectTimeoutMillis + " ms", connectFuture.getCause());
294
-
} else {
295
-
thrownewSmppChannelConnectException("Unable to connect to host [" + host + "] and port [" + port + "]: " + connectFuture.getCause().getMessage(), connectFuture.getCause());
296
-
}
297
-
}
296
+
/* Wait until the connection is made successfully.
297
+
* According to the netty documentation it is bad to use .await(timeout). Instead
298
+
* b.setOption("connectTimeoutMillis", 10000);
299
+
* should be used. See http://netty.io/3.9/api/org/jboss/netty/channel/ChannelFuture.html
300
+
* It turns out that under certain unknown circumstances the connect waits forever: https://github.com/twitter/cloudhopper-smpp/issues/117
301
+
* That's why the future is canceled 1 second after the specified timeout.
302
+
* This is a workaround and hopefully not needed after the switch to netty 4.
303
+
*/
304
+
if (!connectFuture.await(connectTimeoutMillis + 1000)) {
305
+
logger.error("connectFuture did not finish in expected time! Try to cancel the connectFuture");
thrownewSmppChannelConnectTimeoutException("Could not connect to the server within timeout");
309
+
}
298
310
299
-
// if we get here, then we were able to connect and get a channel
300
-
returnconnectFuture.getChannel();
311
+
if (connectFuture.isCancelled()) {
312
+
thrownewInterruptedException("connectFuture cancelled by user");
313
+
} elseif (!connectFuture.isSuccess()) {
314
+
if (connectFuture.getCause() instanceoforg.jboss.netty.channel.ConnectTimeoutException) {
315
+
thrownewSmppChannelConnectTimeoutException("Unable to connect to host [" + host + "] and port [" + port + "] within " + connectTimeoutMillis + " ms", connectFuture.getCause());
316
+
} else {
317
+
thrownewSmppChannelConnectException("Unable to connect to host [" + host + "] and port [" + port + "]: " + connectFuture.getCause().getMessage(), connectFuture.getCause());
318
+
}
319
+
}
320
+
321
+
logger.debug("Successfully connected to remote system " + host + ":" + port);
322
+
// if we get here, then we were able to connect and get a channel
0 commit comments