@@ -28,8 +28,11 @@ class FederatedClient {
28
28
options.pem_cert_chain = client_cert;
29
29
grpc::ChannelArguments args;
30
30
args.SetMaxReceiveMessageSize (std::numeric_limits<int >::max ());
31
- return Federated::NewStub (
32
- grpc::CreateCustomChannel (server_address, grpc::SslCredentials (options), args));
31
+ auto channel =
32
+ grpc::CreateCustomChannel (server_address, grpc::SslCredentials (options), args);
33
+ channel->WaitForConnected (
34
+ gpr_time_add (gpr_now (GPR_CLOCK_REALTIME), gpr_time_from_seconds (60 , GPR_TIMESPAN)));
35
+ return Federated::NewStub (channel);
33
36
}()},
34
37
rank_{rank} {}
35
38
@@ -51,6 +54,7 @@ class FederatedClient {
51
54
52
55
AllgatherReply reply;
53
56
grpc::ClientContext context;
57
+ context.set_wait_for_ready (true );
54
58
grpc::Status status = stub_->Allgather (&context, request, &reply);
55
59
56
60
if (status.ok ()) {
@@ -72,6 +76,7 @@ class FederatedClient {
72
76
73
77
AllreduceReply reply;
74
78
grpc::ClientContext context;
79
+ context.set_wait_for_ready (true );
75
80
grpc::Status status = stub_->Allreduce (&context, request, &reply);
76
81
77
82
if (status.ok ()) {
@@ -91,6 +96,7 @@ class FederatedClient {
91
96
92
97
BroadcastReply reply;
93
98
grpc::ClientContext context;
99
+ context.set_wait_for_ready (true );
94
100
grpc::Status status = stub_->Broadcast (&context, request, &reply);
95
101
96
102
if (status.ok ()) {
0 commit comments