Hi!
I am using the grpc c++ async callback API for my application and I don't know how to get more details about the following error:
On the server side I write the streaming response like this:
```
cta::xrd::Response *header = new cta::xrd::Response();
header->set_type(cta::xrd::Response::RSP_SUCCESS);
header->set_show_header(cta::admin::HeaderType::TAPE_LS);
response.set_allocated_header(header); // now the message takes ownership of the allocated object, we don't need to free header
std::cout << "about to call StartWrite on the server side" << std::endl;
StartWrite(&response); // this will trigger OnWriteDone
std::cout << "called StartWrite on the server" << std::endl;
```
On the client side, I make the call like this
```
std::cout << "In CtaAdminClientReadReactor, about to call the async GenericAdminStream" << std::endl;
client_stub->async()->GenericAdminStream(&m_context, request, this);
std::cout << "Started the request to the server by calling GenericAdminStream" << std::endl;
StartRead(&m_response); // where to store the received response?
std::cout << "In CtaAdminClientReadReactor, called startRead" << std::endl;
StartCall(); // activate the RPC!
std::cout << "In CtaAdminClientReadReactor, called StartCall()" << std::endl;
```
and then read the streaming response:
```
virtual void OnReadDone(bool ok) override {
std::cout << "In CtaAdminCmdStream, inside OnReadDone() " << std::endl;
if (!ok) {
std::cout << "Something went wrong with reading the response in the client" << std::endl;
} else {
// if this is the header, print the formatted header
if (m_response.has_header()) {
std::cout << "We received the header on the client side " << std::endl;
switch (m_response.header().type()) {
.......
```
Using debug prints, from the output, I can see that on the server side, StartWrite() is called just once, then on the client side, the first time OnReadDone is called, it goes into the “not ok” branch.
The error code and message the rpc returns is “Error code: 14, Error message: Socket closed”.
How can I get more insights on where things go wrong? I have enabled debug logging but it seems not much is logged by the async callback API.
Any pointers will be greatly appreciated!
Many thanks,
Konstantina
Thank you for the reply. I think my problem was due to me not using correct lifetimes, the “response” I was using was not as long-lived as the rpc call. Anyway, it is resolved now.