Corrected a condition error where trying to make a request with a closed connection still generates exceptions.
It is better to open the connection if it wasn't opened before.