Giter Club home page Giter Club logo

Comments (7)

SharpBit avatar SharpBit commented on May 30, 2024

Can you type in terminal pip show aiohttp and tell me the version? Could be something to do with the version discord.py that you're using uses.

Update: Try updating the wrapper using pip install -U brawlstats and see if it works

from brawlstats.

milan252525 avatar milan252525 commented on May 30, 2024

image

Wrapper updated, identical error:

aiohttp.errors.ClientOSError: [Errno 101] Cannot connect to host brawlapi.cf:443 ssl:True [Can not connect to brawlapi.cf:443 [Network is unreachable]]
[01/03/2019 17:02] ERROR red on_command_error 369: Exception in command 'club'
Traceback (most recent call last):
  File "lib/aiohttp/connector.py", line 601, in _create_direct_connection
    local_addr=self._local_addr)
  File "/usr/lib/python3.5/asyncio/base_events.py", line 695, in create_connection
    raise exceptions[0]
  File "/usr/lib/python3.5/asyncio/base_events.py", line 682, in create_connection
    yield from self.sock_connect(sock, address)
  File "/usr/lib/python3.5/asyncio/selector_events.py", line 402, in sock_connect
    return (yield from fut)
  File "/usr/lib/python3.5/asyncio/futures.py", line 363, in __iter__
    return self.result()  # May raise too.
  File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
    raise self._exception
  File "/usr/lib/python3.5/asyncio/selector_events.py", line 407, in _sock_connect
    sock.connect(address)
OSError: [Errno 101] Network is unreachable

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

Traceback (most recent call last):
  File "lib/aiohttp/connector.py", line 304, in connect
    yield from self._create_connection(req)
  File "lib/aiohttp/connector.py", line 578, in _create_connection
    transport, proto = yield from self._create_direct_connection(req)
  File "lib/aiohttp/connector.py", line 624, in _create_direct_connection
    (req.host, req.port, exc.strerror)) from exc
aiohttp.errors.ClientOSError: [Errno 101] Can not connect to brawlapi.cf:443 [Network is unreachable]

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

Traceback (most recent call last):
  File "lib/discord/ext/commands/core.py", line 50, in wrapped
    ret = yield from coro(*args, **kwargs)
  File "/home/newbot/labot/Red-DiscordBot/cogs/labs.py", line 25, in club
    club1 = await self.bs.get_club("V9GRP2C")
  File "/home/newbot/.local/lib/python3.5/site-packages/brawlstats/core.py", line 96, in _aget_model
  File "/home/newbot/.local/lib/python3.5/site-packages/brawlstats/core.py", line 83, in _arequest
    raise ServerError(url, code)
  File "lib/aiohttp/client.py", line 565, in __aenter__
    self._resp = yield from self._coro
  File "lib/aiohttp/client.py", line 198, in _request
    conn = yield from self._connector.connect(req)
  File "lib/aiohttp/connector.py", line 314, in connect
    .format(key, exc.strerror)) from exc
aiohttp.errors.ClientOSError: [Errno 101] Cannot connect to host brawlapi.cf:443 ssl:True [Can not connect to brawlapi.cf:443 [Network is unreachable]]

from brawlstats.

SharpBit avatar SharpBit commented on May 30, 2024

Yeah, I don't really know how to fix this one... I've searched on google and stack overflow

  • I don't know if disabling verify_ssl is safe if that makes sense API enforces ssl
  • could try socket.AF_INET that but that breaks it for some network settings. This requires disabling ssl
  • Setting limit to 1 also would make the request synchronous.

Reference: aio-libs/aiohttp#2522

IF ANYONE KNOWS HOW TO FIX THIS, PLEASE SUBMIT A PULL REQUEST. REFER TO CONTRIBUTING.MD

from brawlstats.

SharpBit avatar SharpBit commented on May 30, 2024

@milan252525 Maybe check your network settings/wifi? I can't seem to replicate your issue.

from brawlstats.

SharpBit avatar SharpBit commented on May 30, 2024

Fixed in v2.3.2 or 61a8308

To resolve the issue, pass in aiohttp.TCPConnector(use_dns_cache=False) into the client like such:

connector = aiohttp.TCPConnector(use_dns_cache=False)
client = brawlstats.Client(token, is_async=True, connector=connector)

OR if you want to use your own session:

connector = aiohttp.TCPConnector(use_dns_cache=False)
session = aiohttp.ClientSession(connector=connector)
client = brawlstats.Client(token, is_async=True, session=session)

from brawlstats.

MuhammadShafeeq avatar MuhammadShafeeq commented on May 30, 2024

Bug:

It works in my pc but not in repl

  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: __enter__
Ignoring exception in command profile:
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "main.py", line 70, in profile
    profile_info = secondary.get_info(tag)
  File "/home/runner/BrawlStarsBot/secondary.py", line 12, in get_info
    bs = brawlstats.Client(TOKEN, connector=connector)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/brawlstats/core.py", line 76, in __init__
    brawlers_info = self.get_brawlers()
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/brawlstats/core.py", line 382, in get_brawlers
    return self._get_model(self.api.BRAWLERS, model=Brawlers)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/brawlstats/core.py", line 197, in _get_model
    data = self._request(url, use_cache)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/brawlstats/core.py", line 162, in _request
    with self.session.get(url, timeout=self.timeout, headers=self.headers) as resp:
AttributeError: __enter__

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

Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: __enter__

Code:

def get_info(tag):
    connector = aiohttp.TCPConnector(use_dns_cache=False)
    bs = brawlstats.Client(TOKEN, connector=connector)
    player = bs.get_player(f"{tag}")
    return player

from brawlstats.

SharpBit avatar SharpBit commented on May 30, 2024

@MuhammadShafeeq this is not the same issue, this is a duplicate of issue #78

from brawlstats.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.