i am using C# here .My rpc looks like this: rpc StreamEvents (TestUnitRequest) returns (stream Events); this rpc method is used to stream events and below rpc method is used to subscribe to events ,load program api and log timestamp values and return a boolean value on successful load. rpc SendStatus(AppStatus) returns (CommandReply);
The client sends a request to load data and stream events from the Grpc server in the following way: var reply1 = client.SendStatus(new AppStatus {}); ExceptionMethod(reply1); var result = client.StreamEvents( new TestUnitRequest { }); I am trying to write the streamed events to file and return boolean value to the console as: Console.WriteLine(reply1.IsAccepted); Console.WriteLine("Streaming events....."); StringBuilder sb6 = new StringBuilder(); foreach (var cmd in result.Events) { sb6.Append(cmd); File.AppendAllText(filePath11 + "SampleTpEventlog.txt", sb6.ToString()); } sb6.Clear(); But the streaming is returning null value. Here is the server side code for rpc method sendStatus: disposable = service.SubscribeToEvents(OnEvents); try { var val1 = await service.LoadTestProgram(appstatus.Dir, appstatus.Tpl, appstatus.Stpl, appstatus.Soc, appstatus.Xml, appstatus.Env, true, true); // Console.WriteLine(now.ToString()); retval = val1; } catch (Exception e) { errmsg = e.Message; } return new CommandReply { IsAccepted = retval }; server side code for rpc method StreamEvents is: public override async Task StreamEvents(TestUnitRequest tur, IServerStreamWriter<Events> responseStream, ServerCallContext context) { await responseStream.WriteAsync(Events); } Please let me know if this is enough.Server is on remote desktop and client on local desktop. On Wed, Sep 14, 2022 at 11:04 AM 'Easwar Swaminathan' via grpc.io < grpc-io@googlegroups.com> wrote: > Please provide more information like what language are you using, how does > your rpc definition look like, what the server does, what the client does > etc, and what you expect to see, but didnt. In the meantime, maybe this > helps: https://grpc.io/docs/languages/go/basics/. > On Tuesday, September 13, 2022 at 4:11:18 PM UTC-7 srishtik...@gmail.com > wrote: > >> Hi, >> I wanted to know if its possible to stream events and also return a >> response from the same method in Grpc server call from the client. >> how do we keep on streaming data and return a response too? >> >> Thanks >> Srishti Kumari >> > -- > You received this message because you are subscribed to the Google Groups " > grpc.io" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to grpc-io+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/grpc-io/14610665-5324-47af-92ac-60e5d5bf53e1n%40googlegroups.com > <https://groups.google.com/d/msgid/grpc-io/14610665-5324-47af-92ac-60e5d5bf53e1n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "grpc.io" group. To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/CAACOWgBizyjMfMAW_F%3D40agVotYex_jAM0ODBJKFx-KV4R585g%40mail.gmail.com.