Avoid blocking if server connection is termanated
Fix condition
Remove unused parameter