Improve server connection

Sometimes, the server socket has not been started on the server process side
which results in a connection error client side. To fix this, the client will
try to connect 10 times if the connection was refused or timeout. After 10 unsuccessful connection, a RuntimeError will be raised