title: Why does the pika connection get dropped when publishing at irregular intervals
body: <p>The scenario is the following: I receive messages on one queue, do a bit of processing and then send a message on another queue.</p>
  <pre><code>credentials = PlainCredentials(&quot;test&quot;, &quot;test&quot;)
  publisher_credentials = PlainCredentials(&quot;test&quot;, &quot;test&quot;)
  connection = BlockingConnection(ConnectionParameters(&quot;host1&quot;, 1234, &quot;/&quot;, credentials))
  publisher_connection = BlockingConnection(ConnectionParameters(&quot;host2&quot;, 1234, &quot;/&quot;, publisher_credentials))
  
  channel, publisher_channel = connection.channel(), publisher_connection.channel()
  publisher_channel.queue_declare(queue=&quot;testqueue&quot;, passive=True)
  publisher_channel.confirm_delivery()
  callback_fct = generate_callback(publisher_channel)
  
  channel.basic_consume(queue=os.getenv(&quot;RABBIT_MQ_QNAME&quot;), on_message_callback=callback_fct, auto_ack=True)
  
  try:
      channel.start_consuming()
  except KeyboardInterrupt:
      channel.stop_consuming()
      connection.close()
  except Exception as e:
      logger.exception(&quot;An unexpected error has occurred!&quot;)
  
  </code></pre>
  <p>And the <code>generate_callback</code> function would do something like this:</p>
  <pre><code>def generate_callback(publisher):
      def on_message(channel, method_frame, header_frame, body):
          logger.debug(f&quot;Received {body}&quot;)
          # assume some processing is done here, it should be really fast (under one second)
          publisher.basic_publish(exchange='', &quot;test&quot;, body=&quot;random_string&quot;, properties=BasicProperties(content_type='text/plain', delivery_mode=DeliveryMode.Persistent))
  
      return on_message
  </code></pre>
  <p>Publishing works, but if I do not receive a message in my consumer queue for a couple of minutes, it seems that the publisher connection is lost:</p>
  <pre><code>ERROR - Stream connection lost: ConnectionResetError(104, 'Connection reset by peer')
  </code></pre>
  <p>I do not understand what I have to do in order to prevent the connection from being lost. In my current implementation I am automatically recreating the connection, but I would want to prevent this, at least in the cases in which nothing is received for a couple of minutes. What am I missing?</p>