8266:

Arduino IDE client for MQTT on 8266

Mosquitto:

getting started tutorial another getting started tutorial documentation mosquitto test server mosquitto has a limit of the number of open connections as defined by ulimit -n. It defaults to 1024 but can be increased e.g. sudo ulimit -n 2048

  • make the limit setting permanent by editing /etc/security/limits.conf as explained here
  • also change /etc/sysctl.conf with open file settings

explore limits as in this thread

mosquitto client:

example pub call: mosquitto_pub -h filimin.no-ip.info -p 8883 -d -t hello/world -m “Hello World” –insecure –cafile /tmp/ca.crt -I ESP8266

  • -d enable debug messages
  • –insecure accept the certificate even if it doesn't match the host name
  • –cafile this must match the cafile on the server…and you can't do an SSL-encrypted call from the client apparently without this file.
  • -I ID prefix for client name

cleansession and the retain flag

  • conclusion: it appears clean session only has meaning with QoS > 0

erase all retained messages: mosquitto_sub -i <client_id> -p <port> -h <host> –retained-only -t “#” -v | while read line; do let “x=x+1”; echo $x; mosquitto_pub -i <client_id> -p <port> -h <host> -t “${line% *}” -r -n; done'

edit /etc/sysctl.conf and add the following lines (increase open file limit and decrease memory use of TCP buffers:

fs.file-max = 10000000
fs.nr_open = 10000000
net.ipv4.tcp_mem = 786432 1697152 1945728
net.ipv4.tcp_rmem = 4096 4096 16777216
net.ipv4.tcp_wmem = 4096 4096 16777216
net.ipv4.ip_local_port_range = 15000 65535

edit /etc/security/limits.conf:

* soft nofile 10000000
* hard nofile 10000000
root soft nofile 10000000
root hard nofile 10000000

add to /etc/haproxy/haproxy.conf: in defaults:

maxconn 2000000
timeout connect 3000000 # necessary?
timeout client 66000000 # necessary?
timeout server 66000000 # necessary?

 

check:

pidof haproxy
cat /proc/630/limits | grep 'open files'

increase ip_local_port_range

References