Comments (7)
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.
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.
Yeah, I don't really know how to fix this one... I've searched on google and stack overflow
I don't know if disablingAPI enforces sslverify_ssl
is safe if that makes sensecould tryThis requires disabling sslsocket.AF_INET
that but that breaks it for some network settings.- 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.
@milan252525 Maybe check your network settings/wifi? I can't seem to replicate your issue.
from brawlstats.
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.
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.
@MuhammadShafeeq this is not the same issue, this is a duplicate of issue #78
from brawlstats.
Related Issues (20)
- Errors occur when upgrading from version 4.0.0 to 4.0.1 HOT 5
- Asyncio Lock is not awaited HOT 2
- Problem with installation HOT 15
- I have an issue with the client = brawlstats.Client(token='example_my_token') code HOT 5
- no access to general brawler information HOT 3
- can't get Chinese server data HOT 2
- Surge is invalid brawler HOT 2
- unnecessary print of brawlers HOT 1
- Every brawler in the rankings is now invalid HOT 4
- power play HOT 2
- AttributeError: __enter__ HOT 3
- x3vs3_victories vs team_victories HOT 3
- Remove generator of ips HOT 1
- Brawler Gadgets HOT 1
- How to know Highest Solo Power League or smth like that?
- [Suggestion] Pin requirement versions (specifically python-box)
- How to check is correct brawle profile teg or not? HOT 2
- Invalid authorization: API key does not allow access from IP HOT 1
- not available in brawl stats HOT 1
- trying to get the player icon url HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from brawlstats.