UpstreamData / pyasic

A simplified and standardized interface for Bitcoin ASICs.
https://docs.pyasic.org
Apache License 2.0
97 stars 51 forks source link

Bos miner.web.grpc.get_pool_groups() return OSError: [WinError 121] #103

Closed Sam-SHanshin closed 1 month ago

Sam-SHanshin commented 8 months ago

Describe the bug When i try get miner's pools status by miner.api.pools() i got empty dict then i try to use miner.web.grpc.get_pool_groups() i got OSError: [WinError 121]

Screenshots Traceback (most recent call last):

    x = await controle_object.web.grpc.get_pool_groups()
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\Оксана\Desktop\Sam\venv\Lib\site-packages\pyasic\web\bosminer\__init__.py", line 525, in get_pool_groups
    return await self.send_command("get_pool_groups", GetPoolGroupsRequest())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\Оксана\Desktop\Sam\venv\Lib\site-packages\pyasic\web\bosminer\__init__.py", line 319, in send_command
    metadata.append(("authorization", await self.auth()))
                                      ^^^^^^^^^^^^^^^^^
  File "c:\Users\Оксана\Desktop\Sam\venv\Lib\site-packages\pyasic\web\bosminer\__init__.py", line 333, in auth
    await self._get_auth()
  File "c:\Users\Оксана\Desktop\Sam\venv\Lib\site-packages\pyasic\web\bosminer\__init__.py", line 345, in _get_auth
    await stream.send_message(req, end=True)
  File "c:\Users\Оксана\Desktop\Sam\venv\Lib\site-packages\grpclib\client.py", line 241, in send_message
    await self.send_request()
  File "c:\Users\Оксана\Desktop\Sam\venv\Lib\site-packages\grpclib\client.py", line 173, in send_request
    protocol = await self._channel.__connect__()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\Оксана\Desktop\Sam\venv\Lib\site-packages\grpclib\client.py", line 748, in __connect__
    self._protocol = await self._create_connection()
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\Users\Оксана\Desktop\Sam\venv\Lib\site-packages\grpclib\client.py", line 725, in _create_connection
    _, protocol = await self._loop.create_connection(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Оксана\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 1085, in create_connection
    raise exceptions[0]
  File "C:\Users\Оксана\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 1069, in create_connection
    sock = await self._connect_sock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Оксана\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 973, in _connect_sock
    await self.sock_connect(sock, address)
  File "C:\Users\Оксана\AppData\Local\Programs\Python\Python311\Lib\asyncio\proactor_events.py", line 726, in sock_connect
    return await self._proactor.connect(sock, address)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Оксана\AppData\Local\Programs\Python\Python311\Lib\asyncio\windows_events.py", line 846, in _poll
    value = callback(transferred, key, ov)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Оксана\AppData\Local\Programs\Python\Python311\Lib\asyncio\windows_events.py", line 633, in finish_connect
    ov.getresult()
OSError: [WinError 121]

Desktop (please complete the following information):

Miner Information (If applicable):

Additional context i use pyasic 0.46.0

b-rowan commented 8 months ago

OSError 121 is refused connection, you have to update your miner to the latest version, since older versions don't have gRPC support.

I would also recommend updating pyasic to the latest version, as that will fix some other bugs.

b-rowan commented 8 months ago

Also, on recent versions, it will become miner.web instead of miner.web.grpc, but I would recommend using get_config instead if you just intend to get config information.

Sam-SHanshin commented 8 months ago

What are BOSerWebAPI and BOSMinerRPCAPI? I mean that why do you need to create two classes for Bos?

Sam-SHanshin commented 8 months ago

I see that use get_config is good practic, but i need to get pools status (Are they Alive or Dead?) get_config give me pools parameters but not statuses

b-rowan commented 8 months ago

Regarding your first question; The reason for 2 BOS+ classes is that they dropped support for S9 (and technically X17) prior to implementing gRPC, so in order to maintain compatibility in a simple way with S9s, I split the classes out into something for S9 and something for newer models. This is slightly buggy with X17 models, because they are updatable to new versions but have tuner issues, so it's troublesome to decide between implementations there.

Regarding active pool status, yes, that's the correct way to do that then. I've considered trying to add that to miner data, but it seems complicated to structure that in a useful way, and it's not something I would want to put into miner config...

b-rowan commented 3 months ago

I see that use get_config is good practic, but i need to get pools status (Are they Alive or Dead?) get_config give me pools parameters but not statuses

Getting this added into miner data, some miners already have it, and more are getting it soon.

b-rowan commented 1 month ago

This should be fixed in latest, give it a test and let me know if you still have issues.