title: client-server protocol for sensor data and command transmission using python
body: <p>Unfortunately I have very little experience in this kind of topics so I have been stalled for a while (while searching around and reading for possible solutions).</p>
  
  <p>My issue is quite simple, I have a system that works like this:</p>
  
  <ul>
  <li><p>A client device (for now a raspberry pi; consider multiple devices in future), both reads sensor data and controls some actuators.</p></li>
  <li><p>A server (my pc for now) would like to elaborate this data and send commands to the remote actuators (obviously depending on the elaboration it does).</p></li>
  </ul>
  
  <p><strong><em>Therefore, basically, what I need is</em></strong> for 'n' clients to connect to a specific server address and provide sensor data every 'x' minutes. Then, I would like the server to send specific commands to specific clients' actuators when it feels the need (the clients needs to listen for commands or pull periodically the commands from the server).</p>
  
  <p>I am a bit confused on the variety of protocols and modules available and on the best way to go from here. In particular I am looking for something quite lightweight, that could scale well (if lots of clients will connect) and that doesn't require low-level implementations (I am trying to avoid to handling sockets myself and define my own protocol).</p>
  
  <p><strong><em>Extra info:</em></strong>
  Just to give you some context, I have mainly considered:</p>
  
  <ul>
  <li>MQTT, but it seems to me that I would have to put a broker on what I call "server" and then use the server as a client that connects to a localhost broker for subscriptions...this seems wrong. I mean, the broker now is the problem, how do I solve that?</li>
  <li>webframework like Flask with some sort of REST get/post requests to send data to the server...seems a bit heavy solution and the server doesn't have a way to push commands to the client...the client would have to check periodically.</li>
  </ul>