The purpose of the code was initially to test the operation of the grpc
stub when the grpc service was not available. However, the behavior I'm
seeing indicates that there's something going on that I don't understand-
hence the question.
In this code:
#define IN_MILLISECONDS(x) (std::chrono::system_clock::now() + std::
chrono::milliseconds(x))
string NowString()
{
char buf[128];
SYSTEMTIME timeBuf;
::GetLocalTime(&timeBuf);
sprintf(buf, "%02d:%02d:%02d.%03d - ", timeBuf.wHour, timeBuf.
wMinute, timeBuf.wSecond, timeBuf.wMilliseconds);
return string(buf);
}
void testStub(std::shared_ptr<grpc::Channel> chan)
{
MessageProcessor::Stub client(chan);
Void _void;
AccumulateAmount amount;
amount.set_amount(42);
grpc::ClientContext ctx;
ctx.set_deadline(IN_MILLISECONDS(100));
cout << NowString() << " Making RPC\n";
grpc::Status st = client.Accumulate(&ctx, amount, &_void);
cout << NowString() << " Leaving testStub()\n";
}
void test()
{
auto chan = grpc::CreateChannel("localhost:54321", grpc::
InsecureChannelCredentials());
cout << NowString() << " Channel Up- Testing Stub\n";
testStub(chan);
cout << NowString() << " Leaving test()\n";
}
int main()
{
cout << NowString() << "Calling test()\n";
test();
cout << NowString() << "Exiting 'main'\n";
return 1;
}
the output is
11:42:05.400 - Calling test()
11:42:05.403 - Channel Up- Testing Stub
11:42:05.404 - Making RPC
11:42:05.506 - Leaving testStub()
11:42:05.507 - Leaving test()
11:42:15.545 - Exiting 'main'
Press any key to continue . . .
It should be evident by the timestamps that the destructor for the Channel
is taking just over 10 seconds.
My question is this: *What can I do to significantly reduce the time it
takes to destroy the grpc Channel?*
My guess is that the channel is still trying to connect to the non-existent
server/service. My guess is that the destructor for the channel isn't
cancelling that connection request.
Perhaps there's an argument/option to send to the CreateChannel call? I've
looked at http://www.grpc.io/grpc/cpp/group__grpc__arg__keys.html, but I
didn't see anything that looked like it would affect the initial connection
attempt (the GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS
<http://www.grpc.io/grpc/cpp/group__grpc__arg__keys.html#gaedb26c5ca7d3d279b81d12d9bf6dabc6>
seemed
to affect the re-connection between first and second attempts)
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit
https://groups.google.com/d/msgid/grpc-io/9c7f31b4-ebf0-41e1-958f-e76e661c3471%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.