grpcgrpc-c++

grpc channel WaitForConnection(deadline) does not work


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.

    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);
        }
    }

When I run, this it fails with this 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 ?

Interesting thing to notice is the back off time is in -ve, where as on linux, it is a +ve value and increases as per the backoff strategy.


Solution

  • The issue is fixed, when I started using grpc conan-package to build the server and client instead of locally built grpc from source. I believe some mistakes were made while building grpc locally from source.

    I did not get time to look in details for the root cause it.