|
1 | 1 | # Troubleshooting |
2 | 2 |
|
3 | | -Sometimes, you may encounter issues when working with audio. |
| 3 | +Working with audio can sometimes introduce unexpected issues. Below are common problems and their corresponding troubleshooting steps to help you resolve them. |
4 | 4 |
|
5 | | -Below you can find some common issues, as well as some troubleshooting steps you can take to resolve them. |
| 5 | +## Missing Native Dependencies |
| 6 | + |
| 7 | +If you encounter a @System.DllNotFoundException, it usually indicates missing or incompatible native dependencies. Refer to the [Native Dependencies](../basic-concepts/installing-native-dependencies.md) guide for steps on resolving this. |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | +## Timeout When Connecting to Voice |
| 12 | + |
| 13 | +If you experience a @System.TimeoutException when connecting to a voice channel, it typically stems from one of the following issues: |
| 14 | + |
| 15 | +### Missing Permissions |
| 16 | +Ensure the bot has the @NetCord.Permissions.Connect permission in the target voice channel. |
| 17 | + |
| 18 | +### Channel Capacity |
| 19 | +Check if the voice channel is full; the bot needs an available slot to join. |
| 20 | + |
| 21 | +### Already Connected |
| 22 | +Verify that the bot isn't already active in the channel it is trying to join. |
| 23 | + |
| 24 | +### Slow Network Connection |
| 25 | +@NetCord.Gateway.Voice.GatewayClientExtensions.JoinVoiceChannelAsync* has a default timeout of 2 seconds, which might be too brief for slower networks. You can extend this timeout (e.g., to 10 seconds) as shown below: |
| 26 | +[!code-cs[Join Voice Channel with Extended Timeout](Troubleshooting/Examples.cs#L13)] |
| 27 | + |
| 28 | +--- |
| 29 | + |
| 30 | +## Audio Not Playing |
| 31 | + |
| 32 | +If the bot connects to a voice channel but no audio is heard, verify the following: |
| 33 | + |
| 34 | +### Missing Permissions |
| 35 | +Ensure the bot has the @NetCord.Permissions.Speak permission in the voice channel. The bot will appear as muted to other users if it lacks this permission. |
| 36 | + |
| 37 | +### Speaking State |
| 38 | +Make sure to call @NetCord.Gateway.Voice.VoiceClient.EnterSpeakingStateAsync* with the correct @NetCord.Gateway.Voice.SpeakingFlags before sending audio. |
| 39 | + |
| 40 | +--- |
6 | 41 |
|
7 | 42 | ## Failed to Get External Socket Address |
8 | 43 |
|
9 | | -If you see the error "Failed to get the external socket address. Aborting the client." in your logs, it means that something blocks the IP Discovery response from Discord. This can be caused by various reasons, such as firewall settings or router configurations. If you encounter this issue, try using for example your mobile phone's hotspot to see if the issue is related to your router configuration. If it works on the hotspot, you may need to check your router's settings. |
| 44 | +If you see the error `Failed to get the external socket address. Aborting the client.` in your logs, something is blocking the IP Discovery request or response. |
| 45 | + |
| 46 | +This is typically caused by firewall restrictions or router configurations. To diagnose whether it's a local network issue, try connecting the bot through a different network, such as a mobile hotspot. |
| 47 | + |
| 48 | +--- |
| 49 | + |
| 50 | +## Receiving Audio Stops After Some Time |
| 51 | + |
| 52 | +If audio suddenly cuts out after working normally for a while, consider these common causes: |
| 53 | + |
| 54 | +### UDP Flood Protection |
| 55 | +Your firewall or router might be blocking UDP packets due to a built-in flood protection feature. Try disabling this feature in your router settings, or temporarily switch to a mobile hotspot to see if the issue is strictly related to your router's configuration. |
10 | 56 |
|
11 | | -## Audio Stops After Some Time |
| 57 | +### Closed UDP Socket |
| 58 | +Sockets can sometimes close automatically, especially if the bot is listening without transmitting any audio. You can prevent this by adjusting your firewall/NAT settings or by implementing a keep-alive mechanism. |
12 | 59 |
|
13 | | -If you receive audio for some time and then it suddenly stops, it may be caused by your router blocking the packets after some time. This can be caused by the router's UDP flood protection. You can try disabling this feature in your router's settings to see if it resolves the issue. |
| 60 | +Sending a small, empty data packet at regular intervals will ensure the UDP connection stays open, as demonstrated below: |
| 61 | +[!code-cs[Keep Alive](Troubleshooting/Examples.cs#L18-L21)] |
0 commit comments