WaitForConnected does not work for a windows grpc client

243 views
Skip to first unread message

Trilokesh Ranjan Pradhan

unread,
Sep 30, 2022, 2:47:06 AM9/30/22
to grpc.io
I am writing a grpc based server and client. Server is running on linux and client is running on windows.

I am trying to handle the scenario when the server is not started but the client is up.

This is the simplified version of the code which I use to check when server is available.

auto state = m_channel->GetState(true);

 while (state != GRPC_CHANNEL_READY || state != GRPC_CHANNEL_SHUTDOWN) { std::chrono::time_point deadline = std::chrono::system_clock::now() + std::chrono::seconds(30); if (m_channel->WaitForStateChange(state, deadline)) { std::cout << "new state is: " << static_cast<int>(state) << "\n"; state = m_channel->GetState(true); } } 

But when the client starts running without the server, I see the following error:

 **I0929 22:24:05.748000000 14812 subchannel.cc:905] subchannel 0123CF78 {address=ipv4:192.168.175.130:40051, args={grpc.client_channel_factory=0x121dd68, grpc.default_authority=192.168.175.130:40051, grpc.internal.channel_credentials=0x121dce8, grpc.internal.security_connector=0x1235f28, grpc.internal.subchannel_pool=0x1225db0, grpc.max_receive_message_length=-1, grpc.primary_user_agent=grpc-c++/1.49.0-dev, grpc.resource_quota=0x1225990, grpc.server_uri=dns:///192.168.175.130:40051}}: connect failed (UNAVAILABLE:WSA Error {syscall:"ConnectEx", os_error:"No connection could be made because the target machine actively refused it.\r\n", grpc_status:14, wsa_error:10061, created_time:"2022-09-29T20:24:05.748604482+00:00"}), backing off for -1057 ms**


Where as when I run the client on linux, I see it properly waiting till the server is up and running.

Is there a specific firewall setting that is needed for windows ? Can someone guide me here ?

Trilokesh Ranjan Pradhan

unread,
Sep 30, 2022, 4:51:17 AM9/30/22
to grpc.io
After setting GRPC_VERBOSITY to debug and GRPC_TRACE
 
GRPC_VERBOSITY=debug GRPC_TRACE=tcp,http,api ./grpc-opstatus-client.exe


 D0930 10:50:04.538000000 39664 lb_policy_registry.cc:43] registering LB policy factory for "grpclb"
D0930 10:50:04.538000000 39664 lb_policy_registry.cc:43] registering LB policy factory for "rls_experimental"
D0930 10:50:04.538000000 39664 lb_policy_registry.cc:43] registering LB policy factory for "priority_experimental"
D0930 10:50:04.538000000 39664 lb_policy_registry.cc:43] registering LB policy factory for "weighted_target_experimental"
D0930 10:50:04.538000000 39664 lb_policy_registry.cc:43] registering LB policy factory for "pick_first"
D0930 10:50:04.538000000 39664 lb_policy_registry.cc:43] registering LB policy factory for "round_robin"
D0930 10:50:04.538000000 39664 lb_policy_registry.cc:43] registering LB policy factory for "ring_hash_experimental"
D0930 10:50:04.539000000 39664 dns_resolver_ares.cc:831] Using ares dns resolver
D0930 10:50:04.539000000 39664 certificate_provider_registry.cc:39] registering certificate provider factory for "file_watcher"
D0930 10:50:04.540000000 39664 lb_policy_registry.cc:43] registering LB policy factory for "cds_experimental"
D0930 10:50:04.540000000 39664 lb_policy_registry.cc:43] registering LB policy factory for "xds_cluster_impl_experimental"
D0930 10:50:04.540000000 39664 lb_policy_registry.cc:43] registering LB policy factory for "xds_cluster_resolver_experimental"
D0930 10:50:04.540000000 39664 lb_policy_registry.cc:43] registering LB policy factory for "xds_cluster_manager_experimental"
I0930 10:50:04.540000000 39664 init.cc:163] grpc_init(void)
I0930 10:50:04.540000000 39664 init.cc:163] grpc_init(void)
I0930 10:50:04.540000000 39664 chttp2_connector.cc:346] grpc_secure_channel_create(target=192.168.175.130:2500, creds=0136E510, args=012CF880)
I0930 10:50:04.540000000 39664 init.cc:163] grpc_init(void)
I0930 10:50:04.541000000 39664 init.cc:163] grpc_init(void)
I0930 10:50:04.541000000 39664 credentials.cc:37] grpc_channel_credentials_release(creds=0136E510)
I0930 10:50:04.541000000 39664 init.cc:202] grpc_shutdown(void)
I0930 10:50:04.541000000 39664 channel.cc:369] grpc_channel_register_call(channel=01387C08, method=/udi.operationalstatus.OperationalStatusService/IsOperational, host=(null), reserved=00000000)
I0930 10:50:04.541000000 39664 channel.cc:369] grpc_channel_register_call(channel=01387C08, method=/udi.operationalstatus.OperationalStatusService/SubscribeOperationalStatusChanged, host=(null), reserved=00000000)
I0930 10:50:04.541000000 39664 init.cc:163] grpc_init(void)
I0930 10:50:04.541000000 39664 completion_queue.cc:522] grpc_completion_queue_create_internal(completion_type=0, polling_type=0)
I0930 10:50:04.541000000 39664 init.cc:202] grpc_shutdown(void)
EventHandler Entry....
 I0930 10:50:04.542000000 52904 completion_queue.cc:976] grpc_completion_queue_next(cq=0138A120, deadline=gpr_timespec { tv_sec: 9223372036854775807, tv_nsec: 0, clock_type: 1 }, reserved=00000000)
