godeezer / lib

Deezer API implementation in Go
ISC License
5 stars 3 forks source link

context deadline exceeded (Client.Timeout or context cancellation while reading body) #8

Closed toniz4 closed 3 years ago

toniz4 commented 3 years ago

When trying to download some flac tracks I am getting a context deadline exceeded (Client.Timeout or context cancellation while reading body). Here is where i'm getting this error: deezgo. I only saw that happening with flac files, and client.IsQualityAvailable returns true too.

samhza commented 3 years ago

When I first created this library I decided to put a timeout on the HTTP client that deezer.Client uses. I'll fix this and remove the timeout on the default deezer.Client and I'll also add a way to provide your own http.Client for deezer.Client to use, so that users of the package can set their own timeouts if needed.

toniz4 commented 3 years ago

I tried setting the client timeout to a big value, but it ended up just locking the program. The interest thing is that it is downloading most part of the song, generally just the last part that is missing

samhza commented 3 years ago

I'll fix this and remove the timeout on the default deezer.Client and I'll also add a way to provide your own http.Client for deezer.Client to use I've made these changes in 63bc66b2674104df7d514d7e02b4841b8fa837ab and 807270d953e29fc1e16f866c6a8c887b86c694b3.

toniz4 commented 3 years ago

Either way, when setting the timeout for a big amount, like 2 hours, the download never completes. Steps to reproduce: 1: clone the repo that I had sent of my program. 2: try to run this command, almost every album downloaded in the flac format fails: go run main.go get -f flac -p /tmp/go https://www.deezer.com/us/album/13579923 3: you are going to get a context deadline exceeded (Client.Timeout or context cancellation while reading body) 4: try to set a bigger timeout, like 5 hours 5: the download never finishes.

I don't know almost nothing about http requests, so i don't quite understand why this is happening. Trying to download the same songs with deemix works fine.

toniz4 commented 3 years ago

Sorry, it was my mistake calling a defer in the wrong order. Thanks for the help!