前提・実現したいこと
Discord.pyでRythm的なシステムを作っています。
初期化処理中に以下のエラーメッセージが発生しました。
発生している問題・エラーメッセージ
Logged in as [ボット名] | [クライアントID] WEBSOCKET | Connection Failure:: Cannot connect to host x.x.x.x:2333 ssl:default [リモート コンピューターによりネットワーク接続が拒否されました。] Traceback (most recent call last): File "C:\develop\python\lib\site-packages\aiohttp\connector.py", line 936, in _wrap_create_connection return await self._loop.create_connection(*args, **kwargs) # type: ignore # noqa File "C:\develop\python\lib\asyncio\base_events.py", line 1025, in create_connection raise exceptions[0] File "C:\develop\python\lib\asyncio\base_events.py", line 1010, in create_connection sock = await self._connect_sock( File "C:\develop\python\lib\asyncio\base_events.py", line 924, in _connect_sock await self.sock_connect(sock, address) File "C:\develop\python\lib\asyncio\proactor_events.py", line 702, in sock_connect return await self._proactor.connect(sock, address) File "C:\develop\python\lib\asyncio\windows_events.py", line 808, in _poll value = callback(transferred, key, ov) File "C:\develop\python\lib\asyncio\windows_events.py", line 595, in finish_connect ov.getresult() ConnectionRefusedError: [WinError 1225] リモート コンピューターによりネットワーク接続が拒否されました。 The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\develop\python\lib\site-packages\wavelink\websocket.py", line 75, in _connect self._websocket = await self._node.session.ws_connect(uri, headers=self.headers, heartbeat=self._node.heartbeat) File "C:\develop\python\lib\site-packages\aiohttp\client.py", line 721, in _ws_connect resp = await self.request(method, url, File "C:\develop\python\lib\site-packages\aiohttp\client.py", line 480, in _request conn = await self._connector.connect( File "C:\develop\python\lib\site-packages\aiohttp\connector.py", line 523, in connect proto = await self._create_connection(req, traces, timeout) File "C:\develop\python\lib\site-packages\aiohttp\connector.py", line 858, in _create_connection _, proto = await self._create_direct_connection( File "C:\develop\python\lib\site-packages\aiohttp\connector.py", line 1004, in _create_direct_connection raise last_exc File "C:\develop\python\lib\site-packages\aiohttp\connector.py", line 980, in _create_direct_connection transp, proto = await self._wrap_create_connection( File "C:\develop\python\lib\site-packages\aiohttp\connector.py", line 943, in _wrap_create_connection raise client_error(req.connection_key, exc) from exc aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host x.x.x.x:2333 ssl:default [リモート コンピューターによりネットワーク接続が拒否されました。]
(x.x.x.xは自分のIPです。隠させて頂きました)
該当のソースコード
python
1import discord 2import wavelink 3from discord.ext import commands 4 5 6class Bot(commands.Bot): 7 8 def __init__(self): 9 super(Bot, self).__init__(command_prefix=['audio ', 'wave ', 'aw ']) 10 11 self.add_cog(Music(self)) 12 13 async def on_ready(self): 14 print(f'Logged in as {self.user.name} | {self.user.id}') 15 16 17class Music(commands.Cog): 18 19 def __init__(self, bot): 20 self.bot = bot 21 22 if not hasattr(bot, 'wavelink'): 23 self.bot.wavelink = wavelink.Client(bot=self.bot) 24 25 self.bot.loop.create_task(self.start_nodes()) 26 27 async def start_nodes(self): 28 await self.bot.wait_until_ready() 29 30 # Initiate our nodes. For this example we will use one server. 31 # Region should be a discord.py guild.region e.g sydney or us_central (Though this is not technically required) 32 await self.bot.wavelink.initiate_node(host='x.x.x.x', 33 port=2333, 34 rest_uri='http://x.x.x.x:2333', 35 password='', 36 identifier='TEST', 37 region='us_central') 38 39 @commands.command(name='connect') 40 async def connect_(self, ctx, *, channel: discord.VoiceChannel = None): 41 if not channel: 42 try: 43 channel = ctx.author.voice.channel 44 except AttributeError: 45 raise discord.DiscordException('No channel to join. Please either specify a valid channel or join one.') 46 47 player = self.bot.wavelink.get_player(ctx.guild.id) 48 await ctx.send(f'Connecting to **`{channel.name}`**') 49 await player.connect(channel.id) 50 51 @commands.command() 52 async def play(self, ctx, *, query: str): 53 tracks = await self.bot.wavelink.get_tracks(f'ytsearch:{query}') 54 55 if not tracks: 56 return await ctx.send('Could not find any songs with that query.') 57 58 player = self.bot.wavelink.get_player(ctx.guild.id) 59 if not player.is_connected: 60 await ctx.invoke(self.connect_) 61 62 await ctx.send(f'Added {str(tracks[0])} to the queue.') 63 await player.play(tracks[0]) 64 65 66bot = Bot() 67bot.run('トークン')
試したこと
- 自分のIP→エラー
- 127.0.0.1を試す→同じ結果
補足情報(FW/ツールのバージョンなど)
Python 3.8.3
discord.py 1.3.3
websockets 8.1
wavelink 0.9.2
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。