I0930 10:50:04.542000000 42080 channel_connectivity.cc:62] grpc_channel_check_connectivity_state(channel=01387C08, try_to_connect=1)
I0930 10:50:04.555000000 42080 init.cc:163] grpc_init(void)
I0930 10:50:04.577000000 42080 channel_connectivity.cc:240] grpc_channel_watch_connectivity_state(channel=01387C08, last_observed_state=0, deadline=gpr_timespec { tv_sec: 1664527834, tv_nsec: 577002800, clock_type: 1 }, cq=0138A120, tag=01386F70)
I0930 10:50:04.577000000 42080 completion_queue.cc:702] cq_end_op_for_next(cq=0138A120, tag=01386F70, error=OK, done=00D9CAC0, done_arg=0138A6D0, storage=0138A6F0)
I0930 10:50:04.577000000 42080 channel_connectivity.cc:62] grpc_channel_check_connectivity_state(channel=01387C08, try_to_connect=1)
I0930 10:50:04.577000000 52904 completion_queue.cc:1081] RETURN_EVENT[0138A120]: OP_COMPLETE: tag:0x1386f70 OK
GrpcOpStatusClient::EventHandler, event received: I0930 10:50:04.577000000 42080 channel_connectivity.cc:62] grpc_channel_check_connectivity_state(channel=01387C08, try_to_connect=1)
0
channel state changed...
channel state changed to: 1
I0930 10:50:04.578000000 42080 channel_connectivity.cc:62] grpc_channel_check_connectivity_state(channel=01387C08, try_to_connect=1)
I0930 10:50:04.578000000 52904 completion_queue.cc:976] grpc_completion_queue_next(cq=0138A120, deadline=gpr_timespec { tv_sec: 9223372036854775807, tv_nsec: 0, clock_type: 1 }, reserved=00000000)
I0930 10:50:04.578000000 42080 channel_connectivity.cc:240] grpc_channel_watch_connectivity_state(channel=01387C08, last_observed_state=1, deadline=gpr_timespec { tv_sec: 1664527834, tv_nsec: 578089200, clock_type: 1 }, cq=0138A120, tag=01386CA0)
I0930 10:50:04.578000000 42080 channel_connectivity.cc:62] grpc_channel_check_connectivity_state(channel=01387C08, try_to_connect=1)
I0930 10:50:06.631000000 52904 subchannel.cc:905] subchannel 013900A8 {address=ipv4:192.168.175.130:2500, args={grpc.client_channel_factory=0x136e550, grpc.default_authority=192.168.175.130:2500, grpc.internal.channel_credentials=0x136e510, grpc.internal.security_connector=0x1388be0, grpc.internal.subchannel_pool=0x1389d10, grpc.max_receive_message_length=-1, grpc.primary_user_agent=grpc-c++/1.49.0-dev, grpc.resource_quota=0x1376890, grpc.server_uri=dns:///192.168.175.130:2500}}: connect failed (UNAVAILABLE:WSA Error {syscall:"ConnectEx", os_error:"No connection could be made because the target machine actively refused it.\r\n", grpc_status:14, wsa_error:10061, created_time:"2022-09-30T08:50:06.630792136+00:00"}), backing off for -1087 ms
Reply all
Reply to author
Forward
0 new messages