billy-yoyo / RainbowSixSiege-Python-API

Asynchronous python api for rainbow six siege (r6sapi)
MIT License
129 stars 31 forks source link

Failed to connect #9

Closed LaughOutQuiet closed 6 years ago

LaughOutQuiet commented 6 years ago

Traceback (most recent call last):
  File "C:\Users\Matthew\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 50, in wrapped
    ret = yield from coro(*args, **kwargs)
  File "C:\Users\Matthew\Desktop\Projects\Python\Discord\Bots\Series\Laugh (All in one)\CogStats.py", line 66, in r6
    player = await auth.get_player(user, api.Platforms.UPLAY)
  File "C:\Users\Matthew\AppData\Local\Programs\Python\Python36-32\lib\site-packages\r6sapi\r6sapi.py", line 522, in get_player
    results = yield from self.get_players(name=name, platform=platform, uid=uid)
  File "C:\Users\Matthew\AppData\Local\Programs\Python\Python36-32\lib\site-packages\r6sapi\r6sapi.py", line 488, in get_players
    data = yield from self.get("https://public-ubiservices.ubi.com/v2/profiles?nameOnPlatform=%s&platformType=%s" % (parse.quote(name), parse.quote(platform)))
  File "C:\Users\Matthew\AppData\Local\Programs\Python\Python36-32\lib\site-packages\r6sapi\r6sapi.py", line 394, in get
    raise FailedToConnect
r6sapi.r6sapi.FailedToConnect

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

Traceback (most recent call last):
  File "C:\Users\Matthew\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\bot.py", line 846, in process_commands
    yield from command.invoke(ctx)
  File "C:\Users\Matthew\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 374, in invoke
    yield from injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\Matthew\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 54, in wrapped
    raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: FailedToConnect: 
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x06962970>```

I get this error when i run my command? any idea on whats wrong and how to fix?
NG-Bullseye commented 6 years ago

Same problem here

Traceback (most recent call last): File "C:/Users/leona/OneDrive/Programme/Telegram-Bot-master/tele_news.py", line 15, in asyncio.get_event_loop().run_until_complete(run()) File "C:\Users\leona\AppData\Local\Programs\Python\Python36\lib\asyncio\base_events.py", line 468, in run_until_complete return future.result() File "C:/Users/leona/OneDrive/Programme/Telegram-Bot-master/tele_news.py", line 9, in run player = yield from auth.get_player("NG-Loki", api.Platforms.UPLAY) File "C:\Users\leona\AppData\Local\Programs\Python\Python36\lib\site-packages\r6sapi\r6sapi.py", line 522, in get_player results = yield from self.get_players(name=name, platform=platform, uid=uid) File "C:\Users\leona\AppData\Local\Programs\Python\Python36\lib\site-packages\r6sapi\r6sapi.py", line 488, in get_players data = yield from self.get("https://public-ubiservices.ubi.com/v2/profiles?nameOnPlatform=%s&platformType=%s" % (parse.quote(name), parse.quote(platform))) File "C:\Users\leona\AppData\Local\Programs\Python\Python36\lib\site-packages\r6sapi\r6sapi.py", line 394, in get raise FailedToConnect r6sapi.r6sapi.FailedToConnect Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x0000013C2DADE710>

Pls Help

billy-yoyo commented 6 years ago

I'll look in to this asap, sorry for the slow reply.

NG-Bullseye commented 6 years ago

I only get that exception when I call billy-yoyo's example program from a different class. If I run the script by itself it works.

billy-yoyo commented 6 years ago

Three things that might be wrong:

Is the error happening every time, or does it sometimes work? The last one is unlikely, unless you've been spamming requests a lot.

LaughOutQuiet commented 6 years ago

@billy-yoyo It has not been happening very often and it tends to happen after i use a few commands in a shorter time period, over 3 minutes i used 10 commands and i got the error after i successfully executed the 10 commands, sorry for responding late, I don't usually check github (kinda forgot I had it) but i will implement the max_connect_retries

EDIT: I've tried to implement the max_connect_retries and it does not seem to be working, could you provide an example for me so I can see if I'm doing something wrong?

EDIT 2:

I believe that the reason max_connect_retries is not working is because of the following:

Now I'm getting this error and I don't know what the source is:


Ignoring exception in command r6 operator
Traceback (most recent call last):
  File "C:\Users\Matthew\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 50, in wrapped
    ret = yield from coro(*args, **kwargs)
  File "C:\Users\Matthew\Desktop\Projects\Python\Discord\Bots\Series\Laugh (All in one)\cogs\stats.py", line 277, in _operator
    p = await self.get_player(player, platform)
  File "C:\Users\Matthew\Desktop\Projects\Python\Discord\Bots\Series\Laugh (All in one)\cogs\stats.py", line 90, in get_player
    p = await r6sapi.Auth(email=(config["stats"]["email"]),password=(config["stats"]["password"])).get_player(player, plat)
KeyError: 'stats'

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

Traceback (most recent call last):
  File "C:\Users\Matthew\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\bot.py", line 846, in process_commands
    yield from command.invoke(ctx)
  File "C:\Users\Matthew\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 634, in invoke
    yield from ctx.invoked_subcommand.invoke(ctx)
  File "C:\Users\Matthew\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 374, in invoke
    yield from injected(*ctx.args, **ctx.kwargs)
  File "C:\Users\Matthew\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\ext\commands\core.py", line 54, in wrapped
    raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: KeyError: 'stats'

EDIT AGAIN:
sorry i just found the cause of my autism, i renamed a config and forgot to change it in the code ;-;

really sorry about that i tried your fix and it worked my man.
billy-yoyo commented 6 years ago

Closing as the issue was fixed, will consider adding better error reporting later so it's more obvious why you're failing to connect, if possible.