Discord.py: This Happens sometiems when starting a ffmpeg player through youtube_dl function or when stopping it.

Created on 17 Apr 2016  路  3Comments  路  Source: Rapptz/discord.py

Most helpful comment

I also get these from Voice connections too.

Traceback (most recent call last):
  File "E:\Users\Elsword\Desktop\DecoraterBot\Async\\DecoraterBot.py", line 61,
in <module>
    DecoraterBotCore.Login.login_info(client)
  File "E:\Users\Elsword\Desktop\DecoraterBot\Async\DecoraterBotCore\Login.py",
line 40, in login_info
    client.run(discord_user_email, discord_user_password, bot_token)
  File "E:\Python35\lib\site-packages\discord\client.py", line 625, in run
    self.loop.run_until_complete(self.start(email, password))
  File "E:\Python35\lib\asyncio\base_events.py", line 337, in run_until_complete

    return future.result()
  File "E:\Python35\lib\asyncio\futures.py", line 274, in result
    raise self._exception
  File "E:\Python35\lib\asyncio\tasks.py", line 239, in _step
    result = coro.send(None)
  File "E:\Python35\lib\site-packages\discord\client.py", line 595, in start
    yield from self.connect()
  File "E:\Python35\lib\site-packages\discord\client.py", line 543, in connect
    yield from self.close()
  File "E:\Python35\lib\site-packages\discord\client.py", line 558, in close
    yield from self.voice.disconnect()
  File "E:\Python35\lib\site-packages\discord\voice_client.py", line 328, in dis
connect
    yield from self.main_ws.send(utils.to_json(payload))
  File "E:\Python35\lib\site-packages\websockets\protocol.py", line 261, in send

    yield from self.write_frame(opcode, data)
  File "E:\Python35\lib\site-packages\websockets\protocol.py", line 421, in writ
e_frame
    "in the {} state".format(self.state_name))
websockets.exceptions.InvalidState: Cannot write to a WebSocket in the CLOSED st
ate
Task exception was never retrieved
future: <Task finished coro=<VoiceClient.keep_alive_handler() done, defined at E
:\Python35\lib\site-packages\discord\voice_client.py:186> exception=InvalidState
('Cannot write to a WebSocket in the CLOSING state',)>
Traceback (most recent call last):
  File "E:\Python35\lib\asyncio\tasks.py", line 239, in _step
    result = coro.send(None)
  File "E:\Python35\lib\site-packages\discord\voice_client.py", line 197, in kee
p_alive_handler
    yield from self.ws.send(utils.to_json(payload))
  File "E:\Python35\lib\site-packages\websockets\protocol.py", line 261, in send

    yield from self.write_frame(opcode, data)
  File "E:\Python35\lib\site-packages\websockets\protocol.py", line 421, in writ
e_frame
    "in the {} state".format(self.state_name))
websockets.exceptions.InvalidState: Cannot write to a WebSocket in the CLOSING s
tate
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x039A5B30>
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x039BB430>
Task was destroyed but it is pending!
task: <Task pending coro=<Client.keep_alive_handler() running at E:\Python35\lib
\site-packages\discord\client.py:300> wait_for=<Future pending cb=[Task._wakeup(
)]>>
Press any key to continue . . .

Also if only d.py would allow you to disable seeing the 502 errors.
I think on the keep alive handler for vws to try and see if it is closed and if so reopen the main ws. So this hopefully gets fixed.

All 3 comments

It's just the usual 502 errors.

I also get these from Voice connections too.

Traceback (most recent call last):
  File "E:\Users\Elsword\Desktop\DecoraterBot\Async\\DecoraterBot.py", line 61,
in <module>
    DecoraterBotCore.Login.login_info(client)
  File "E:\Users\Elsword\Desktop\DecoraterBot\Async\DecoraterBotCore\Login.py",
line 40, in login_info
    client.run(discord_user_email, discord_user_password, bot_token)
  File "E:\Python35\lib\site-packages\discord\client.py", line 625, in run
    self.loop.run_until_complete(self.start(email, password))
  File "E:\Python35\lib\asyncio\base_events.py", line 337, in run_until_complete

    return future.result()
  File "E:\Python35\lib\asyncio\futures.py", line 274, in result
    raise self._exception
  File "E:\Python35\lib\asyncio\tasks.py", line 239, in _step
    result = coro.send(None)
  File "E:\Python35\lib\site-packages\discord\client.py", line 595, in start
    yield from self.connect()
  File "E:\Python35\lib\site-packages\discord\client.py", line 543, in connect
    yield from self.close()
  File "E:\Python35\lib\site-packages\discord\client.py", line 558, in close
    yield from self.voice.disconnect()
  File "E:\Python35\lib\site-packages\discord\voice_client.py", line 328, in dis
connect
    yield from self.main_ws.send(utils.to_json(payload))
  File "E:\Python35\lib\site-packages\websockets\protocol.py", line 261, in send

    yield from self.write_frame(opcode, data)
  File "E:\Python35\lib\site-packages\websockets\protocol.py", line 421, in writ
e_frame
    "in the {} state".format(self.state_name))
websockets.exceptions.InvalidState: Cannot write to a WebSocket in the CLOSED st
ate
Task exception was never retrieved
future: <Task finished coro=<VoiceClient.keep_alive_handler() done, defined at E
:\Python35\lib\site-packages\discord\voice_client.py:186> exception=InvalidState
('Cannot write to a WebSocket in the CLOSING state',)>
Traceback (most recent call last):
  File "E:\Python35\lib\asyncio\tasks.py", line 239, in _step
    result = coro.send(None)
  File "E:\Python35\lib\site-packages\discord\voice_client.py", line 197, in kee
p_alive_handler
    yield from self.ws.send(utils.to_json(payload))
  File "E:\Python35\lib\site-packages\websockets\protocol.py", line 261, in send

    yield from self.write_frame(opcode, data)
  File "E:\Python35\lib\site-packages\websockets\protocol.py", line 421, in writ
e_frame
    "in the {} state".format(self.state_name))
websockets.exceptions.InvalidState: Cannot write to a WebSocket in the CLOSING s
tate
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x039A5B30>
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x039BB430>
Task was destroyed but it is pending!
task: <Task pending coro=<Client.keep_alive_handler() running at E:\Python35\lib
\site-packages\discord\client.py:300> wait_for=<Future pending cb=[Task._wakeup(
)]>>
Press any key to continue . . .

Also if only d.py would allow you to disable seeing the 502 errors.
I think on the keep alive handler for vws to try and see if it is closed and if so reopen the main ws. So this hopefully gets fixed.

The image is fixed above if you add a check for 502's and log.debug the info from it in _rate_limit_helper. @cookkkie

Was this page helpful?
0 / 5 - 0 ratings

Related issues

VoxelPrismatic picture VoxelPrismatic  路  16Comments

TomOrth picture TomOrth  路  15Comments

wolfclaws picture wolfclaws  路  17Comments

johndoe434 picture johndoe434  路  21Comments

ThePiGuy24 picture ThePiGuy24  路  17Comments