Skip to content

Commit

Permalink
[runtime] Improve error message for failed network connections due to…
Browse files Browse the repository at this point in the history
… limited number of file handles
  • Loading branch information
StephanEwen committed May 20, 2015
1 parent 825cea2 commit 89209a4
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,23 @@ private void initEpollBootstrap() {
ChannelFuture connect(SocketAddress serverSocketAddress) {
checkState(bootstrap != null, "Client has not been initialized yet.");

return bootstrap.connect(serverSocketAddress);
try {
return bootstrap.connect(serverSocketAddress);
}
catch (io.netty.channel.ChannelException e) {
if ( (e.getCause() instanceof java.net.SocketException &&
e.getCause().getMessage().equals("Too many open files")) ||
(e.getCause() instanceof io.netty.channel.ChannelException &&
e.getCause().getCause() instanceof java.net.SocketException &&
e.getCause().getCause().getMessage().equals("Too many open files")))
{
throw new io.netty.channel.ChannelException(
"The operating system does not offer enough file handles to open the network connection. " +
"Please increase the number of of available file handles.", e.getCause());
}
else {
throw e;
}
}
}
}

0 comments on commit 89209a4

Please sign in to comment.