KyokoBot / koe

Tiny and embeddable Discord media transport library based on Netty.
MIT License
52 stars 14 forks source link

Invalid endpoint makes request never return #23

Open vicky5124 opened 6 months ago

vicky5124 commented 6 months ago

Sending a PATCH request with invalid data results in a request that never finishes.

curl -H "Authorization: $LAVALINK_PASSWORD" http://localhost:2333/v4/sessions/3qygjqfuvxcejpug/players/182892283111276544 -i -X PATCH --json '{"voice" : {"token" : "02ab32bd6b39aaf3", "endpoint" : "wss://madrid253.discord.media:443", "sessionId" : "4541df6f11175d3f34b3baedb7b57a0d"}}'

Tested with this cURL command, where the invalid data is an endpoint that includes the protocol, and the command never finished, even after running for over an hour.

"endpoint" : "wss://madrid253.discord.media:443" This is "invalid" and causes this issue

"endpoint" : "madrid253.discord.media:443" This works completely fine

This is not intended behaviour, being permanently stuck waiting for a response, in an infinite await, or running out of threads in a pool because of a failed request that could easily return an error, or have the invalid information stripped, or time out.

I brought the issue up in the lavalink discord server, and Topi suggested it was a Koe issue.

alula commented 6 months ago

Probably, the connect() implementation looks flawed on quick look: https://github.com/KyokoBot/koe/blob/master/core/src/main/java/moe/kyokobot/koe/internal/MediaConnectionImpl.java#L47