Fix the issue that requests may hang
For some reasons, I get an issue that could not update DNS record repeatedly by docker. When I checked the logs, I found logs without timestamps, making it difficult to debug. And I attempted to debug by using gdb and pstack. It turns out that it just doesn't work. The last logs I get looks like: đĄ Updating record {'type': 'A', 'name': 'my.domain', 'content': 'ip4', 'proxied': False, 'ttl': 300} đĄ Updating record {'type': 'AAAA', 'name': 'my.domain', 'content': 'ipv6', 'proxied': False, 'ttl': 300} However, what I see in Cloudflare shows that the time of the last audit log is the time when I started the Docker container. I cannot verify it because of the lack of timestamp in the log. For this purpose, I create this pull request.
Finally, I found where the problem is. In some regions on Earth, requests may never get a response. To deal with this situation, we need to add a timeout parameter to throw an Exception when a timeout occurs. I reproduced this issue by doing nothing. It will always reproduce, and the stack shows it hangs on the method 'hand_shake'.
Changes include:
- Add the parameter 'timeout' to handle the case when a timeout occurs.
- Add logging to custom log level for some extra information.
I'm experiencing similar issues as described in OP. @timothymiller any chance we could get this merged?
#157 should also be checked. It alters also the output.