Issue while connecting the client to the server

grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.UNAVAILABLE
details = “failed to connect to all addresses; last error: UNAVAILABLE: ipv4:0.0.0.0:9092: WSA Error”
debug_error_string = “UNKNOWN:Error received from peer {created_time:“2024-07-17T02:32:08.5763354+00:00”, grpc_status:14, grpc_message:“failed to connect to all addresses; last error: UNAVAILABLE: ipv4:0.0.0.0:9092: WSA Error”}”

Please someone help how to fix this issue.

1 Like

Hi,
Could you provide the code that caused that problem?

1 Like

from flwr.client import ClientApp, NumPyClient

from task import (
Net,
DEVICE,
load_data,
get_weights,
set_weights,
train,
test,
)

Load model and data (simple CNN, CIFAR-10)

net = Net().to(DEVICE)
trainloader, testloader = load_data()

Define FlowerClient and client_fn

class FlowerClient(NumPyClient):
def fit(self, parameters, config):
set_weights(net, parameters)
results = train(net, trainloader, testloader, epochs=1, device=DEVICE)
return get_weights(net), len(trainloader.dataset), results

def evaluate(self, parameters, config):
    set_weights(net, parameters)
    loss, accuracy = test(net, testloader)
    return loss, len(testloader.dataset), {"accuracy": accuracy}

def client_fn(cid: str):
“”“Create and return an instance of Flower Client.”“”
return FlowerClient().to_client()

Flower ClientApp

app = ClientApp(
client_fn=client_fn,
)

Legacy mode

if name == “main”:
from flwr.client import start_client

start_client(
    server_address="127.0.0.1:9092",
    client=FlowerClient().to_client(),
    insecure=True,  # Assuming you want to run in insecure mode
    superlink="127.0.0.1:9092"  # Use superlink instead of server
)
1 Like

Hi @priya04119961870, did you first start the server before starting the client?

Yes I did start the server…
still was facing the WSA issue