title: Problem with gRPC setup. Getting an intermittent RPC unavailable error
body: <p>I have a grpc server and client that works as expected most of the time, but do get a "transport is closing" error occasionally:</p>
  
  <pre class="lang-none prettyprint-override"><code>rpc error: code = Unavailable desc = transport is closing
  </code></pre>
  
  <p>I'm wondering if it's a problem with my setup. The client is pretty basic</p>
  
  <pre><code>connection, err := grpc.Dial(address, grpc.WithInsecure(), grpc.WithBlock())
  pb.NewAppClient(connection)
  defer connection.Close()
  </code></pre>
  
  <p>and calls are made with a timeout like</p>
  
  <pre><code>ctx, cancel := context.WithTimeout(ctx, 300*time.Millisecond)
  defer cancel()
  
  client.MyGRPCMethod(ctx, params)
  </code></pre>
  
  <p>One other thing I'm doing is checking the connection to see if it's either open, idle or connecting, and reusing the connection if so. Otherwise, redialing. </p>
  
  <p>Nothing special configuration is happening with the server</p>
  
  <pre><code>grpc.NewServer()
  </code></pre>
  
  <p>Are there any common mistakes setting up a grpc client/server that I might be making?</p>