Http_request and mqtt bugs?

Hi, guys!
I’m a newbie, I encountered a couple of obscure moments in the work of the http_request and mqtt client components.
With http_request, the problem is as follows: when you try to send two requests in a row to different servers (one in the local network, by ip address, the other to the Internet via fqdn), the second request always fails. Returns error 400 in logs. If you rearrange the requests in places, the same picture - the first request passes normally, the second returns an error 400. For requests to only one server, everything works ok.
With mqtt the problem is as follows: I need to connect to a third-party MQTT server. I create a node, make all sensors and switch internal so that they do not climb on the server when they want to. In mqtt: I disable birth_message: and will_message. The connection to the server goes fine, but when node go in to dip_sleep, the server, in topic /state sends a message “offline”, which I can’t disable in any way. (seen in the logs of the mqtt server).
I’m trying to enable birth_message:, so that when you connect, in the status/ topic sends the message “online” - this is how it was intended. As a result, when you connect to the server, the message does not go, but now, when you disconnect from the server, you get 2 messages at once: “online” and “offline”.
I turn off birth_message:, and turn on will_message with the message “online”(!). then, when connecting, the message “online” comes to the topic /status, and when disconnecting, as before, the non-disabled message “offline”. At the same time, under any settings, I did not see the DISCONNECT message in the mqtt server logs.
Looks like, firstly, the messages birth_message: and will_message: are mixed up, and secondly, it seems like instead of the DISCONNECT message, when disconnecting, what should be will_message by default is sent to the server.
Well, the very principle of operation of will_message is not sure that it coincides with the mqtt standard. will_message must be sent in order to inform everyone about an ABNORMAL break connection - not at normal disconnect.
It all looks like bugs. I should report it via github, but I don’t know how to use github yet :). And in English like a dog - I understand everything, but I can only say it through google translate :slight_smile:

esphome:

mqtt:
  broker: bla-bla-bla.ru 
  port: 1883
  username: name
  password: pass
  client_id: id
  birth_message:
#   topic: f/TEMP1/status
#   payload: "online"
  will_message:
#   topic: f/TEMP1/status
#   payload: "offline"

  discovery: false
  log_topic:
  topic_prefix: f/TEMP1

deep_sleep:
  run_duration: 10s
  sleep_duration: 6min

Server log:


2020-10-05 12:28:24  213.87.127.193  MQTT  CONNECT  =
2020-10-05 12:28:34  213.87.127.193  MQTT  PUBLISH  f/TEMP1/status=offline

esphome:

mqtt:
  broker: bla-bla-bla.ru 
  port: 1883
  username: name
  password: pass
  client_id: id
  birth_message:
   topic: f/TEMP1/status
   payload: "online"
  will_message:
#   topic: f/TEMP1/status
#   payload: "offline"

  discovery: false
  log_topic:
  topic_prefix: f/TEMP1

Server log:


2020-10-05 12:49:07  213.87.127.193  MQTT  CONNECT  =
2020-10-05 12:49:08  213.87.127.193  MQTT  PUBLISH  f/TEMP1/status=online
2020-10-05 12:49:18  213.87.127.193  MQTT  PUBLISH  f/TEMP1/status=offline

esphome:

  broker: bla-bla-bla.ru 
  port: 1883
  username: name
  password: pass
  client_id: id
  birth_message:
#   topic: f/TEMP1/status
#   payload: "online"
  will_message:
   topic: f/TEMP1/status
   payload: "offline"

  discovery: false
  log_topic:
  topic_prefix: f/TEMP1

Server log:

2020-10-05 13:04:40  213.87.127.193  MQTT  CONNECT  f/TEMP1/status=offline
2020-10-05 13:04:50  213.87.127.193  MQTT  PUBLISH  f/TEMP1/status=offline

In all cases, the last message in the logs is superfluous.It should be DISCONNECTED instead. When connecting,it should be something like:

2020-10-05 13:04:40  213.87.127.193  MQTT  CONNECT  <birth_message>
2020-10-05 13:04:40  213.87.127.193  MQTT  PUBLISH  <will_message>
2020-10-05 13:04:50  213.87.127.193  MQTT  DISCONNECT

Or am I wrong?

OK! with the last message understood.

shutdoun_message:

I didn’t notice in the documentation.
I can hardly see :slight_smile:
I also understood the logic of will_message. I didn’t understand only how not to send will_message when connect, but to send the usual “online” message to /status directly when connect.

I’ve attempted to override the will_message to say “online” and it doesn’t work;

esphome:
  name: outside
...
mqtt:
  broker: 192.168.7.6
  username: "<name>"
  password: "<passwd>"
  discovery: true
  discovery_retain: true
  birth_message:
    topic: outside/status
    payload: online
  will_message:
    topic: outside/status
    payload: online

And yet when I subscribe to outside/status I see;

Message 293 received on outside/status at 2:13 PM:
offline
QoS: 0 - Retain: false
Message 292 received on outside/status at 2:13 PM:
online
QoS: 0 - Retain: false
Message 291 received on outside/status at 2:13 PM:
online
QoS: 0 - Retain: true

So it looks like the will_message is in addition to the default ‘offline’ message.

Actually, I’m not entirely sure, but this may have been some kind of strange side-effect of either not doing a “Clean Build Files” between installs, and/or retained messages pushed by earlier builds during testing. It appears after doing a clean build with;

esphome:
  name: outside
...
mqtt:
  broker: 192.168.7.6
  username: "<name>"
  password: "<passwd>"
  discovery: true
  discovery_retain: true
  birth_message:
  will_message:

and purging the retained messages with;

mosquitto_pub -t outside/status -r -n -d

I now nolonger see any messages going to outside/status, as I would have expected.