With the solution of connect, then check connection and close if problem and then call connect again i think we can fall in a recursive loop if the error is persisting for 5-6 seconds (may be network choke) and then PHP will crash because of out of memory.