The solution is simple - instead of rebooting the dongle, switch between 4G/3G and turn mobile data off, and then on.
That's it, you will have 4-5 second rotation time.
For some carriers switching the band will do the trick as well and it will increase the rotation time even more.
You will need to implement fallbacks to hard reset if dongle fails to rotate using this approach or just hangs(if you use huawei)
To absolutely remove the downtime - have a pool of spare dongles waiting to take over the work till the dongle is rotated.
Thanks
@lucky.sparks this is exactly the information I needed. Will test and report back.
Here are some other solutions I tried so far:
1. Fallback to Ethernetconnection during restart: I did this by setting up a rudimentary inter-process communication between my ProxyRefresh script and my browser automation script - - whenever the ProxyRefreshscript starts, it pings the automation script, and the automation script un-sets the proxies and continues running the script. Another ping when ProxyRefresh ends, and the automation script returns to using the proxies.
I didn't like exposing my Ethernet connection IP, so I'm not too keen on this solution.
2. Fallback to a router/dongle - - same IPC as before, but it switches to a spare dongle. I don't particularly like this one because it means for 30 sec all the scripts will be running on a single proxy. To make this work, I would have to have more than just 1 spare router/dongle.
3. A load-based refresh - all my automation agents communicate with a central database to log their start times, the task they're currently performing etc, and this includes which proxy they're currently using in relational tables. I wrote a cron job that checks if any of the proxies are unused (have no related agents) and refresh the ones that are unused, setting a flag refreshing=1 to prevent race conditions like an automation agent attempting to use a proxy that the ProxyRefresh script is just about to assign for refreshing. This works in my unit tests, but it fails in real-world scenarios because the number of automation scripts is far higher than the number of proxies I'm using, so none of the proxies are ever "idle".