v2.5.2 does not connect to failover pool when main pool dies, then crashes
**EDIT:** All problems reported by me in this thread are on Linux, Ubuntu 16.04. Windows apparently behaves differently.

Subj pretty much says it all. Proxy has been working fine for many hours, and then the pool crapped out (their server died) and I was expecting the proxy to automatically switch to the failover proxy.

It started saying `send failed, invalid state: 4` and also `connect error: "connection timed out"` ... for 17 minutes ... after 17 minutes it crashed entirely.

It also said `[2018-04-16 20:45:57] #003 no active pools, stop` which is false because the config file had 3 pools defined. Something is not working well here.

There were 10 messages `connect error: "connection timed out"` corresponding to the 10 retries I defined in the config file, but they were not 5 seconds apart like I defined in the config file. As you can see, the first 4 such messages were about 3 minutes apart each.

Config and log below of the session.

```
{
    "background": false,
    "log-file": "trtl.log",
    "access-log-file": null,
    "retries":10,
    "retry-pause": 5,
    "donate-level": 1,
    "algo": "cryptonight-lite",
    "custom-diff": 2000,
    "syslog": false,
    "verbose": true,
    "colors": true,
    "workers": true,
    "pools": [
        {
            "url": "trtl.mine2gether.com:5555",
            "user": "<wallet>",
            "pass": "x",
            "variant": 1,
        },
        {
            "url": "eu.turtlepool.space:7777",
            "user": "<wallet>",
            "pass": "x",
            "variant": 1,
        },
        {
            "url": "pool.trtl.unipool.pro:9999",
            "user": "<wallet>",
            "pass": "x",
            "variant": 1,
        },
    ],
    "bind": [
        "0.0.0.0:3333"
    ],
    "api": {
        "port": 0,
        "access-token": null,
        "worker-id": null
    }
}
```

Here's the log.

```
[2018-04-16 20:37:35] 13.33 kH/s, shares: 609251/0 +16, upstreams: 4, miners: <edited> (max <edited>) +0/-0
[2018-04-16 20:38:35] 13.50 kH/s, shares: 609416/0 +16, upstreams: 4, miners: <edited> (max <edited>) +0/-0
[2018-04-16 20:39:35] 11.50 kH/s, shares: 609557/0 +14, upstreams: 4, miners: <edited> (max <edited>) +0/-0
[2018-04-16 20:40:35] 0.00 kH/s, shares: 609557/0 +0, upstreams: 4, miners: <edited> (max <edited>) +1/-1
[2018-04-16 20:41:35] 0.00 kH/s, shares: 609557/0 +0, upstreams: 4, miners: <edited> (max <edited>) +1/-5
[2018-04-16 20:42:35] 0.00 kH/s, shares: 609557/0 +0, upstreams: 4, miners: <edited> (max <edited>) +1/-1
[2018-04-16 20:43:35] 0.00 kH/s, shares: 609557/0 +0, upstreams: 4, miners: <edited> (max <edited>) +1/-1
[2018-04-16 20:44:35] 0.00 kH/s, shares: 609557/0 +0, upstreams: 4, miners: <edited> (max <edited>) +5/-4
[2018-04-16 20:45:35] 0.00 kH/s, shares: 609557/0 +0, upstreams: 4, miners: <edited> (max <edited>) +8/-1
[2018-04-16 20:45:43] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:45:44] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:45:45] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:45:46] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:45:47] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:45:47] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:45:47] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:45:48] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:45:48] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:45:48] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:45:50] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:45:55] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:45:55] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:45:55] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:45:56] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:45:56] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:45:57] [trtl.mine2gether.com:5555] timeout
[2018-04-16 20:45:57] #003 no active pools, stop
[2018-04-16 20:45:57] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:45:58] [trtl.mine2gether.com:5555] send failed, invalid state: 4

[... HUNDREDS MESSAGES of "send failed, invalid state: 4" ...]

[2018-04-16 20:48:11] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:48:11] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:48:12] [trtl.mine2gether.com:5555] connect error: "connection timed out"
[2018-04-16 20:48:13] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:48:13] [trtl.mine2gether.com:5555] send failed, invalid state: 4

[... HUNDREDS MESSAGES of "send failed, invalid state: 4" ...]

[2018-04-16 20:50:24] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:50:25] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:50:27] [trtl.mine2gether.com:5555] connect error: "connection timed out"
[2018-04-16 20:50:29] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:50:31] [trtl.mine2gether.com:5555] send failed, invalid state: 4

[... HUNDREDS MESSAGES of "send failed, invalid state: 4" ...]

[2018-04-16 20:52:42] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:52:42] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:52:42] [trtl.mine2gether.com:5555] connect error: "connection timed out"
[2018-04-16 20:52:43] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:52:43] [trtl.mine2gether.com:5555] send failed, invalid state: 4

[... HUNDREDS MESSAGES of "send failed, invalid state: 4" ...]

[2018-04-16 20:54:57] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:54:57] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:54:58] [trtl.mine2gether.com:5555] connect error: "connection timed out"
[2018-04-16 20:54:58] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:54:58] [trtl.mine2gether.com:5555] send failed, invalid state: 4

[... HUNDREDS MESSAGES of "send failed, invalid state: 4" ...]

[2018-04-16 20:55:05] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:55:06] #002 no active pools, stop
[2018-04-16 20:55:06] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:55:07] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:55:08] #001 no active pools, stop
[2018-04-16 20:55:08] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:55:10] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:55:11] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:55:11] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:55:11] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:55:11] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:55:12] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:55:13] [trtl.mine2gether.com:5555] send failed, invalid state: 4
[2018-04-16 20:55:14] #000 no active pools, stop
[2018-04-16 20:55:35] 0.00 kH/s, shares: 609557/0 +0, upstreams: 0, miners: <edited> (max <edited>) +0/-1
[2018-04-16 20:56:17] [trtl.mine2gether.com:5555] connect error: "connection timed out"
[2018-04-16 20:56:35] 0.00 kH/s, shares: 609557/0 +0, upstreams: 0, miners: <edited> (max <edited>) +0/-0
[2018-04-16 20:57:13] [trtl.mine2gether.com:5555] connect error: "connection timed out"
[2018-04-16 20:57:21] [trtl.mine2gether.com:5555] connect error: "connection timed out"
[2018-04-16 20:57:23] [trtl.mine2gether.com:5555] connect error: "connection timed out"
[2018-04-16 20:57:29] [trtl.mine2gether.com:5555] connect error: "connection timed out"
[2018-04-16 20:57:35] 0.00 kH/s, shares: 609557/0 +0, upstreams: 0, miners: <edited> (max <edited>) +0/-0
[2018-04-16 20:57:41] [trtl.mine2gether.com:5555] connect error: "connection timed out"
xmrig-proxy: src/unix/stream.c:1230: uv__stream_io: Assertion `!(stream->flags & UV_CLOSING)' failed.
Aborted (core dumped)
```

