ValvePython / steam

☁️ Python package for interacting with Steam
http://steam.readthedocs.io
MIT License
1.1k stars 137 forks source link

Anonymous login failing to connect with CM servers #279

Closed ericwoolard closed 4 years ago

ericwoolard commented 4 years ago

I have a pretty simple bot that uses SteamClient to login anonymously and make a call to get_product_info(), and recently noticed that my attempts at an anonymous login have started to fail once attempting to establish a connection to any of the bootstrapped CM servers. Have had no issues for over a year until now, and can't seem to figure out what's going on.

Logging just shows

15260 Bootstraping from builtin list
15260 Added 30 new CM addresses.
15260 Attempting Anonymous login
15260 Connect initiated.
15260 Attempting connection to ('208.78.164.12', 27017)
15260 Failed to connect. Retrying...

and continues to try additional CM servers, but fails on each.

rossengeorgiev commented 4 years ago

Sound like you are on steam v0.9. Either update, or use set_credential_location() to maintain an up to date list of CMs.

ericwoolard commented 4 years ago

Sound like you are on steam v0.9. Either update, or use set_credential_location() to maintain an up to date list of CMs.

Updating did the trick. Thanks!

As an extra note, I ran into several protobuf related errors after updating to 1.0.2, but lowering my protobuf version to 3.6.0 fixed those issues.

ericwoolard commented 4 years ago

Well, it's working locally, however I'm still running into issues on a server running Ubuntu 14.04. Output just repeatedly spits out

28544 WebAPI boostrap failed: __init__() takes at most 1 positional argument (2 given)
28544 DNS boostrap failed: __init__() takes at most 1 positional argument (2 given)

until I kill the script.

I'm not passing anything to SteamClient() or directly modifying or instantiating CMClient nor CMServerList. The only calls I'm making with SteamClient are client.anonymous_login() and client.get_product_info(apps=[730], timeout=15).

I've made sure steam is v1.0.2 on both systems, and even put all dependencies on the same versions yet still have this issue on the Ubuntu server.

Any ideas what could be causing this?

rossengeorgiev commented 4 years ago

Very strange. What version of python are using?

Log message suggests it is failing here:

https://github.com/ValvePython/steam/blob/92c5107c7c300d55d37d9e681de8394d78fca841/steam/core/cm.py#L462 https://github.com/ValvePython/steam/blob/92c5107c7c300d55d37d9e681de8394d78fca841/steam/core/cm.py#L491

You can edit your local file and add:

self._LOG.exception(exp)

Re-run the script, and now there should be full stacktrace printed out when the error occures, which should have enough info to debug this further

ericwoolard commented 4 years ago

I'm running Python 3.5 on the server. This is what I've got for bootstrap_from_webapi():

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/steam/core/cm.py", line 490, in bootstrap_from_webapi
    'http_timeout': 3})
  File "/usr/local/lib/python3.5/dist-packages/steam/webapi.py", line 468, in get
    return webapi_request(url, 'GET', caller=caller, session=session, params=params)
  File "/usr/local/lib/python3.5/dist-packages/steam/webapi.py", line 426, in webapi_request
    resp = f(url, stream=False, timeout=onetime['http_timeout'], **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/requests/sessions.py", line 543, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/requests/sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.5/dist-packages/requests/sessions.py", line 643, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/usr/local/lib/python3.5/dist-packages/urllib3/connectionpool.py", line 677, in urlopen
    chunked=chunked,
  File "/usr/local/lib/python3.5/dist-packages/urllib3/connectionpool.py", line 381, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.5/dist-packages/urllib3/connectionpool.py", line 978, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.5/dist-packages/urllib3/connection.py", line 309, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.5/dist-packages/urllib3/connection.py", line 160, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw
  File "/usr/local/lib/python3.5/dist-packages/urllib3/util/connection.py", line 61, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/local/lib/python3.5/dist-packages/gevent/_socketcommon.py", line 230, in getaddrinfo
    addrlist = get_hub().resolver.getaddrinfo(host, port, family, type, proto, flags)
  File "/usr/local/lib/python3.5/dist-packages/gevent/hub.py", line 830, in _get_resolver
    self._resolver = self.resolver_class(hub=self) # pylint:disable=not-callable
  File "/usr/local/lib/python3.5/dist-packages/gevent/resolver/thread.py", line 39, in __init__
    self.pool = hub.threadpool
  File "/usr/local/lib/python3.5/dist-packages/gevent/hub.py", line 854, in _get_threadpool
    self._threadpool = self.threadpool_class(self.threadpool_size, hub=self)
  File "/usr/local/lib/python3.5/dist-packages/gevent/threadpool.py", line 284, in __init__
    self._available_worker_threads_greenlet_sem = Semaphore(1, hub)
  File "src/gevent/_semaphore.py", line 29, in gevent._semaphore.Semaphore.__init__ (src/gevent/gevent._semaphore.c:1327            )
TypeError: __init__() takes at most 1 positional argument (2 given)

and for bootstrap_from_dns():

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/steam/core/cm.py", line 460, in bootstrap_from_dns
    proto=socket.IPPROTO_TCP)
  File "/usr/local/lib/python3.5/dist-packages/gevent/_socketcommon.py", line 230, in getaddrinfo
    addrlist = get_hub().resolver.getaddrinfo(host, port, family, type, proto, flags)
  File "/usr/local/lib/python3.5/dist-packages/gevent/hub.py", line 830, in _get_resolver
    self._resolver = self.resolver_class(hub=self) # pylint:disable=not-callable
  File "/usr/local/lib/python3.5/dist-packages/gevent/resolver/thread.py", line 39, in __init__
    self.pool = hub.threadpool
  File "/usr/local/lib/python3.5/dist-packages/gevent/hub.py", line 854, in _get_threadpool
    self._threadpool = self.threadpool_class(self.threadpool_size, hub=self)
  File "/usr/local/lib/python3.5/dist-packages/gevent/threadpool.py", line 284, in __init__
    self._available_worker_threads_greenlet_sem = Semaphore(1, hub)
  File "src/gevent/_semaphore.py", line 29, in gevent._semaphore.Semaphore.__init__ (src/gevent/gevent._semaphore.c:1327            )
TypeError: __init__() takes at most 1 positional argument (2 given)

Seems it may be related to gevent? Like I said previously, in my troubleshooting I put all dependencies including gevent on the same version as my local test env, so I'm not really sure what would be the issue unless there's a component of gevent that I missed.

rossengeorgiev commented 4 years ago

Looks like bug in gevent, try different version. Also, update your ubuntu. 14 LTS is old, and since April is end of life.

ericwoolard commented 4 years ago

Upgrading ubuntu has been on the list for a while but unfortunately isn't feasible atm. Rolling back gevent to v1.4.0 and greenlet to v0.4.15 got everything working again. Thanks for your help!