Repository: sunpy/sunpy

Issue:
VSOClient should fail to initilize if it can't read the WSDL
Currently what happens is this:

```
/home/stuart/Git/sunpy/sunpy/net/vso/vso.py:93: UserWarning: Connection failed with error <urlopen error [Errno -3] Temporary failure in name resolution>. 
 Retrying with different url and port.
  "Connection failed with error {}. \n Retrying with different url and port.".format(e))
Traceback (most recent call last):
  File "test_download.py", line 14, in <module>
    a.Wavelength(171*u.angstrom) | a.Wavelength(94*u.angstrom))
  File "/home/stuart/Git/sunpy/sunpy/net/fido_factory.py", line 297, in search
    return UnifiedResponse(query_walker.create(query, self))
  File "/home/stuart/Git/sunpy/sunpy/net/attr.py", line 411, in create
    return self.createmm(self, *args, **kwargs)
  File "/home/stuart/Git/sunpy/sunpy/util/multimethod.py", line 120, in __call__
    return fun(*args, **kwargs)
  File "/home/stuart/Git/sunpy/sunpy/net/fido_factory.py", line 238, in _create_or
    qblocks.extend(walker.create(attr.and_(attrblock), factory))
  File "/home/stuart/Git/sunpy/sunpy/net/attr.py", line 411, in create
    return self.createmm(self, *args, **kwargs)
  File "/home/stuart/Git/sunpy/sunpy/util/multimethod.py", line 120, in __call__
    return fun(*args, **kwargs)
  File "/home/stuart/Git/sunpy/sunpy/net/fido_factory.py", line 231, in _create_and
    return [factory._make_query_to_client(*query.attrs)]
  File "/home/stuart/Git/sunpy/sunpy/net/fido_factory.py", line 431, in _make_query_to_client
    return tmpclient.search(*query), tmpclient
  File "/home/stuart/Git/sunpy/sunpy/net/vso/vso.py", line 303, in search
    QueryRequest = self.api.get_type('VSO:QueryRequest')
AttributeError: 'NoneType' object has no attribute 'get_type'


```


Discussion:
You can reproduce this by creating `VSOClient()` object without an internet connection.
I wonder how many clients also error like that. 

Resolving patch:
diff --git a/sunpy/net/vso/vso.py b/sunpy/net/vso/vso.py
--- a/sunpy/net/vso/vso.py
+++ b/sunpy/net/vso/vso.py
@@ -91,15 +91,22 @@ def check_connection(url):
     except (socket.error, socket.timeout, HTTPError, URLError) as e:
         warnings.warn(
             "Connection failed with error {}. \n Retrying with different url and port.".format(e))
+        return None
 
 
 def get_online_vso_url(api, url, port):
-    if api is None and (url is None or port is None):
-        for mirror in DEFAULT_URL_PORT:
-            if check_connection(mirror['url']):
-                api = zeep.Client(mirror['url'], port_name=mirror['port'])
-                api.set_ns_prefix('VSO', 'http://virtualsolar.org/VSO/VSOi')
-                return api
+    if isinstance(api, zeep.client.Client):
+        return api
+
+    if url and check_connection(url):
+        api = zeep.Client(url, port)
+        return api
+
+    for mirror in DEFAULT_URL_PORT:
+        if check_connection(mirror['url']):
+            api = zeep.Client(mirror['url'], port_name=mirror['port'])
+            api.set_ns_prefix('VSO', 'http://virtualsolar.org/VSO/VSOi')
+            return api
 
 
 class QueryResponse(list):
@@ -256,6 +263,8 @@ class VSOClient(BaseClient):
 
     def __init__(self, url=None, port=None, api=None):
         api = get_online_vso_url(api, url, port)
+        if api is None:
+            raise ConnectionError("Cannot find an online VSO mirror.")
         self.api = api
 
     def make(self, atype, **kwargs):


Test patch:
diff --git a/sunpy/net/tests/test_vso.py b/sunpy/net/tests/test_vso.py
--- a/sunpy/net/tests/test_vso.py
+++ b/sunpy/net/tests/test_vso.py
@@ -1,15 +1,15 @@
 # -*- coding: utf-8 -*-
 
 import pytest
-
+from unittest import mock
 import astropy.units as u
 
 from sunpy.time import TimeRange, parse_time
 from sunpy.net import vso
 from sunpy.net.vso import attrs as va
+from sunpy.net.vso.vso import VSOClient, get_online_vso_url
 from sunpy.net.vso import QueryResponse
 from sunpy.net import attr
-
 from sunpy.tests.mocks import MockObject
 
 
@@ -410,3 +410,20 @@ def test_vso_hmi(client, tmpdir):
         fileids = dri.fileiditem.fileid
         series = list(map(lambda x: x.split(':')[0], fileids))
         assert all([s == series[0] for s in series])
+
+
+@mock.patch('sunpy.net.vso.vso.check_connection', return_value=None)
+def test_get_online_vso_url(mock_urlopen):
+    """
+    No wsdl links returned valid HTTP response? Return None
+    """
+    assert get_online_vso_url(None, None, None) is None
+
+
+@mock.patch('sunpy.net.vso.vso.get_online_vso_url', return_value=None)
+def test_VSOClient(mock_vso_url):
+    """
+    Unable to find any valid VSO mirror? Raise ConnectionError
+    """
+    with pytest.raises(ConnectionError):
+        VSOClient()