title: Channel closed when running simple example with TLS
body: <p>I'm trying to run the official "Hello, World" example with TLS, provided by the gRPC team (<a href="https://github.com/grpc/grpc-java/tree/v1.15.0/examples/src/main/java/io/grpc/examples/helloworldtls" rel="nofollow noreferrer">code on GitHub</a>).</p>
  
  <p>I've cloned the official repo and checked out tag <code>v1.15.0</code>.</p>
  
  <p>I've run the installation script as follows (as shown in the documentation):</p>
  
  <pre><code>./gradlew installDist
  </code></pre>
  
  <p>I've edited the launch scripts for <code>hello-world-server</code> and <code>hello-world-client</code> to run the classes <code>io.grpc.examples.helloworldtls.HelloWorldServerTls</code> and <code>io.grpc.examples.helloworldtls.HelloWorldClientTls</code> respectively.</p>
  
  <p>I've created the certificates needed for the TLS authentication to happen using <a href="https://github.com/grpc/grpc-java/tree/v1.15.0/examples#generating-self-signed-certificates-for-use-with-grpc" rel="nofollow noreferrer">the script provided as part of the documentation</a> and stored them in a directory I named <code>cert</code>.</p>
  
  <p>Finally, I've run the server as follows:</p>
  
  <pre><code>./build/install/examples/bin/hello-world-server localhost 50440 cert/server.crt cert/server.pem
  </code></pre>
  
  <p>The server starts correctly and outputs the following:</p>
  
  <pre><code>Oct 08, 2018 9:15:10 AM io.grpc.examples.helloworldtls.HelloWorldServerTls start
  INFO: Server started, listening on 50440
  </code></pre>
  
  <p>Finally, I try to start the client on another shell with the following command:</p>
  
  <pre><code>./build/install/examples/bin/hello-world-client localhost 50440 cert/ca.crt
  </code></pre>
  
  <p>Unfortunately, the client fails with the following output:</p>
  
  <pre><code>Oct 08, 2018 9:25:22 AM io.grpc.examples.helloworldtls.HelloWorldClientTls greet
  INFO: Will try to greet localhost ...
  Oct 08, 2018 9:25:22 AM io.grpc.examples.helloworldtls.HelloWorldClientTls greet
  WARNING: RPC failed: Status{code=UNKNOWN, description=channel closed, cause=java.nio.channels.ClosedChannelException
      at io.grpc.netty.Utils.statusFromThrowable(Utils.java:169)
      at io.grpc.netty.NettyClientTransport$5.operationComplete(NettyClientTransport.java:260)
      at io.grpc.netty.NettyClientTransport$5.operationComplete(NettyClientTransport.java:254)
      at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:511)
      at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:485)
      at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:424)
      at io.netty.util.concurrent.DefaultPromise.setFailure(DefaultPromise.java:112)
      at io.netty.channel.DefaultChannelPromise.setFailure(DefaultChannelPromise.java:89)
      at io.grpc.netty.ProtocolNegotiators$AbstractBufferingHandler.fail(ProtocolNegotiators.java:564)
      at io.grpc.netty.ProtocolNegotiators$BufferUntilTlsNegotiatedHandler.userEventTriggered(ProtocolNegotiators.java:661)
      at io.netty.channel.AbstractChannelHandlerContext.invokeUserEventTriggered(AbstractChannelHandlerContext.java:329)
      at io.netty.channel.AbstractChannelHandlerContext.invokeUserEventTriggered(AbstractChannelHandlerContext.java:315)
      at io.netty.channel.AbstractChannelHandlerContext.fireUserEventTriggered(AbstractChannelHandlerContext.java:307)
      at io.netty.handler.ssl.SslUtils.handleHandshakeFailure(SslUtils.java:318)
      at io.netty.handler.ssl.SslHandler.setHandshakeFailure(SslHandler.java:1551)
      at io.netty.handler.ssl.SslHandler.channelInactive(SslHandler.java:1023)
      at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245)
      at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231)
      at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224)
      at io.netty.channel.DefaultChannelPipeline$HeadContext.channelInactive(DefaultChannelPipeline.java:1429)
      at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245)
      at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231)
      at io.netty.channel.DefaultChannelPipeline.fireChannelInactive(DefaultChannelPipeline.java:947)
      at io.netty.channel.AbstractChannel$AbstractUnsafe$8.run(AbstractChannel.java:822)
      at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
      at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)
      at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:464)
      at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)
      at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
      at java.base/java.lang.Thread.run(Thread.java:844)
  Caused by: java.nio.channels.ClosedChannelException
      at io.netty.handler.ssl.SslHandler.channelInactive(...)(Unknown Source)
  }
  </code></pre>
  
  <p>The error occurs with mutual authentication as well.</p>
  
  <p>I'm not sure what's going wrong or how to find the root cause of this, do you have any pointers?</p>