[OWSLib-users] connection refused when searching a specific metadata

Tom Kralidis tomkralidis at gmail.com
Fri Apr 29 05:17:14 PDT 2016


Hi Ernest:

On Fri, Apr 29, 2016 at 5:49 AM, Ernest Chiarello
<ernest.chiarello at univ-fcomte.fr> wrote:
> Hello,
>
> i am new in this list and in Python, so it is possible that i ask naive
> issues...
> i am looking for a specific metadata in geonetwork, according to owslib
> documentation.
>
> it works well with Chrome and Firefox, using this url:
> http://geonetwork-mshe.univ-fcomte.fr:8080/geonetwork/srv/fre/catalog.search#/metadata/8174d16d-240f-4199-9c2f-af6976e376b3
>
> but i fails with owslib. :'(
>
>>>> geonetwork =
>>>> 'http://geonetwork-mshe.univ-fcomte.fr:8080/geonetwork/srv/fre/csw'
>
>>>> csw = CatalogueServiceWeb(geonetwork)
>
>>>> csw.getrecordbyid(id=['8174d16d-240f-4199-9c2f-af6976e376b3'])
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
>   File "/usr/lib/python2.7/dist-packages/owslib/csw.py", line 293, in
> getrecordbyid
>     self._invoke()
>   File "/usr/lib/python2.7/dist-packages/owslib/csw.py", line 647, in
> _invoke
>     self.response = openURL(self.request, None, 'Get',
> username=self.username, password=self.password, timeout=self.timeout).read()
>   File "/usr/lib/python2.7/dist-packages/owslib/util.py", line 186, in
> openURL
>     **rkwargs)
>   File "/usr/lib/python2.7/dist-packages/requests/api.py", line 53, in
> request
>     return session.request(method=method, url=url, **kwargs)
>   File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 468, in
> request
>     resp = self.send(prep, **send_kwargs)
>   File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 576, in
> send
>     r = adapter.send(request, **kwargs)
>   File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 437, in
> send
>     raise ConnectionError(e, request=request)
> requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost',
> port=8080): Max retries exceeded with url:
> /geonetwork/srv/fre/csw?outputFormat=application%2Fxml&service=CSW&outputSchema=http%3A%2F%2Fwww.opengis.net%2Fcat%2Fcsw%2F2.0.2&request=GetRecordById&version=2.0.2&elementsetname=full&id=8174d16d-240f-4199-9c2f-af6976e376b3
> (Caused by
> NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection
> object at 0x7fd4f8050fd0>: Failed to establish a new connection: [Errno 111]
> Connection refused',))
>
> any idea ?
>

I'm guessing the CSW you are querying has 'http://localhost:8080' set as it's
host in the CSW configuration.  OWSLib's CSW support does a GetCapabilities
request by default to get this information.  You can use the skip_caps=True
parameter to bypass this:

csw = CatalogueServiceWeb(geonetwork, skip_caps=True)

which means OWSLib will always use the URL you specify when initializing
the CSW.  This is not always guaranteed to work as some CSW implementations
have URLs which differ depending on the operation.

Having said this, the CSW itself should update its configuration accordingly
to prevent this issue from manifesting itself for downstream
clients/applications.

Hope this helps.

..Tom

> Thanks in advance.
>
> Ernest.
>


More information about the OWSLib-users mailing list