Beckhoff / ADS

Beckhoff protocol to communicate with TwinCAT devices.
MIT License
519 stars 197 forks source link

ADS Connection Error With Docker Container #220

Open ismailalhajosman opened 11 months ago

ismailalhajosman commented 11 months ago

I have a Beckhoff PLC with IP (192.168.0.176) that I need to control it from linux machine using pyads. Inside linux machine I have a docker container that I want it to establish connection with the PLC.

When I try to communicate the linux host machine whose IP is (192.168.0.100) with the PLC , everything work alright and I can read and write varibles from and to the PLC. However, when I try to communicate the docker container inside linux whose IP is (172.19.0.13) with th PLC using pyads I got the ADS timeout error (1861).

PS. When I try : ping 192.168.0.176 from inside the docker container is throws data which means it connects to PLC , but when I try to read varibles from the PLC it give the ADS timeout error (1861).

Can you help me solve this issue?

nosvalds commented 10 months ago

Hi @ismailalhajosman we experienced a very similar issue. To resolve it we started the docker container with the --net=host option. This seemed to resolve the network issue between the host and container that caused the timeout. Note this might break networking to other containers you have running on the host so could require some reworking there.

The --net=host option is used to make the programs inside the Docker container look like they are running on the host itself, from the perspective of the network. It allows the container greater network access than it can normally get.

https://docs.docker.com/network/drivers/host/