Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote end closed connection without response #15

Closed
VGalata opened this issue Aug 31, 2018 · 2 comments
Closed

Remote end closed connection without response #15

VGalata opened this issue Aug 31, 2018 · 2 comments

Comments

@VGalata
Copy link

VGalata commented Aug 31, 2018

Hello!

I have a problem using geocoder.geocode for many queries (ca. 1200) in a for-loop: It throws an error ("Remote end closed connection without response") and stops with a Segmentation fault. I have a free trial account, so I made sure to have a pause of 2 seconds after each query. Also, the total number of made queries was below the daily limit. In total, I made three attempts and each time the error was thrown after a different number of processed requests.

Could you help me to find out why this could happen and how to avoid/solve it?

Thank you in advance!

Here is a code snippet to show how I made the requests:

from opencage.geocoder import OpenCageGeocode
geocoder = OpenCageGeocode('...') # my API key

df = ... # table with locations

for i in df.index:
        query  = df.loc[i,'Location']
        location = geocoder.geocode(query)
        sleep(2)
        # check and save the result

Here is the output after the error is thrown:

Traceback (most recent call last):
  File "/home/valia/Work/venv_3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/home/valia/Work/venv_3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 384, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/home/valia/Work/venv_3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 380, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib64/python3.7/http/client.py", line 1321, in getresponse
    response.begin()
  File "/usr/lib64/python3.7/http/client.py", line 296, in begin
    version, status, reason = self._read_status()
  File "/usr/lib64/python3.7/http/client.py", line 265, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/valia/Work/venv_3/lib/python3.7/site-packages/requests/adapters.py", line 445, in send
    timeout=timeout
  File "/home/valia/Work/venv_3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/home/valia/Work/venv_3/lib/python3.7/site-packages/urllib3/util/retry.py", line 367, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/home/valia/Work/venv_3/lib/python3.7/site-packages/urllib3/packages/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/home/valia/Work/venv_3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/home/valia/Work/venv_3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 384, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/home/valia/Work/venv_3/lib/python3.7/site-packages/urllib3/connectionpool.py", line 380, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib64/python3.7/http/client.py", line 1321, in getresponse
    response.begin()
  File "/usr/lib64/python3.7/http/client.py", line 296, in begin
    version, status, reason = self._read_status()
  File "/usr/lib64/python3.7/http/client.py", line 265, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "parse_locs.py", line 131, in <module>
    if pandas.isnull(query_):
  File "/home/valia/Work/venv_3/lib/python3.7/site-packages/opencage/geocoder.py", line 118, in geocode
    response = requests.get(url, params=data)
  File "/home/valia/Work/venv_3/lib/python3.7/site-packages/requests/api.py", line 72, in get
    return request('get', url, params=params, **kwargs)
  File "/home/valia/Work/venv_3/lib/python3.7/site-packages/requests/api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/valia/Work/venv_3/lib/python3.7/site-packages/requests/sessions.py", line 512, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/valia/Work/venv_3/lib/python3.7/site-packages/requests/sessions.py", line 622, in send
    r = adapter.send(request, **kwargs)
  File "/home/valia/Work/venv_3/lib/python3.7/site-packages/requests/adapters.py", line 495, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
Segmentation fault (core dumped)

Edit: Typos

@mtmail
Copy link
Member

mtmail commented Sep 2, 2018

We contacted the user the same hour via email. That's easier when exchanging URLs containing API keys. So far it looks like a network connection problem from computer to our servers (same country, pretty unexplainable) while all previous queries were fast, no errors and no timeouts.

@mtmail mtmail closed this as completed Sep 2, 2018
@VGalata
Copy link
Author

VGalata commented Sep 3, 2018

The fourth attempt worked, I had no errors for all ~1200 queries. So, probably there was a problem with our network.

Thank you very much for the very fast reply!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants