discord.py icon indicating copy to clipboard operation
discord.py copied to clipboard

No indication of UDP Connection failure

Open spencerpogo opened this issue 4 years ago • 14 comments

Summary

When I run await vc.connect() it hangs and doesn't return, despite debug logging saying the handshake was successful. Turns out that UDP connections where being blocked, but discord.py gave no indication that there was any issue at all.

Reproduction Steps

Full code

Expected Results

Client connects to voice channel, method returns, and audio plays.

Actual Results

Full logs The client connects to the voice channel. joining is printed on stdout but no other prints happen.

Checklist

  • [x] I have searched the open issues for duplicates.
  • [x] I have shown the entire traceback, if possible.
  • [x] I have removed my token from display, if visible.

System Information

- Python v3.8.2-final
- discord.py v1.3.3-final
- aiohttp v3.6.2
- websockets v8.1
- system info: Linux 5.4.0-1009-gcp #9-Ubuntu SMP Fri Apr 10 19:12:03 UTC 2020

Thanks.

spencerpogo avatar May 11 '20 23:05 spencerpogo

btw you just leaked your token

TheRockettek avatar May 11 '20 23:05 TheRockettek

I think the problem is on discord's site because I'm getting this:

[12/May/2020 10:27:37] INFO - Connecting to voice...
[12/May/2020 10:27:37] INFO - Starting voice handshake...
[12/May/2020 10:27:47] ERROR - Task exception was never retrieved
future: <Task finished name='Task-43131781' coro=<VoiceClient._create_socket() done, defined at /usr/local/lib/python3.8/dist-packages/discord/voice_client.py:172> exception=gaierror(-3, 'Temporary failure in name resolution')>
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/discord/voice_client.py", line 191, in _create_socket
    self.endpoint_ip = socket.gethostbyname(self.endpoint)
socket.gaierror: [Errno -3] Temporary failure in name resolution

FightMan01 avatar May 12 '20 11:05 FightMan01

That's on your end.

TheRockettek avatar May 12 '20 13:05 TheRockettek

Same here - except it shows as connected to the voice in Discord, but the code thinks its not

infinitelyjames avatar May 28 '20 12:05 infinitelyjames

Did you manage to fix the issue @Scoder12?

Bart2000 avatar Jun 27 '20 13:06 Bart2000

@Bart2000 nope, still not working

spencerpogo avatar Aug 05 '20 20:08 spencerpogo

I figured out the issue. The host I was running it on blocked UDP ports, it still would be nice to have some sort of indication that this is the issue.

spencerpogo avatar Aug 18 '20 16:08 spencerpogo

I figured out the issue. The host I was running it on blocked UDP ports, it still would be nice to have some sort of indication that this is the issue.

This isn't really realistic, there are a ton of different local networking issues that could be causing this. It's not the library's responsibility to implement code to diagnose the dozens, if not hundreds, of possibilities that could be causing this considering they are all networking issues on your side.

Phxntxm avatar Aug 18 '20 16:08 Phxntxm

True, but there could at least be an indication that it is not connected to voice. Maybe connect hanging is an indication enough but its frustrating to debug whats going on when you don't know if its the libraries fault or a networking issue.

I recognize that this is a rare issue so if no one wants to fix it idc.

spencerpogo avatar Aug 18 '20 18:08 spencerpogo

There are going to be changes on how the voice connection flow which might accidentally fix this though I'm unsure what the error is. If UDP is being blocked I suspect socket.connect would fail but I don't actually use it since I use the implicit binding flow. It might be worth rewriting the socket operations to connect to the address rather than using send_to so this stuff can be handled better -- though when this is called it's way after connect() is called so I'm not totally sure what's going on here.

Rapptz avatar Aug 19 '20 19:08 Rapptz

I just started to get a similar error as well:

ERROR:asyncio:Task exception was never retrieved
future: <Task finished coro=<VoiceClient._create_socket() done, defined at /usr/local/lib/python3.6/dist-packages/discord/voice_client.py:172> exception=gaierror(-2, 'Name or service not known')>
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/discord/voice_client.py", line 191, in _create_socket
    self.endpoint_ip = socket.gethostbyname(self.endpoint)
socket.gaierror: [Errno -2] Name or service not known

I don't think I changed anything recently. Is there any other way to diagnose or log the UDP port?

Thyself17 avatar Sep 26 '20 03:09 Thyself17

I'm currently, out of nowhere, getting this error myself too. Nothing has changed on my end, or the server running it.

Very confused about what to do about troubleshooting this.

I just started to get a similar error as well:

ERROR:asyncio:Task exception was never retrieved
future: <Task finished coro=<VoiceClient._create_socket() done, defined at /usr/local/lib/python3.6/dist-packages/discord/voice_client.py:172> exception=gaierror(-2, 'Name or service not known')>
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/discord/voice_client.py", line 191, in _create_socket
    self.endpoint_ip = socket.gethostbyname(self.endpoint)
socket.gaierror: [Errno -2] Name or service not known

Is there any other way to diagnose or log the UDP port?

fosspill avatar Sep 27 '20 14:09 fosspill

The issue I'm experiencing, and most likely @Thyself17 seems to be fixed in https://github.com/Rapptz/discord.py/commit/a9824ffabf0b2c8031ac75245650711145aaa26c Update with python3 -m pip install -U discord.py

EDIT: I recommend not updating yet as that seems to have broken everything else. Instead: Use v1.3.4 and change line 190 in voice_client to self.endpoint = endpoint.split(':')[0]

fosspill avatar Sep 27 '20 17:09 fosspill

I was able to fix my script, but I don't have any useful diagnostic information here. I ended up downgrading discord.py, which presented other problems. After that I reinstalled the latest discord.py using python3 -m pip install -U discord.py and then sudo python3 -m pip install -U discord.py

I'm not sure what it changed, but I am now able to connect to voice channels again.

Thyself17 avatar Sep 28 '20 15:09 Thyself17