title: gRPC stream become canceled
body: <p>I'm trying to create a streaming API via gRPC, but my StreamObserver became canceled for some strange reason.
  Here is my <code>.proto</code> declarations:</p>
  
  <pre><code>service Service {
      rpc connect (ConnectionRequest) returns (stream StreamResponse) {}
  
      rpc act (stream ActRequest) returns (ActResponse) {}
  }
  </code></pre>
  
  <p>The idea is that the users will <code>connect</code> so the <code>StreamResponse</code> will be saved for each user, and then on each <code>act</code> the <code>StreamResponse</code> will receive the update. Here is the java implementation of the <code>Service</code></p>
  
  <pre><code>class ServiceImpl extends ServiceGrpc.ServiceImplBase {
      ............
      @Override
      public void connect(ConnectionRequest request, StreamObserver&lt;StreamResponse&gt; responseObserver) {
          observers.add(responseObserver);
      }
  
      @Override
      public StreamObserver&lt;ActRequest&gt; act(StreamObserver&lt;ActResponse&gt; responseObserver) {
          return return new StreamObserver&lt;ActRequest&gt;() {
              @Override
              public void onNext(ActRequest actRequest) {
                  StreamResponse streamResponse = StreamResponse.newBuilder().build();
                  observers.forEach(o -&gt; o.onNext(streamResponse));
                  actRequest..onCompleted();
              }
              ...............
          };
      }
      ..................
  }
  </code></pre>
  
  <p>And here is the client <code>connect</code> method:</p>
  
  <pre><code>ServiceGrpc.ServiceStub stub = ServiceGrpc.newStub(channel);
  new StreamObserver&lt;PlayerResponse&gt;() {
      ........
      @Override
      public void onNext(StreamResponse streamResponse) {
            logger.info("Act: " streamResponse.getData());
      }
      ........
  }
  ConnectionRequest request = ConnectionRequest.newBuilder().build();
  stub.connect(request, streamObserver);
  </code></pre>
  
  <p>And the client <code>act</code> method:</p>
  
  <pre><code>StreamObserver&lt;ActResponse&gt; observer = new StreamObserver&lt;ActResponse&gt;() {
      @Override
      public void onNext(ActResponse actResponse) {
          logger.info("Status: " + actResponse.getSuccess());
      }
      .........
  };
  StreamObserver&lt;ActRequest&gt; act = stub.act(observer);
  act.onNext(MoveRequest.newBuilder().build());
  act.onCompleted();
  </code></pre>
  
  <p>When I start both client and server, the client is able to call <code>connect</code>. But the method <code>act</code> can be called only for the first time. When the client calls <code>act</code> for the second time I receive the following exception:</p>
  
  <pre><code>io.grpc.StatusRuntimeException: CANCELLED: call already cancelled
      at io.grpc.Status.asRuntimeException(Status.java:517)
      at io.grpc.stub.ServerCalls$ServerCallStreamObserverImpl.onNext(ServerCalls.java:335)
  </code></pre>
  
  <p>And in the debug mode I can see that the <code>StreamObserver&lt;StreamResponse&gt; responseObserver</code> is <code>canceled=true</code>.</p>