title: Can I get notified when the grpc client disconnects?
body: <p>I need to catch in the server whenever a client isn't listen to the stream anymore. I thought this would do:</p>
  
  <pre><code>function getEvents(call) {
    const { type } = call.request
    EVENTS
      .filter((e) =&gt; e.type === type)
      .foreach((event) =&gt; call.write(event))
  
    call.on('end', () =&gt; { console.log('client left...') })
  }
  </code></pre>
  
  <p>What I intended is that a client would connect, specify an event type, and receive a stream of events. The connection would then hang until <code>Ctrl+C</code> and "client left..." would be logged to the console.</p>
  
  <p>Client code would be like:</p>
  
  <pre><code>function main() {
    const client = 
      new EventStore('localhost:50051', grpc.credentials.createInsecure())
  
    const call = client.getEvents({ type: 'Done' })
    call.on('data', (event) =&gt; console.log(event))
  }
  </code></pre>
  
  <p>Everything work as expected, only the callback for <code>call.on('end')</code> never fires. I got the basics for this from the <a href="https://grpc.io/docs/tutorials/basic/node.html" rel="nofollow noreferrer">gRPC Tutorial</a> but I must be missing something.</p>