Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Randomize local port used for Particle connection
It's a good idea to randomize the port used, otherwise a rebooted Oak will try and reconnect on the same port, which may result in a long delay if the connection was not closed before the reboot, as mentioned by @jldeon here: digistump#54 (comment) I believe I have observed this issue in practice on a few occasions, where it would take exactly five seconds for the first data to come through the connection, which seems too constant to be a random delay. As the read timeout in blocking_receive() is 2 s, this is obviously problematic. As most users will be behind routers running NAT, it will be the router settings, rather than the Particle server settings, that affect how reconnections from the same source port are treated.
- Loading branch information