p4lang/behavioral-model

The simple_switch_CLI command fails to be executed

lizzmosquito opened this issue · 2 comments

OSsytem:ubuntu20.04

If I execute the simple_switch command (sudo ./simple_switch i 1@ens4 -i 2@ens6 --log-console /home/pml/Workspace/P4/tutorials/exercises/basic/basic.json) , simple_switch_CLI command can success to be executed.

But I execute the simple_switch_grpc command (sudo simple_switch_grpc --device-id 1 -i 1@ens4 -i 2@ens6 --log-console --no-p4 -- --cpu-port 255 --grpc-server-addr 100.1.1.132:50051) , simple_switch_CLI command can fails to be executed.

pml@pml:/Workspace/P4/tutorials/exercises/basic$ sudo simple_switch_CLI
[sudo] password for pml:
Could not connect to any of [('127.0.0.1', 9090)]
Could not connect to thrift client on port 9090
Make sure the switch is running and that you have the right port
pml@pml:
/Workspace/P4/tutorials/exercises/basic$
pml@pml:/Workspace/P4/tutorials/exercises/basic$ sudo simple_switch_CLI --thrift-port 50051
Could not connect to any of [('127.0.0.1', 50051)]
Could not connect to thrift client on port 50051
Make sure the switch is running and that you have the right port
pml@pml:
/Workspace/P4/tutorials/exercises/basic$

If I recall correctly, you must supply a --thrift-port <port-number> parameter to simple_switch_grpc in order for it to listen for Thrift connections, which simple_switch_CLI relies upon.

Without that command line option, simple_switch_grpc only listens for gRPC connections for the P4Runtime API, and not a Thrift connection.

If you build simple_switch_grpc yourself, by default the Thrift server is disabled. You can run simple_switch_grpc --help and check whether the --thrift-port command-line argument is missing.
The information for enabling the Thrift server is in the documentation: https://github.com/p4lang/behavioral-model/tree/main/targets/simple_switch_grpc#enabling-the-thrift-server