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

[BUG] Timeout when requesting get_product_info #474

Open
denizkoekden opened this issue Oct 11, 2024 · 13 comments
Open

[BUG] Timeout when requesting get_product_info #474

denizkoekden opened this issue Oct 11, 2024 · 13 comments

Comments

@denizkoekden
Copy link

Description
When I try "client.get_product_info(apps=[app_id], timeout=1)" I get an timeout. Of course before I initialize and login the Client and login anonymously with

client = SteamClient()
client.anonymous_login()

then I print(client) I get:
<SteamClient(('155.133.226.75', 27028)) offline>
So it seems like the SteamClient is offline?

Steps to Reproduce the behavior
Run:
app_id = 570
client = SteamClient()
client.anonymous_login()
info = client.get_product_info(apps=[app_id], timeout=1)
print (info)

Expected behavior
I expect informations about the provided App ID but since tonight I only get an timeout back
Screenshots
image
Versions Report

python -m steam.versions_report
steam: 1.4.4

Dependencies:
                 vdf: 3.4
            protobuf: 3.20.3
            requests: 2.31.0
          cachetools: 5.3.2
              gevent: 24.10.2
 gevent-eventemitter: 2.1
       pycryptodomex: 3.21.0
              enum34: Not Installed
       win-inet-pton: Not Installed

Python runtime:
          executable: C:\Python312\python.exe
             version: 3.12.1 (tags/v3.12.1:2305ca5, Dec  7 2023, 22:03:25) [MSC v.1937 64 bit (AMD64)]
            platform: win32

