switchupcb / disgo

Create a Discord Bot in Go using this Discord API Wrapper. The next generation of Discord API Consumption.
Apache License 2.0
89 stars 2 forks source link

request: timeout error #49

Closed montanaflynn closed 1 year ago

montanaflynn commented 1 year ago

I'm getting a lot of these errors, I don't have any problem with discord.js running on the same network, although maybe they are doing retries?

2023/01/10 20:10:32 error occurred getting channel "##############": REQUEST ERROR: client "": x "###############": route: "32": resource: "": endpoint: "https://discord.com/api/v10/channels/##############": error: timeout
2023/01/10 20:11:43 error occurred sending a message to channel "##############": REQUEST ERROR: client "": x "###############": route: "40": resource: "": endpoint: "https://discord.com/api/v10/channels/##############/messages": error: read tcp4 192.168.1.2:51942->162.159.138.232:443: i/o timeout
2023/01/10 20:11:49 error occurred sending a message to channel "##############": REQUEST ERROR: client "": x "###############": route: "40": resource: "": endpoint: "https://discord.com/api/v10/channels/##############/messages": error: timeout
switchupcb commented 1 year ago

A timeout occurs when the message is not sent within the request's timeout, which is set within the configuration. The timeout represents the amount of time a request will wait for a response.

You can adjust the bot's timeout from the Client.Config.Request.Timeout which is defined at Request. If you would like to ensure that requests occur within a certain time, but are always retried, you can adjust the amount of retries per request by setting the Client.Config.Request.Retries.

bot.Config.Request.Timeout = time.Second * 15

For more information, check out the Client example: Request.

switchupcb commented 1 year ago

@montanaflynn Please let me know if this information solved your problem. If you need more help, feel free to ask.

switchupcb commented 1 year ago

Note For Maintainer

discord.js sets the default timeout to 15 seconds. Consider changing the default timeout, adding the timeout error to a FAQ , or creating a TimeoutError which describes the issue.

Update: fasthttp.ErrTimeout is returned from timed out calls.

This issue will be solved by adding it to either an FAQ or Request concept documentation.

montanaflynn commented 1 year ago

Thanks @switchupcb, this has indeed solved the problem!