question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Crash "ConnectionError: BadStatusLine"

See original GitHub issue

I have a very simple script. It makes an unverified account, sleeps 5 minutes, then does a get_posts_recent(skip=0, limit=60, after="", mine=False, hashtag="", channel="")

Pretty much taken straight out of the documentation/samples. PS I also tried the version without brackets, get_post_recent() (got the idea from your test file, its in one of the first tests).

However, a random number of cycles (usually 1-5), it will crash, with the error stack:

Traceback (most recent call last): File "C:\PythonScript\jodler.py", line 31, in <module> looped_recent = j.get_posts_recent(skip=0, limit=60, after="", mine=False, hashtag="", channel="") File "C:\Python27\lib\site-packages\jodel_api.py", line 214, in get_posts_recent return self._get_posts('', skip, limit, after, mine, hashtag, channel, **kwargs) File "C:\Python27\lib\site-packages\jodel_api.py", line 211, in _get_posts return self._send_request("GET", url, params=params, **kwargs) File "C:\Python27\lib\site-packages\jodel_api.py", line 62, in _send_request resp = s.request(method=method, url=url, params=params, json=payload, headers=headers, **kwargs) File "C:\Python27\lib\site-packages\requests\sessions.py", line 468, in request resp = self.send(prep, **send_kwargs) File "C:\Python27\lib\site-packages\requests\sessions.py", line 576, in send r = adapter.send(request, **kwargs) File "C:\Python27\lib\site-packages\requests\adapters.py", line 426, in send raise ConnectionError(err, request=request) ConnectionError: ('Connection aborted.', BadStatusLine("''",))

Line 31 in my script is as follows:

looped_recent = j.get_posts_recent(skip=0, limit=60, after="", mine=False, hashtag="", channel="")

Nothing fancy going on, but it dies. Any idea?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
nborrmanncommented, May 7, 2017

That error means that you’re receiving a malformed response or the server prematurely terminated the connection (cf [1], [2]).

It’s weird that you are getting the error so often, I can’t remember ever seeing this. It might be due to your specific combination of your OS, python version, ssl lib, even your ISP. Try different machines/connections and see if you’re still getting the error.

If nothing works, I’d recommend generously wrapping this in a try except and retrying upon an error.

Anyway, there’s not much jodel_api can do about that, so I’m closing this issue.

[1] https://github.com/kennethreitz/requests/issues/2364

[2] https://bugs.python.org/issue23054

0reactions
kristoffer-tveracommented, May 7, 2017

Thanks for getting back to me so quick during a weekend.

I ran into same issues in 2.7 and 3.5. I am not behind a proxy, but i haven’t tested the code on another connection, so it might come down to the connection.

I sat this up as a text-to-speech bot about 4 months ago, and didn’t recall running into any issues back then, so I assumed the API handled these network issues.

Wrapping everything up in try/catch loops works. I also bumped every instance of time.sleep up to double, and have been able to cycle through 72 times now without catching a single exception. Strange.

Read more comments on GitHub >

github_iconTop Results From Across the Web

('Connection aborted.', BadStatusLine("''",)) - Bugzilla@Mozilla
Retry currently only happens when ``requests.exceptions.HttpError`` exception is raised. I think retry should also happen on ``requests.exceptions.
Read more >
Python Requests XML API Exception ConnectionError
Python Requests XML API Exception ConnectionError: ('Connection aborted.', BadStatusLine("''",)) when xml size increases.
Read more >
bigsuds.ConnectionError: BadStatusLine - DevCentral
On a certain F5 (V11) I keep getting a Connecti : BasStatusLine: '' Looks like BigSuds is getting back a response that is...
Read more >
ConnectionError: ('Connection aborted.', BadStatusLine
It is telling you there was a bad status line, and what the bad status line contents was. (Used to be you couldn't...
Read more >
requests 2.14.0 - PyPI
Fix crash with custom method parameter to Session.request (#2317) ... Translate urllib3 ProxyError into a requests ProxyError derived from ConnectionError.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found