Aadil Hoda
Aadil Hoda

Reputation: 105

How to store back the nested response data in protobuf?

I'm using GRPC to remote call the database and store the data in the response format given by the .proto file. My program is based on CPP programming:

// similar .proto file
message FinalResponse
{
    repeated IntermediateResponse finals = 1;
}

message IntermediateResponse
{
    string name = 1;
    InitialResponse foo = 2;
}

enum InitialResponse
{
    COUNTRY_UNKNOWN = 0;
    COUNTRY_INDIA = 1;
}

For my case, the request message is empty(no field) so didn't displayed here. I went through the protocol buffer documentation and tried this:

// firstly called the database and stored the intermediateResponse in a vector<pair<string, string>> data

//pseudo-code below:
FinalResponse result;

for cur_data in data:
{ 
    IntermediateResponse *interResp = result.add_finals();
    interResp->set_name(cur_data.first);
    interResp->set_foo(static_cast<InitialResponse>(cur_data.second));
}

When I'm executing this, there is no syntax/build error but grpc status is saying we didn't get any response back:

ERROR - (12) No message returned for unary request

I want to clarify that service was running from the server side and client is able to detect that service as well, I'm suspecting that maybe the returned data through database is not properly stored in the response message and so GRPC is deducing that we didn't get back any data. Please suggest some work around for this?

Upvotes: 1

Views: 365

Answers (1)

Aadil Hoda
Aadil Hoda

Reputation: 105

Looks like it was the server side issue probably, now with the same changes, it is able to store the response properly.

Maybe server went down for some time and returned error.

Upvotes: 1

Related Questions