Subscribe stops when connecting to two ROS system with ROS-TCP-Connector

I have a single simulation connected to two ROS systems.
I have added ROSconnection to two objects on unity to communicate with ROS in Docker, but after the connection, one of them stops subscribing.
Both can publish from Unity to ROS, but subscribe from ROS stops after a few seconds of connection.
How can I solve this problem?

This is the part of the script that is adding to the two objects. padmode is published once per second.

using System;
using System.Collections.Generic;
using UnityEngine;
using Unity.Robotics.ROSTCPConnector;
using RosMessageTypes.Geometry;
using RosMessageTypes.Std;
using RosMessageTypes.Sensor;
using RosMessageTypes.BuiltinInterfaces;
using Unity.Robotics.UrdfImporter.Control;
using UnityEngine.UI;
using Unity.Robotics.Core;
    public class Controller : MonoBehaviour
        public string ros_name;
        ROSConnection m_ros;
        float rosLinear;
        float rosAngular;
        int padmode;

        void Start()
            m_ros = this.GetComponent<ROSConnection>();

            m_ros.Subscribe<TwistMsg>("/cmd_vel", ReceiveCmd);
            m_ros.Subscribe<Int16Msg>("/pad/mode", ReceivePadMode);   

        void ReceiveCmd(TwistMsg cmdVel)
            rosLinear = (float)cmdVel.linear.x;
            rosAngular = (float)cmdVel.angular.z;
            Debug.Log(ros_name + "cmd: " + rosLinear.ToString());

        void ReceivePadMode(Int16Msg msg)
            padmode =;
            Debug.Log(ros_name + "mode: " + a.ToString());

Hello, probably more information is needed to help you. :(

So if I understand correctly (I'll make some assumptions to get more information, so correct me if I'm wrong):

  • You are running ROS in Docker.

  • There you have one publisher publishing messages to /cmd_vel and one publisher publishing messages to /pad/mode.

  • Presumably, you also have some subscribers for some topics registered from Unity (?).

  • You have two objects in your scene, and they both

  • Have this Controller script attached to them, so they should subscribe to both /cmd_vel and /pad/mode topics.

  • Have some other script attached to them in which they publish some messages to some topics that some node is subscribed to inside your ROS environment (?).

To further clarify:

  • The publishing from Unity to ROS works correctly all the time for both of the game objects?
  • Only one of the game objects stops subscribing correctly after a few seconds of the application running, even though they use the same Controller component?
  • Does always the same game object (from the two) stop receiving messages, or does it seem to be random?
  • What is the frequency of all the publishers (in Unity and in ROS publishing into Unity)?