title: MQTT/TCP Timeout
body: <p>I wrote a simple program used to observe the MQTT connection state.</p>
  <p>MQTT library choice &lt;PubSubClient.h&gt;</p>
  <p>Only do MQTT Connect, but not do other things, like client.loop(keep connect)、disconnect.</p>
  <p>When connecting successfully, and wait about 22s after, TCP sends [FIN, ACK] and [RST, ACK].</p>
  <p>Is TCP timeout ?
  And how to know TCP timeout value and view sessions from Wireshark .</p>
  <p>Client: ESP8266 &lt;-&gt; MQTT Broker: Windows</p>
  <p>Code:</p>
  <pre><code>    void MQTT_Setup(){
        client.setServer(MQTT_SERVER, MQTT_PORT);
        //client.setCallback(callback);
        MQTT_Connect();
      }
      
      void MQTT_Connect(){
        bool bMQTT;
        bMQTT = client.connect(&quot;ESP&quot;);
        Serial.println(&quot;MQTT Connected&quot;);
        if(bMQTT)MQTT_Disconnect();
        //MQTT_Publish();
      }
      void setup() {
      Serial.begin(BAUDRATE);
      delay(3000);
      WIFI_Setup();
      MQTT_Setup();
      }
  
      void loop() {
        //client.loop();
      }
  </code></pre>
  <p>Wireshark:
  <a href="https://i.stack.imgur.com/SHYXo.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SHYXo.jpg" alt="enter image description here" /></a></p>