Tinkoff / invest-python

Tinkoff Invest Python gRPC client
https://tinkoff.github.io/invest-python/
Apache License 2.0
301 stars 87 forks source link

[Bug] failed to connect to all addresses; last error: UNAVAILABLE: ipv4:91.194.227.80:443: recvmsg:Connection reset by peer #232

Closed Che4ako closed 1 year ago

Che4ako commented 1 year ago

Что случилось?

Два дня подряд возникает ошибка "failed to connect to all addresses; last error: UNAVAILABLE". До этого такой проблемы никогда не возникало. Возникает во всех методах (например, client.instruments.shares()). Периодически проблема исчезает и подключиться удается, через несколько минут снова "UNAVAILABLE failed to connect to all addresses".

В чем может быть проблема?

Воспроизведение

import asyncio
import os

from tinkoff.invest import AsyncClient

async def main():
    async with AsyncClient(TOKEN) as client:
        print(await client.users.get_accounts())

if __name__ == "__main__":
    asyncio.run(main())

Tinkoff Invest Version

0.2.0-beta57

Python Version

3.10

OS

Linux

Логи

None GetAccounts UNAVAILABLE failed to connect to all addresses; last error: UNAVAILABLE: ipv4:91.194.227.80:443: recvmsg:Connection reset by peer
Traceback (most recent call last):
  File "/home/venv/lib/python3.10/site-packages/tinkoff/invest/_errors.py", line 85, in wrapper
    return await func(*args, **kwargs)
  File "/home/venv/lib/python3.10/site-packages/tinkoff/invest/async_services.py", line 1260, in get_accounts
    response = await response_coro
  File "/home/venv/lib/python3.10/site-packages/grpc/aio/_call.py", line 290, in __await__
    raise _create_rpc_error(self._cython_call._initial_metadata,
grpc.aio._call.AioRpcError: <AioRpcError of RPC that terminated with:
    status = StatusCode.UNAVAILABLE
    details = "failed to connect to all addresses; last error: UNAVAILABLE: ipv4:91.194.227.80:443: recvmsg:Connection reset by peer"
    debug_error_string = "UNKNOWN:failed to connect to all addresses; last error: UNAVAILABLE: ipv4:91.194.227.80:443: recvmsg:Connection reset by peer {created_time:"2023-05-26T11:14:16.321370976+03:00", grpc_status:14}"
>

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/test_tinkoff_async_client.py", line 15, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/home/test_tinkoff_async_client.py", line 11, in main
    print(await client.users.get_accounts())
  File "/home/venv/lib/python3.10/site-packages/tinkoff/invest/_errors.py", line 100, in wrapper
    raise AioRequestError(status_code, details, metadata) from e
tinkoff.invest.exceptions.AioRequestError: (<StatusCode.UNAVAILABLE: (14, 'unavailable')>, 'failed to connect to all addresses; last error: UNAVAILABLE: ipv4:91.194.227.80:443: recvmsg:Connection reset by peer', None)
Che4ako commented 1 year ago

ошибка дополнилась сообщением "envoy overloaded"

grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with: status = StatusCode.UNAVAILABLE details = "envoy overloaded" debug_error_string = "UNKNOWN:Error received from peer {created_time:"2023-05-31T10:53:27.174714314+03:00", grpc_status:14, grpc_message:"envoy overloaded"}"

AlexanderVolkovTCS commented 1 year ago

Добрый день!

UNAVAILABLE failed to connect to all addresses; last error: UNAVAILABLE: ipv4:91.194.227.80:443

эта ошибка означает сетевую недоступность сервиса. Примерно в это время был инцидент с системой защиты от ddos

"envoy overloaded"

эта проблема решена на прошлой неделе.

TOKEN = 't.-G6YjzdzpcRYtkoziP5HKndGtcxae1GvEX4p1gbCUWZ12nZZyxwuTfr53Z6uvvRFHDKc4MEkhBsotnjIXVkQEg'

не надо токен указывать публично. Рекомендую отозвать его и создать новый