System info:
              system: Windows
             machine: AMD64
             release: 11
             version: 10.0.22631```
</details>
@denizkoekden denizkoekden changed the title [BUG] [BUG] Timeout when requesting get_product_info Oct 11, 2024
@Sericck
Copy link

Sericck commented Oct 11, 2024

Hello, I have a similar problem, can't auth in steam using client.cli_login() or client.cli_login(). I add print(eresult) after self._pre_login() in "client/init.py/def login" and pre_login always returns EResult.TryAnotherCM.
Why, I don't know

@revij
Copy link

revij commented Oct 12, 2024

Fighting with the same issue and while it doesn't seem easy to troubleshoot why the TCP connection is dropped, I've had better success with the websocket implementation suggested on PR #469 - not as perfect as some servers don't seem to communicate correctly for some reason..

https://gist.github.com/revij/da3a8ae03de673caf68ec1cfe79b5654

@BlankTMing
Copy link

Fighting with the same issue and while it doesn't seem easy to troubleshoot why the TCP connection is dropped, I've had better success with the websocket implementation suggested on PR #469 - not as perfect as some servers don't seem to communicate correctly for some reason..

https://gist.github.com/revij/da3a8ae03de673caf68ec1cfe79b5654

I use the login() function in CMClient.PROTOCOL_WEBSOCKET way, and your code is still problematic, but using anonymous_login() is normal

@denizkoekden
Copy link
Author

Okay

Fighting with the same issue and while it doesn't seem easy to troubleshoot why the TCP connection is dropped, I've had better success with the websocket implementation suggested on PR #469 - not as perfect as some servers don't seem to communicate correctly for some reason..

https://gist.github.com/revij/da3a8ae03de673caf68ec1cfe79b5654

This is actually working in my test enviroment. I uninstalled the steam library (pip remove steam), then I installed the steam library from the PR (pip install https://github.com/njbooher/steam/archive/wsproto.zip) and then I added the following to the Code:

Import the following:
from steam.core.connection import WebsocketConnection

Then add:

client.connection = WebsocketConnection()

after

client = SteamClient()

and then its working.

@BlankTMing
Copy link

get_product_info(apps=[app_id], timeout=1)

Trying to get multiple apps with get_product_info will have problems

@revij
Copy link

revij commented Oct 12, 2024

Okay

Fighting with the same issue and while it doesn't seem easy to troubleshoot why the TCP connection is dropped, I've had better success with the websocket implementation suggested on PR #469 - not as perfect as some servers don't seem to communicate correctly for some reason..
https://gist.github.com/revij/da3a8ae03de673caf68ec1cfe79b5654

This is actually working in my test enviroment. I uninstalled the steam library (pip remove steam), then I installed the steam library from the PR (pip install https://github.com/njbooher/steam/archive/wsproto.zip) and then I added the following to the Code:

Import the following: from steam.core.connection import WebsocketConnection

Then add:

client.connection = WebsocketConnection()

after

client = SteamClient()

and then its working.

While it seems to work with some websocket servers, I had trouble with the ones located in fra1/fra2/ams/vie1 but the ones in par1/sto1/sto2/waw1 work just fine.
Connections to the "broken" sites also reach to the "ClientPICSProductInfoRequest" point but then seem to receive a "Try another CM" response as well.

@denizkoekden
Copy link
Author

denizkoekden commented Oct 12, 2024

Okay. I just tried it from multiple Servers I run in germany and they all can connect to Steam Servers reliable.

<SteamClient(('cmp1-fra1.steamserver.net', 27019)) online>

@BlankTMing
Copy link

BlankTMing commented Oct 13, 2024

OK, I fixed it, he still uses TCP

def bootstrap_from_webapi(self, cell_id=0):
       
        from steam import webapi
        try:
            resp = webapi.get('ISteamDirectory', 'GetCMListForConnect', 1, params={'cmtype': 'netfilter',
                                                                         'http_timeout': 3})
        except Exception as exp:
            self._LOG.error("WebAPI boostrap failed: %s" % str(exp))
            return False

        result = EResult(resp['response']['success'])

        if result != EResult.OK:
            self._LOG.error("GetCMList failed with %s" % repr(result))
            return False

        serverlist = resp['response']['serverlist']
        self._LOG.debug("Received %d servers from WebAPI" % len(serverlist))

        def str_to_tuple(serveraddr):
            ip, port = serveraddr['endpoint'].split(':')
            return str(ip), int(port)

        self.clear()
        self.cell_id = cell_id
        self.merge_list(map(str_to_tuple, serverlist))

        return True

@denizkoekden
Copy link
Author

Alright, I had a feeling the implementation from the PR wasn’t perfect as it might be a first draft, but it’s still an improvement over the previous state where nothing worked at all. Can we gather the issues we’ve found and revise the PR? I also noticed that @revij made a few adjustments in his fork. Overall, improving this would benefit many Steam projects. If I find the time them I’ll dive deeper into the code and the topic next week to see what’s still missing and not working.

detiam added a commit to detiam/steam_websocket that referenced this issue Oct 13, 2024
detiam added a commit to detiam/steam_websocket that referenced this issue Oct 13, 2024
detiam added a commit to detiam/steam_websocket that referenced this issue Oct 14, 2024
detiam added a commit to detiam/steam_websocket that referenced this issue Oct 14, 2024
@max-pfeiffer
Copy link

Plus one here:

client.anonymous_login()
<EResult.TryAnotherCM: 48>

And:

info: dict = client.get_product_info(apps=[258550], timeout=1)
Traceback (most recent call last):
  File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevconsole.py", line 364, in runcode
    coro = func()
           ^^^^^^
  File "<input>", line 1, in <module>
  File "/Users/maxpfeiffer/repos/rust-game-server-docker/.venv/lib/python3.11/site-packages/steam/client/builtins/apps.py", line 139, in get_product_info
    chunk = self.wait_event(job_id, timeout=timeout, raises=True)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/maxpfeiffer/repos/rust-game-server-docker/.venv/lib/python3.11/site-packages/eventemitter/__init__.py", line 119, in wait_event
    return result.get(True, timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "src/gevent/event.py", line 329, in gevent._gevent_cevent.AsyncResult.get
  File "src/gevent/event.py", line 356, in gevent._gevent_cevent.AsyncResult.get
  File "src/gevent/_abstract_linkable.py", line 487, in gevent._gevent_c_abstract_linkable.AbstractLinkable._wait_core
  File "src/gevent/_abstract_linkable.py", line 490, in gevent._gevent_c_abstract_linkable.AbstractLinkable._wait_core
  File "src/gevent/_abstract_linkable.py", line 442, in gevent._gevent_c_abstract_linkable.AbstractLinkable._AbstractLinkable__wait_to_be_notified
  File "src/gevent/_abstract_linkable.py", line 451, in gevent._gevent_c_abstract_linkable.AbstractLinkable._switch_to_hub
  File "src/gevent/_greenlet_primitives.py", line 61, in gevent._gevent_c_greenlet_primitives.SwitchOutGreenletWithLoop.switch
  File "src/gevent/_greenlet_primitives.py", line 65, in gevent._gevent_c_greenlet_primitives.SwitchOutGreenletWithLoop.switch
  File "src/gevent/_gevent_c_greenlet_primitives.pxd", line 35, in gevent._gevent_c_greenlet_primitives._greenlet_switch
gevent.timeout.Timeout: 1 second

@MABBTT
Copy link

MABBTT commented Oct 16, 2024

OK, I fixed it, he still uses TCP

def bootstrap_from_webapi(self, cell_id=0):
       
        from steam import webapi
        try:
            resp = webapi.get('ISteamDirectory', 'GetCMListForConnect', 1, params={'cmtype': 'netfilter',
                                                                         'http_timeout': 3})
        except Exception as exp:
            self._LOG.error("WebAPI boostrap failed: %s" % str(exp))
            return False

        result = EResult(resp['response']['success'])

        if result != EResult.OK:
            self._LOG.error("GetCMList failed with %s" % repr(result))
            return False

        serverlist = resp['response']['serverlist']
        self._LOG.debug("Received %d servers from WebAPI" % len(serverlist))

        def str_to_tuple(serveraddr):
            ip, port = serveraddr['endpoint'].split(':')
            return str(ip), int(port)

        self.clear()
        self.cell_id = cell_id
        self.merge_list(map(str_to_tuple, serverlist))

        return True

This is working well for me. No observed errors using this approach instead of the websocket method.

@max-pfeiffer
Copy link

max-pfeiffer commented Oct 20, 2024

I switched to detiam's fork, where he implemented the fix: https://github.com/detiam/steam_websocket

My Poetry config:

steam = {git = "https://github.com/detiam/steam_websocket.git", branch = "master", extras=["client"]}

@detiam Thanks a lot for fixing the issue!

detiam added a commit to detiam/steam_websocket that referenced this issue Oct 22, 2024
@kurokobo
Copy link

kurokobo commented Oct 23, 2024

It seems that the issue on Steam's side has been resolved, as the code that stopped working few weeks ago is now functioning again 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants