Connecting to a TCP server in a Torizon/Docker application

Hi all,

I am developing an application for my Colibri i.MX7D module that is running a modified image of torizon-core-docker-colibri-imx7-emmc-Tezi_5.6.0+build.13 (changes to the device tree, not relevant here).
Development is done on Linux with Visual Studio Code and the Torizon extension.

My application starts a telnet server thread on port 50400 that listens to incoming connections by calling accept(). This succeeds without any errors (the same code is already used many times on desktop Linux systems). So far so good.
However, if I try to connect to this port from another machine with putty, I get the error “Connection Refused”. The used IP address is OK, I can ping to the module without any problem.

My understanding is that the docker container in which my application runs does not allow any connection from the outside. Searching on the Toradex site, the only post that seems to speak of this is An external ssh connection to a Debian container in Torizon? but that did not help me a lot…

Is there a simple way, in the Ports or Network keys in the Torizon extension for instance, to allow/connect a specific port to the outside world ?

I may be far off the real cause, this is my first application on a Toradex module so there is still a lot to learn an understand…

Any help is much appreciated !
Best regards,
Jeroen

Hi @ompie ,

My understanding is that the docker container in which my application runs does not allow any connection from the outside

From the Docker documentation: Newly created containers are connected to a default bridge network, which is isolated from the module network stack.

You can start the container with the host network mode: this way, the container shares the Colibri iMX7’s networking namespace and your application can communicate with other peers in the local network.

This mode is enabled when running docker run with parameter --network host. In our extension, all you need to do is create a new entry in the extraparms configuration with these options:

  • Key of the new element: network_mode
  • Value of element: host

Then redeploy the application to the SoM. More information about the extension configurations can be found here: IDE Extension | Toradex Developer Center

Try doing this and see if it helps you.

Best regards,
Lucas Akira

Just complementing my previous response, you can also achieve communication through port 50400 by just exposing it on the ports entry in the extension configurations, as described here: Torizon Best Practices Guide | Toradex Developer Center.

It is preferable doing this method rather than changing the network mode to host, which should be done only if really needed. Sorry for not explaining this sooner.

Best regards,
Lucas Akira

Hi Lucas,
Once again many thanks for your quick an helpfull answer. Adding the key 50400/tcp and value 50400 to the Port setting did the trick

Have a nice weekend
Jeroen

Glad I was able to help!

Best regards,
Lucas Akira