Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt Remote Objects over TCP
Forum Updated to NodeBB v4.3 + New Features

Qt Remote Objects over TCP

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 926 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    ligabre
    wrote on last edited by ligabre
    #1

    Hello all,

    I would like to know if Qt RO could be used to serve remotely a subclass of QObject that lives on another node on the LAN network. When all of my process run on the same machine, everything is fine. However, when they run on different machines, it doesn't seem to work.

    Let say that I have two machines, one with IPa, the other one with IPb. The machine with IPa sets a Qt RO network, and the machine with IPb would like to access the Qt objects provided by the one with IPa. However, when I try to acquire a replica from this machine with IPb, the replica state is always Default, and it never enters to the state "Valid".

    This is the code I'm using on IPa (it comes directly from Qt help about Qt RO):

        AnObjectDerivedFromQObject objectInstance;
        // myInternalHost is a node only visible on the device...
        QRemoteObjectHost myInternalHost(QUrl("local:MyHost"));
        myInternalHost.enableRemoting(&objectInstance);
    
        // Regular host node, listening on port 12123, so visible to other
        // devices
        QRemoteObjectHost proxyNode(QUrl("tcp://127.0.0.1:12123"));
    
        // Enable proxying objects from nodes on the local machine's internal
        // QtRO bus
        proxyNode.proxy(QUrl("local:registry"));
    

    And on the machine with IPb, I've implemented:

        QSharedPointer<AnObjectDerivedFromQObjectReplica> replica;
    
        // NB: localhost resolves to a different ip address than proxyNode
        QRemoteObjectHost nodeOnRemoteDevice(QUrl("tcp://localhost:23234")); // This is as it is in the Qt doc
    
        // Connect to the target's proxyNode directly, or use a tcp registry...
        nodeOnRemoteDevice.connectToNode(QUrl("tcp://IPa:12123")); // Where IPa is the IP of the machine providing the actual object.
    
        // Because of the proxy, we can get the object over tcp/ip port 12123,
        // even though we can't connect directly to "local:MyHost"
        replica.reset(nodeOnRemoteDevice.acquire<AnObjectDerivedFromQObjectReplica>());
    

    The replica state then never enters in the Valid state.
    Could you please explain me what are my mistakes here?

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      127.0.0.1 and localhost both mean "this machine". If you never enter IPa how do you expect IPb to be able to connect?

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      1
      • L Offline
        L Offline
        ligabre
        wrote on last edited by ligabre
        #3

        The argument given to connectToNode (the method that will connect to the host node on machine with IPa) is the IPa. The object nodeOnRemoteDevice is just another Qt RO network on the machine with IP address IPb.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SimonSchroeder
          wrote on last edited by
          #4

          The examples are actually quite confusing. Does anybody know what local:switch, local:registry, etc. mean for a QUrl? I've never seen that and I can't find anything in the Qt documentation. Are these pipes? Or files? Both would explain why it works locally and not on distributed machines.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved