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

http.client.BadStatusLine #88

Closed
fratamico opened this issue May 15, 2020 · 4 comments
Closed

http.client.BadStatusLine #88

fratamico opened this issue May 15, 2020 · 4 comments
Labels
bug Something isn't working

Comments

@fratamico
Copy link

Thank you so much for this api! When running on my personal computer it runs fine, however when running on an AWS ubuntu server, I get the BadStatusLine error occasionally when hitting the api.bySound method. Any ideas what could be causing this? I'm running python 3.7.7 and am on the latest version of your TikTokAPI on my server.

The full error trace is below:

Traceback (most recent call last):
  File "src/get_video_by_song.py", line 26, in get_videos_by_song_id
    tiktoks = api.bySound(song_id, count)
  File "/home/ubuntu/.local/lib/python3.7/site-packages/TikTokApi/tiktok.py", line 92, in bySound
    b = browser(api_url)
  File "/home/ubuntu/.local/lib/python3.7/site-packages/TikTokApi/browser.py", line 27, in __init__
    asyncio.get_event_loop().run_until_complete(self.start())
  File "/usr/lib/python3.7/asyncio/base_events.py", line 587, in run_until_complete
    return future.result()
  File "/home/ubuntu/.local/lib/python3.7/site-packages/TikTokApi/browser.py", line 30, in start
    self.browser = await pyppeteer.launch(self.options)
  File "/home/ubuntu/.local/lib/python3.7/site-packages/pyppeteer/launcher.py", line 305, in launch
    return await Launcher(options, **kwargs).launch()
  File "/home/ubuntu/.local/lib/python3.7/site-packages/pyppeteer/launcher.py", line 166, in launch
    self.browserWSEndpoint = get_ws_endpoint(self.url)
  File "/home/ubuntu/.local/lib/python3.7/site-packages/pyppeteer/launcher.py", line 227, in get_ws_endpoint
    with urlopen(url) as f:
  File "/usr/lib/python3.7/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.7/urllib/request.py", line 525, in open
    response = self._open(req, data)
  File "/usr/lib/python3.7/urllib/request.py", line 543, in _open
    '_open', req)
  File "/usr/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.7/urllib/request.py", line 1347, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/lib/python3.7/urllib/request.py", line 1322, in do_open
    r = h.getresponse()
  File "/usr/lib/python3.7/http/client.py", line 1344, in getresponse
    response.begin()
  File "/usr/lib/python3.7/http/client.py", line 306, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.7/http/client.py", line 288, in _read_status
    raise BadStatusLine(line)
http.client.BadStatusLine: GET /json/version HTTP/1.1
@fratamico fratamico added the bug Something isn't working label May 15, 2020
@davidteather
Copy link
Owner

One thing I would check is make sure the ubuntu firewall as well as your aws security policy allows for outgoing connections.

Another thing might be TikTok is doing spam protection against that data center if too many requests are being sent to their servers from the data center.

Here's a stackover flow that may help.

@davidteather davidteather changed the title [ERROR] http.client.BadStatusLine: GET /json/version HTTP/1.1 Error on AWS Ubuntu Server May 15, 2020
@fratamico
Copy link
Author

Thanks! It doesn't always error and seems to run faster on the server, so perhaps it is the TikTok spam detection. I'll try throttling it.

@fratamico
Copy link
Author

Just adding a time.sleep(30) each (rare) time that error occurred, then trying again seemed to fix it. Thanks again!

@davidteather
Copy link
Owner

No problem glad I could help

This was referenced Jun 9, 2020
@davidteather davidteather changed the title Error on AWS Ubuntu Server http.client.BadStatusLine Jun 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants