When sending MQTT messages, first message arrives within 2 seconds and subsequent messages sent within less than 20 secs from first message, arrive in about 0.5 second.
I would like to speed up those “first” messages and wonder if there's a way to keep the line hot without bombarding the client with unnecessary keep alive kind of messages.
I am running Mosquitto version 2.0.4 on Ubuntu 18.04.5 LTS which has almost no load, it only runs the broker and has no subscribers other than the one I am testing.
The client is an Arduino 1400 MKR GSM connected over 3G network, it connects to the broker and then loops on the message receive callback without any other tasks.
mosquitto.conf
pid_file /var/run/mosquitto/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
log_timestamp true
log_timestamp_format %Y-%m-%d %H:%M:%S
log_type all
include_dir /etc/mosquitto/conf.d
default.conf
allow_anonymous false
password_file /etc/mosquitto/passwd
listener 1883
protocol mqtt
listener 8883
protocol mqtt
listener 8000
protocol websockets
listener 9001
protocol websockets
listener 8083
protocol websockets
cafile /etc/nginx-sp/ssl/xxx.combined_crt
keyfile /etc/nginx-sp/ssl/xxx.key
certfile /etc/nginx-sp/ssl/xxx.combined_crt
EDIT
Publisher code Using phpMQTT:
$mqtt = new phpMQTT($server, $port, $client_id);
if ($mqtt->connect(true, NULL, $username, $password)) {
$mqtt->publish($topic, $payload, 0);
$mqtt->close();
return 1;
}