PCT-697: Agent is running but PCT says it's not

* PCT-697: Agent is running but PCT says it's not
* PCT-629: Agent running but not connected
Yes, I don't like this approach also, we can avoid this delay for first server, because we have infinite loop for connection, but we can't avoid some delay for second server, because then we will can an error "connection refused". So I just used code that we had.