title: How to detect (physical) disconnect when using a bidirectional stream in Grpc
body: <p>I am using the synchronous C++ API of Grpc to send messages over a bidirectional stream that needs to be kept open indefinitely.</p>
  
  <p>Right now, if I pull the cable between server &amp; client, the <code>Write</code> and <code>Read</code> calls on that stream will block for about 15 minutes on both sides before returning <code>false</code>.</p>
  
  <p>How do I set the timeout of <code>Read</code>and <code>Write</code> to something less than 15 minutes?</p>
  
  <hr>
  
  <p>I am starting the Server with:</p>
  
  <pre><code>ServerBuilder srvBuilder;
  
  srvBuilder.AddChannelArgument(GRPC_ARG_KEEPALIVE_TIME_MS, 2000);
  srvBuilder.AddChannelArgument(GRPC_ARG_KEEPALIVE_TIMEOUT_MS, 1000);
  srvBuilder.AddChannelArgument(GRPC_ARG_HTTP2_BDP_PROBE, 1);
  srvBuilder.AddChannelArgument(GRPC_ARG_MAX_CONNECTION_IDLE_MS , 1000);
  
  srvBuilder.AddListeningPort("0.0.0.0:50505", grpc::InsecureServerCredentials());
  srvBuilder.RegisterService(&amp;testService);
  </code></pre>
  
  <p>Using Grpc 1.10.0 on Ubuntu 16.04 LTS</p>