Added the gracefully shutdown for all client connections to release all these resources.
+ Refactoring of some functions + Added the retrying of all three connections + Added the documentation to the code + Improved the error messages