Added timeout to request. Added the error code when a connection fails.