Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request - Node client BiDi streaming example. #1062

Open
JoelBrenstrum opened this issue Oct 2, 2023 · 3 comments
Open

Request - Node client BiDi streaming example. #1062

JoelBrenstrum opened this issue Oct 2, 2023 · 3 comments

Comments

@JoelBrenstrum
Copy link

I am struggling to get a node client to work with external gRPC server (Salesforce Pub/Sub) for BiDiStreaming.
Unary requests are working fine.
I can create the initial stream but it is closed as soon as I attempt to read it.

My code is very similar to this example
https://www.supaglue.com/blog/how-to-build-a-real-time-cdc-event-integration-with-your-customers-salesforce.

I've gone through all the examples and have yet to find one where the client consumes BiDiStreaming.
I would appreciate it if the node client example could consume the stream.

@srikrsna-buf
Copy link
Member

srikrsna-buf commented Oct 2, 2023

Hey! We'll get them added thank you for opening the issue. In the meantime here's a small sample:

import {
  createGrpcTransport,
} from "@connectrpc/connect-node";
import {ElizaService} from "gen/...";

const transport = createGrpcTransport({
    baseUrl: "https://demo.connectrpc.com",
    httpVersion: "2",
});
const client = createPromiseClient(ElizaService, transport);

const res = client.converse(
  (async function* () {
    yield { sentence: "Hey!" };
  })()
);
for await (const next of res) {
  console.log(next.sentence);
}

@nikoprotic
Copy link

Given this example, how would you control the connection from the client side? Specifically I would like to know how to:

  1. Close the connection
  2. Detect when the connection closes/when the server closes the connection
  3. Re-open the connection if the server closes it abruptly

@srikrsna-buf
Copy link
Member

@nikoprotic You can use the WritableIterable to have more control on the client side, here's an example usage from the connect repo: https://github.com/connectrpc/connect-es/blob/06234f16d9e06a140f953e0115952a7324878897/packages/connect-node-test/src/node-readme.spec.ts#L265-L282

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants