Skip to content

"Cancelled on client" error in gRPC Client streaming RPC scenario #264

Closed
@PrasadJayakumar

Description

Followed the steps detailed in https://httpyac.github.io/guide/request.html?#client-streaming-rpc

But, getting "Cancelled on client" error in gRPC Client streaming RPC scenario. Am I missing something?

Thank you for sharing the helpful tool.

GRPC /BasicService/CalculateAverage
{
  "value": 10
}

{{@streaming
  async function writeStream(){
    await sleep(1000);
    await $requestClient.send({
      value: 20,
    });
    await sleep(1000);
    await $requestClient.send({
      value: 30
    });
  }
  exports.waitPromise = writeStream();
}}
syntax = "proto3";

package grpc_basics;

service BasicService { 
 // Client streaming RPC: CalculateAverage
 rpc CalculateAverage (stream DataPoint) returns (AverageResponse);
}

message DataPoint {
  double value = 1;
}

message AverageResponse {
  double average = 1; 
}

Code behind the service is provided below.

  calculateAverage(call, callback) {
    // Simulating client streaming by calculating the average of received data points
    let totalSum = 0;
    let count = 0;

    call.on("data", (dataPoint) => {
      console.log("data", dataPoint);
      totalSum += dataPoint.value;
      count++;
    });

    call.on("end", () => {
      const average = count > 0 ? totalSum / count : 0;
      const response = { average: average };
      console.log("end", response);
      callback(null, response);
    });
  }

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions