tiagocoutinho/modbus-proxy

By tiagocoutinho

Updated over 4 years ago

Bridge between your modbus device(s) and multiple concurrent clients.

Image
Networking
Internet of things
0

10K+

tiagocoutinho/modbus-proxy repository overview

Modbus TCP proxy

Many modbus devices support only one or very few clients. This proxy acts as a bridge between the client and the modbus device. It can be seen as a layer 7 reverse proxy. This allows multiple clients to communicate with the same modbus device.

When multiple clients are connected, cross messages are avoided by serializing communication on a first come first served REQ/REP basis.

How to use this image

First, you will need write a configuration file where you specify for each modbus device you which to control:

  • modbus connection (the modbus device url)
  • listen interface (to which url your clients should connect)

Configuration files can be written in YAML (.yml or .yaml) or TOML (.toml).

Suppose you have a PLC modbus device listening on plc1.acme.org:502 and you want your clients to connect to your machine on port 9000. A YAML configuration would look like this:

devices:
- modbus:
    url: plc1.acme.org:502
  listen:
    bind: 0:502

By default, this docker image runs the command /modbus-proxy-rs -c /etc/modbus-proxy.yml. (ENTRYPOINT ["modbus-proxy-rs"] and CMD ["-c", "/etc/modbus-proxy.yml"])

Therefore, launching a container is as simple as:

$ docker run -d -p 5020:502 -v $PWD/config.yml:/etc/modbus-proxy.yml tiagocoutinho/modbus-proxy

Note that the server is capable of handling multiple modbus devices. Here is a configuration example for 2 devices:

devices:
- modbus:
    url: plc1.acme.org:502
  listen:
    bind: 0:502
- modbus:
    url: plc2.acme.org:502
  listen:
    bind: 0:503

Note that for each modbus device you add in the configuration file you need to publish the corresponding bind port on the host (-p <host port>:<container port> argument).

So for the above configuration you would need to run:

$ docker run -d -p 5020:502 -p 5030:503 -v $PWD/config.yml:/etc/modbus-proxy.yml tiagocoutinho/modbus-proxy

Logging

Log levels can be adjusted by setting the RUST_LOG environment variable (default is warn):

$ docker run -d -p 5020:502 -v $PWD/config.yml:/etc/modbus-proxy.yml -e RUST_LOG=debug tiagocoutinho/modbus-proxy

Tag summary

Content type

Image

Digest

Size

924.4 kB

Last updated

over 4 years ago

docker pull tiagocoutinho/modbus-proxy