8266: [[http://pubsubclient.knolleary.net/|Arduino IDE client for MQTT on 8266]] * [[http://pubsubclient.knolleary.net/api.html#publish2|API docs]] Mosquitto: [[http://spin.atomicobject.com/2014/03/19/mqtt-protocol-ethernet/|getting started tutorial]] [[http://nthn.me/posts/2012/mqtt.html|another getting started tutorial]] [[http://mosquitto.org/documentation/|documentation]] [[http://test.mosquitto.org/|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 [[https://singztechmusings.wordpress.com/2011/07/11/ulimit-how-to-permanently-set-kernel-limits-in-linux/|here]] * also change /etc/sysctl.conf with open file settings explore limits as in [[https://lists.launchpad.net/mosquitto-users/msg00163.html|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 [[http://www.steves-internet-guide.com/mqtt-clean-sessions-example/|cleansession and the retain flag]] * //conclusion: it appears clean session only has meaning with QoS > 0// erase all retained messages: mosquitto_sub -i -p -h --retained-only -t "#" -v | while read line; do let "x=x+1"; echo $x; mosquitto_pub -i -p -h -t "${line% *}" -r -n; done' \\ ===== HA Proxy: ===== ==== Configuring for high # of connections (tested on 16.04) ==== 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' [[https://ma.ttias.be/linux-increase-ip_local_port_range-tcp-port-range/|increase ip_local_port_range]] === References === * [[http://rexpie.github.io/2015/08/26/loadbalancing-with-haproxy.html|Load balancing with HA proxy]] * [[https://www.linangran.com/?p=547|Configuring HA proxy for 300k connections]] * [[https://serverfault.com/questions/669596/configure-haproxy-on-linux-to-accept-10k-simultaneous-connections|important tip I needed for getting beyond 2048 connections]] [[https://github.com/lelylan/lelylan|Lelylan]] is an IoT framwork to making clustering etc. easier * [[https://github.com/lelylan/haproxy-mqtt/blob/master/haproxy.cfg|stuff about Lelylan with HAProxy]] [[https://github.com/mqtt/mqtt.github.io/wiki/Server%20support|chart comparing MQTT brokers]] [[https://serversforhackers.com/load-balancing-with-haproxy|complete article showing clustering with Mosca, HA Proxy and friends]]