title: Hyperledger fabric Error: 14 UNAVAILABLE: TCP Write failed
body: <p>When chaincode container remains idle for some time then it stops with error:</p>
  
  <pre><code>ERROR [lib/handler.js] Chat stream with peer - on error: "Error: 14 UNAVAILABLE: EOF\n    at createStatusError (/usr/local/src/node_modules/grpc/src/client.js:64:15)\n    at ClientDuplexStream._emitStatusIfDone (/usr/local/src/node_modules/grpc/src/client.js:270:19)\n at ClientDuplexStream._receiveStatus (/usr/local/src/node_modules/grpc/src/client.js:248:8)\n    at /usr/local/src/node_modules/grpc/src/client.js:804:12"
  </code></pre>
  
  <p>And when the first request comes after idle time it gives an error of </p>
  
  <pre><code>Error: 14 UNAVAILABLE: TCP Write failed
  </code></pre>
  
  <p>After that for second request error changes to following:</p>
  
  <pre><code>Error: SERVICE_UNAVAILABLE
  at ClientDuplexStream.broadcast.on (/app/node_modules/fabric-client/lib/Orderer.js:172:22)
  at emitOne (events.js:116:13)
  at ClientDuplexStream.emit (events.js:211:7)
  at ClientDuplexStream._emitStatusIfDone (/app/node_modules/grpc/src/client.js:236:12)
  at ClientDuplexStream._receiveStatus (/app/node_modules/grpc/src/client.js:213:8)
  at Object.onReceiveStatus (/app/node_modules/grpc/src/client_interceptors.js:1290:15)
  at InterceptingListener._callNext (/app/node_modules/grpc/src/client_interceptors.js:564:42)
  at InterceptingListener.onReceiveStatus (/app/node_modules/grpc/src/client_interceptors.js:614:8)
  at /app/node_modules/grpc/src/client_interceptors.js:1110:18
  </code></pre>
  
  <p>From third request onwards all works fine.</p>
  
  <p>I was using fabric-shim 1.2.0 but after upgrading it to 1.3.0 the error appears randomly. </p>
  
  <p>I am using fabric 1.3.0.</p>
  
  <p>Edit:
  After upgrading fabric shim to 1.3.1, the error is changed to following:</p>
  
  <pre><code>error: [Orderer.js]: sendBroadcast - on error: "Error: 14 UNAVAILABLE: TCP Write failed\n    at Object.exports.createStatusError (/app/node_modules/grpc/src/common.js:87:15)\n    at ClientDuplexStream._emitStatusIfDone (/app/node_modules/grpc/src/client.js:235:26)\n    at ClientDuplexStream._receiveStatus (/app/node_modules/grpc/src/client.js:213:8)\n    at Object.onReceiveStatus (/app/node_modules/grpc/src/client_interceptors.js:1290:15)\n    at InterceptingListener._callNext (/app/node_modules/grpc/src/client_interceptors.js:564:42)\n    at InterceptingListener.onReceiveStatus (/app/node_modules/grpc/src/client_interceptors.js:614:8)\n    at /app/node_modules/grpc/src/client_interceptors.js:1110:18"
  Error: SERVICE_UNAVAILABLE
      at ClientDuplexStream.broadcast.on (/app/node_modules/fabric-client/lib/Orderer.js:172:22)
      at emitOne (events.js:116:13)
      at ClientDuplexStream.emit (events.js:211:7)
      at ClientDuplexStream._emitStatusIfDone (/app/node_modules/grpc/src/client.js:236:12)
      at ClientDuplexStream._receiveStatus (/app/node_modules/grpc/src/client.js:213:8)
      at Object.onReceiveStatus (/app/node_modules/grpc/src/client_interceptors.js:1290:15)
      at InterceptingListener._callNext (/app/node_modules/grpc/src/client_interceptors.js:564:42)
      at InterceptingListener.onReceiveStatus (/app/node_modules/grpc/src/client_interceptors.js:614:8)
      at /app/node_modules/grpc/src/client_interceptors.js:1110:18
  </code></pre>