astropy / astropy/astroquery

NED broken connection

Open
#1,783 0 comments 0 reactions 0 assignees View on GitHub
bug ipac.ned
Dominant language
Python
Stars
791
Forks
451
Avg merge
1d 3h
Merged PRs (30d)
4

Description

I am trying to query the objects using astroquery.ned and I always get a broken connection error as soon as I go over 0.5 degree radius.

```
from astroquery.ned import Ned
import astropy.units as u
Ned.TIMEOUT=10000000
from astropy.coordinates import SkyCoord

co = SkyCoord(ra=95, dec=-52, unit=(u.deg, u.deg), frame='fk5')
table = Ned.query_region(co, radius=1*u.deg)
```

I always get the following output

```
ValueError Traceback (most recent call last)
~/anaconda3/lib/python3.7/site-packages/urllib3/response.py in _update_chunk_length(self)
600 try:
--> 601 self.chunk_left = int(line, 16)
602 except ValueError:

ValueError: invalid literal for int() with base 16: b''

During handling of the above exception, another exception occurred:

IncompleteRead Traceback (most recent call last)
~/anaconda3/lib/python3.7/site-packages/urllib3/response.py in _error_catcher(self)
359 try:
--> 360 yield
361

~/anaconda3/lib/python3.7/site-packages/urllib3/response.py in read_chunked(self, amt, decode_content)
665 while True:
--> 666 self._update_chunk_length()
667 if self.chunk_left == 0:

~/anaconda3/lib/python3.7/site-packages/urllib3/response.py in _update_chunk_length(self)
604 self.close()
--> 605 raise httplib.IncompleteRead(line)
606

IncompleteRead: IncompleteRead(0 bytes read)

During handling of the above exception, another exception occurred:

ProtocolError Traceback (most recent call last)
~/anaconda3/lib/python3.7/site-packages/requests/models.py in generate()
749 try:
--> 750 for chunk in self.raw.stream(chunk_size, decode_content=True):
751 yield chunk

~/anaconda3/lib/python3.7/site-packages/urllib3/response.py in stream(self, amt, decode_content)
489 if self.chunked and self.supports_chunked_reads():
--> 490 for line in self.read_chunked(amt, decode_content=decode_content):
491 yield line

~/anaconda3/lib/python3.7/site-packages/urllib3/response.py in read_chunked(self, amt, decode_content)
693 if self._original_response:
--> 694 self._original_response.close()
695

~/anaconda3/lib/python3.7/contextlib.py in __exit__(self, type, value, traceback)
129 try:
--> 130 self.gen.throw(type, value, traceback)
131 except StopIteration as exc:

~/anaconda3/lib/python3.7/site-packages/urllib3/response.py in _error_catcher(self)
377 # This includes IncompleteRead.
--> 378 raise ProtocolError('Connection broken: %r' % e, e)
379

ProtocolError: ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read))

During handling of the above exception, another exception occurred:

ChunkedEncodingError Traceback (most recent call last)
in
2 coNC = SkyCoord(ra=centers[index][0], dec=centers[index][1],
3 unit=(u.deg, u.deg), frame='fk5')
----> 4 tableNC = Ned.query_region(coNC, radius=1*u.deg)

~/anaconda3/lib/python3.7/site-packages/astroquery/ned/core.py in query_region(self, coordinates, radius, equinox, get_query_payload, verbose)
139 response = self.query_region_async(coordinates, radius=radius,
140 equinox=equinox,
--> 141 get_query_payload=get_query_payload)
142 if get_query_payload:
143 return response

~/anaconda3/lib/python3.7/site-packages/astroquery/ned/core.py in query_region_async(self, coordinates, radius, equinox, get_query_payload)
204 return request_payload
205 response = self._request("GET", url=Ned.OBJ_SEARCH_URL,
--> 206 params=request_payload, timeout=Ned.TIMEOUT)
207 return response
208

~/anaconda3/lib/python3.7/site-packages/astroquery/query.py in _request(self, method, url, params, data, headers, files, save, savedir, timeout, cache, stream, auth, continuation, verify, allow_redirects, json)
261 allow_redirects=allow_redirects,
262 verify=verify,
--> 263 json=json)
264 to_cache(response, query.request_file(self.cache_location))
265 self._last_query = query

~/anaconda3/lib/python3.7/site-packages/astroquery/query.py in request(self, session, cache_location, stream, auth, verify, allow_redirects, json)
69 stream=stream, auth=auth, verify=verify,
70 allow_redirects=allow_redirects,
---> 71 json=json)
72
73 def hash(self):

~/anaconda3/lib/python3.7/site-packages/requests/sessions.py in request(self, method, url, params, data, headers, cookies, files, auth, timeout, allow_redirects, proxies, hooks, stream, verify, cert, json)
531 }
532 send_kwargs.update(settings)
--> 533 resp = self.send(prep, **send_kwargs)
534
535 return resp

~/anaconda3/lib/python3.7/site-packages/requests/sessions.py in send(self, request, **kwargs)
684
685 if not stream:
--> 686 r.content
687
688 return r

~/anaconda3/lib/python3.7/site-packages/requests/models.py in content(self)
826 self._content = None
827 else:
--> 828 self._content = b''.join(self.iter_content(CONTENT_CHUNK_SIZE)) or b''
829
830 self._content_consumed = True

~/anaconda3/lib/python3.7/site-packages/requests/models.py in generate()
751 yield chunk
752 except ProtocolError as e:
--> 753 raise ChunkedEncodingError(e)
754 except DecodeError as e:
755 raise ContentDecodingError(e)

ChunkedEncodingError: ('Connection broken: IncompleteRead(0 bytes read)', IncompleteRead(0 bytes read))
```
Any suggestion is highly appreciated

Contributor guide

Open the contributing guide

Research direction

Start with astroquery/ned/core.py, especially query_region and query_region_async, and reproduce the supplied SkyCoord query with a radius above 0.5 degrees. Trace the request and response handling around the reported ChunkedEncodingError; done means the query completes reliably or the failure is documented with a clear, actionable limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.