p4lang / p4runtime-shell

An interactive Python shell for P4Runtime
Apache License 2.0
79 stars 40 forks source link

Failed to establish session with the server #49

Open SergiVera opened 4 years ago

SergiVera commented 4 years ago

Hi everyone,

I have some issues when trying to run the p4runtime shell, as shown in the following figure: p4runtime-shell-error I have used the following command: sudo ./p4runtime-sh-docker --grpc-addr 0.0.0.0:50001 --device-id 0 --election-id 0,1 --config ../p4-tutorial/basic-forwarding/build/basic.p4.p4info.txt,../p4-tutorial/basic-forwarding/build/basic.json I guess the error is in the --grpc-addr but I don't know how to proceed. I have tested it with addresses 0.0.0.0 and localhost but I always obtain the same error. Thanks in advance!

antoninbas commented 4 years ago

0.0.0.0:50001 is not a valid address - you need to pass the address of the P4Runtime server. 0.0.0.0 is used in a server when you want to listen on every available interface. p4runtime-sh-docker is a client. Because you are using the Docker wrapper, the following information from the README may also apply:

If you are using the Docker image to run p4runtime-shell and you are trying to connect to a P4Runtime server running natively on the same system and listening on the localhost interface, you will not be able to connect to the server using --grpc-addr localhost: or --grpc-addr 127.0.0.1:. Instead, you should have your P4Runtime server listen on all interfaces (0.0.0.0) and you will need to use the IP address assigned to the Docker bridge (docker0 by default) or the IP address assigned to the local network management interface (e.g. eth0).

SergiVera commented 4 years ago

Yes, I have already read the README but I don't understand it. Which is the IP address assigned to the Docker bridge?

SergiVera commented 4 years ago

I think I have found the error. The file p4runtime-sh-docker lacks of --grpc-addr argument to pass on. Since neither IP nor port is specified, the error is: Failed to connect to all addresses

fatihusta commented 3 years ago

Hi @SergiVera I have same issue. Did you solve this problem?

emdneto commented 3 years ago

When running the P4 Switch Container, you need to expose ports with the -p 50001:50001 flag. This way, you can run p4runtime-shell for localhost: 50001.

For example, if you run a topology with mn-stratum, you can run p4runtime-shell for localhost:50001, localhost:50002, and localhost:50003, as your host's port has been bound to your container. Check this example:

docker run --privileged --rm -it -p 50001-50003:50001-50003 opennetworking/mn-stratum --topo linear,3

SergiVera commented 3 years ago

Hi @SergiVera I have same issue. Did you solve this problem?

Hello, thanks @fatihusta @emdneto for your time, I've been able to solve the problem.

Regards

belenbrandino commented 3 years ago

Hi @SergiVera

I have the same problem. How did you solve it?

Many thanks

SergiVera commented 3 years ago

Hello @belenbrandino,

In the end, I haven't used p4 in my project, but I'm sure I solve it too but I don't remember it well. I'm glad that you've solved it too!

Thanks