wiktorn / Overpass-API

Overpass API docker image
MIT License
134 stars 48 forks source link

http.client.IncompleteRead #61

Closed julianmlr closed 9 months ago

julianmlr commented 3 years ago

The get request in python is not working. I am hosting on a gcloud computing instance. With Postman and Curl the request is working, but not with python and the request lib.

Docker configuration:


docker run \
  -e OVERPASS_META=yes \
  -e OVERPASS_MODE=clone \
  -e OVERPASS_DIFF_URL=https://planet.openstreetmap.org/replication/minute/ \
  -e OVERPASS_RATE_LIMIT=1 \
  -e OVERPASS_SPACE=8589934592 \
  -v /big/docker/overpass_clone_db/:/db \
  -p 12346:80 \
  -i -t \
  --name overpass_world \
  wiktorn/overpass-api

docker start overpass_world

Working: curl --location -g --request GET 'http://35.242.198.27:12346/api/interpreter?data=[timeout:3600][maxsize:1073741824][out:json];node(around:5000,51.408159,7.2989356,51.4030306,7.3490601,51.4364065,7.3528927,51.4466813,7.3238974,51.408159,7.2989356)[name];out;%0A'

Not working:


url = "http://35.242.198.27:12346/api/interpreter?data=[timeout:3600][maxsize:1073741824][out:json];node(around:5000,51.408159,7.2989356,51.4030306,7.3490601,51.4364065,7.3528927,51.4466813,7.3238974,51.408159,7.2989356)[name];out;"

response = requests.request("GET", url)
#
print(response.text)`
Produces the following error:

Traceback (most recent call last):
  File "/home/julian/develop/dielage/backend/real-estate-integrator/venv/lib/python3.8/site-packages/urllib3/response.py", line 436, in _error_catcher
    yield
  File "/home/julian/develop/dielage/backend/real-estate-integrator/venv/lib/python3.8/site-packages/urllib3/response.py", line 766, in read_chunked
    chunk = self._handle_chunk(amt)
  File "/home/julian/develop/dielage/backend/real-estate-integrator/venv/lib/python3.8/site-packages/urllib3/response.py", line 710, in _handle_chunk
    value = self._fp._safe_read(amt)
  File "/usr/lib/python3.8/http/client.py", line 614, in _safe_read
    raise IncompleteRead(data, amt-len(data))
http.client.IncompleteRead: IncompleteRead(5461 bytes read, 4779 more expected)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/julian/develop/dielage/backend/real-estate-integrator/venv/lib/python3.8/site-packages/requests/models.py", line 751, in generate
    for chunk in self.raw.stream(chunk_size, decode_content=True):
  File "/home/julian/develop/dielage/backend/real-estate-integrator/venv/lib/python3.8/site-packages/urllib3/response.py", line 571, in stream
    for line in self.read_chunked(amt, decode_content=decode_content):
  File "/home/julian/develop/dielage/backend/real-estate-integrator/venv/lib/python3.8/site-packages/urllib3/response.py", line 792, in read_chunked
    self._original_response.close()
  File "/usr/lib/python3.8/contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "/home/julian/develop/dielage/backend/real-estate-integrator/venv/lib/python3.8/site-packages/urllib3/response.py", line 454, in _error_catcher
    raise ProtocolError("Connection broken: %r" % e, e)
urllib3.exceptions.ProtocolError: ('Connection broken: IncompleteRead(5461 bytes read, 4779 more expected)', IncompleteRead(5461 bytes read, 4779 more expected))

During handling of the above exception, another exception occurred:
proformance commented 3 years ago

I had the same issue, and it actually turned out to be a full disk (docker had filled up the disk with a 7GB logfile). It worked well with small query-results, but once they were a bit larger I got the same issue.

You mention that the curl works, don't forget to pay attention to the result, is it really a valid json?

Hope it helps

Best regards