title: How to subscribe AND publish at the same time with mosquitto command line tools?
body: <p>I want to implement a request-response with MQTT (3.1.1).
  It can be done using some language binding I guess.
  But how to do it using mosquitto_pub and mosquitto_sub command line utilities?</p>
  
  <p>The main problem is, that i need to subscribe first, then publish, then wait for the incoming packet.
  I tried this using zsh (or bash), with no luck, as you can see sometimes the message arrives, sometimes it does not.</p>
  
  <pre><code>$ mosquitto_sub -t topic -C 1 &amp; mosquitto_pub -t topic -m message ; fg
  [1] 20321
  [1]  + running    mosquitto_sub -t topic -C 1
  ^C
  $ mosquitto_sub -t topic -C 1 &amp; mosquitto_pub -t topic -m message ; fg
  [1] 20341
  [1]  + running    mosquitto_sub -t topic -C 1
  message
  </code></pre>
  
  <p>Also it does connect twice which is not ideal.</p>