prop/lib/microwaveprop/pskr
Graham McIntire 5521b0b153
fix(pskr): handshake on passive socket, switch to active after SUBSCRIBE
`:gen_tcp.recv/3` requires a passive socket and returns `:einval` if
the socket is in any active mode. We were opening with
`active: :once`, sending CONNECT, then calling `:gen_tcp.recv` to
read CONNACK — which kernel-rejected every time.

The visible symptom was "Pskr.Client connect failed: :einval" every
30s on the elected leader, while a manual `:gen_tcp.connect` from
`bin/microwaveprop rpc` worked because it never tried to recv. Each
failed attempt also leaked a port (connect succeeded; recv failed
later), and we'd accumulated ~27 dangling sockets on the leader
process.

Open the socket in `active: false`, finish the synchronous
CONNECT/CONNACK/SUBSCRIBE handshake with `:gen_tcp.recv`, then
`:inet.setopts(active: :once)` so PUBLISHes arrive as
`{:tcp, socket, data}` messages going forward. Also close the
socket on any handshake failure so retries stop leaking ports.
2026-05-04 10:39:43 -05:00
..
aggregator.ex feat(pskr): ingest PSK Reporter MQTT firehose for weather correlation 2026-05-04 09:24:20 -05:00
client.ex fix(pskr): handshake on passive socket, switch to active after SUBSCRIBE 2026-05-04 10:39:43 -05:00
mqtt.ex refactor(pskr): drop emqtt, talk MQTT 3.1.1 over :gen_tcp directly 2026-05-04 09:52:34 -05:00
spot_hourly.ex feat(pskr): ingest PSK Reporter MQTT firehose for weather correlation 2026-05-04 09:24:20 -05:00