nunoloureiro / birdtradebot

Cryptocurrency Bot that receives trading advice and performs transactions (manages wallets)
MIT License
13 stars 3 forks source link

Bot Crash on Twitter API connection problem #2

Closed edgardurao closed 6 years ago

edgardurao commented 6 years ago

Crashed on Twitter API connection problem

Traceback (most recent call last): File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main "main", fname, loader, pkg_name) File "/usr/lib/python2.7/runpy.py", line 72, in _run_code exec code in run_globals File "/home/user/Documents/birdtradebot-master/birdtradebot/main.py", line 4, in go() File "birdtradebot/init.py", line 966, in go trader.run() File "birdtradebot/init.py", line 565, in run self._run() File "birdtradebot/init.py", line 250, in _run ids_map = twitter_handles_to_userids(self.twitter, self.handles) File "birdtradebot/init.py", line 158, in twitter_handles_to_userids ids_map[handle] = twitter.show_user(screen_name=handle)['id_str'] File "/home/user/.local/lib/python2.7/site-packages/twython/endpoints.py", line 569, in show_user return self.get('users/show', params=params) File "/home/user/.local/lib/python2.7/site-packages/twython/api.py", line 264, in get return self.request(endpoint, params=params, version=version) File "/home/user/.local/lib/python2.7/site-packages/twython/api.py", line 258, in request api_call=url) File "/home/user/.local/lib/python2.7/site-packages/twython/api.py", line 161, in _request raise TwythonError(str(e)) twython.exceptions.TwythonError: ('Connection aborted.', error("(104, 'ECONNRESET')",))

nunoloureiro commented 6 years ago

Thanks, it's a known bug, I've experienced it myself..

While there isn't a fix, I'll show you how I do it:

You also need to change init.py on line 907 and hardcode the password that encrypts the config file with the keys. Yeah, that's not pretty but it's a workaround for now...

poupas commented 6 years ago

The fix has landed on the master branch.

nunoloureiro commented 6 years ago

It still crashes:

Traceback (most recent call last):
  File "/home/nuno/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 601, in urlopen
    chunked=chunked)
  File "/home/nuno/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 387, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/home/nuno/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 383, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.5/http/client.py", line 1197, in getresponse
    response.begin()
  File "/usr/lib/python3.5/http/client.py", line 297, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.5/http/client.py", line 258, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.5/socket.py", line 575, in readinto
    return self._sock.recv_into(b)
  File "/usr/lib/python3.5/ssl.py", line 929, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/lib/python3.5/ssl.py", line 791, in read
    return self._sslobj.read(len, buffer)
  File "/usr/lib/python3.5/ssl.py", line 575, in read
    v = self._sslobj.read(len, buffer)
ConnectionResetError: [Errno 104] Connection reset by peer
During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/nuno/.local/lib/python3.5/site-packages/requests/adapters.py", line 440, in send
    timeout=timeout
  File "/home/nuno/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 639, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/home/nuno/.local/lib/python3.5/site-packages/urllib3/util/retry.py", line 357, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/home/nuno/.local/lib/python3.5/site-packages/urllib3/packages/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/home/nuno/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 601, in urlopen
    chunked=chunked)
  File "/home/nuno/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 387, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/home/nuno/.local/lib/python3.5/site-packages/urllib3/connectionpool.py", line 383, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.5/http/client.py", line 1197, in getresponse
    response.begin()
  File "/usr/lib/python3.5/http/client.py", line 297, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.5/http/client.py", line 258, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.5/socket.py", line 575, in readinto
    return self._sock.recv_into(b)
  File "/usr/lib/python3.5/ssl.py", line 929, in recv_into
    return self.read(nbytes, buffer)
  File "/usr/lib/python3.5/ssl.py", line 791, in read
    return self._sslobj.read(len, buffer)
  File "/usr/lib/python3.5/ssl.py", line 575, in read
    v = self._sslobj.read(len, buffer)
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/nuno/.local/lib/python3.5/site-packages/twython/api.py", line 159, in _request
    response = func(url, **requests_args)
  File "/home/nuno/.local/lib/python3.5/site-packages/requests/sessions.py", line 521, in get
    return self.request('GET', url, **kwargs)
  File "/home/nuno/.local/lib/python3.5/site-packages/requests/sessions.py", line 508, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/nuno/.local/lib/python3.5/site-packages/requests/sessions.py", line 618, in send
    r = adapter.send(request, **kwargs)
  File "/home/nuno/.local/lib/python3.5/site-packages/requests/adapters.py", line 490, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "birdtradebot/__init__.py", line 195, in twitter_handles_to_userids
    ids_map[handle] = twitter.show_user(screen_name=handle)['id_str']
  File "/home/nuno/.local/lib/python3.5/site-packages/twython/endpoints.py", line 569, in show_user
    return self.get('users/show', params=params)
  File "/home/nuno/.local/lib/python3.5/site-packages/twython/api.py", line 264, in get
    return self.request(endpoint, params=params, version=version)
  File "/home/nuno/.local/lib/python3.5/site-packages/twython/api.py", line 258, in request
    api_call=url)
  File "/home/nuno/.local/lib/python3.5/site-packages/twython/api.py", line 161, in _request
    raise TwythonError(str(e))
twython.exceptions.TwythonError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "birdtradebot/__main__.py", line 4, in <module>
    go()
  File "birdtradebot/__init__.py", line 1018, in go
    trader.run()
  File "birdtradebot/__init__.py", line 616, in run
    self._run()
  File "birdtradebot/__init__.py", line 287, in _run
    ids_map = twitter_handles_to_userids(self.twitter, self.handles)
  File "birdtradebot/__init__.py", line 197, in twitter_handles_to_userids
    if 'User not found' in e.message:
AttributeError: 'TwythonError' object has no attribute 'message'
poupas commented 6 years ago

Indeed it did. There was an error handling the exception before our (new) code had the chance to handle it. It should be fixed now.