rkosegi / jdownloader-cli

JDownloader CLI tool written in Go
Apache License 2.0
20 stars 4 forks source link

Timeouts when running commands #51

Open HeyItsJono opened 1 week ago

HeyItsJono commented 1 week ago

Hey there, I'm excited to finally have an alternative to the sluggish web interface, but unfortunately many of these commands seem to just time out. Here's an example below (sensitive info has been replaced by placeholders).

jdcli download link list --device DEVICE--debug

2024-11-05T22:58:24.170+1100    DEBUG   jdownloader/client.go:235       POST https://api.jdownloader.org/my/connect?email=EMAIL&appkey=jdcli&rid=1&signature=938c63ea23446a02652a4c936a000c98f7ba75f3bf34c442eb11b972257d419a @ 1
2024-11-05T22:58:25.776+1100    DEBUG   jdownloader/client.go:248       HTTP200 @ 1
2024-11-05T22:58:25.777+1100    DEBUG   jdownloader/client.go:235       GET https://api.jdownloader.org/my/listdevices?sessiontoken=TOKEN&rid=2&signature=cd01d092f9817bc34cad9c5ca38051268365b3aa07c1e267e65437955b671db6 @ 2
2024-11-05T22:58:26.162+1100    DEBUG   jdownloader/client.go:248       HTTP200 @ 2
2024-11-05T22:58:26.163+1100    DEBUG   jdownloader/client.go:235       POST https://api.jdownloader.org/t_TOKEN_c9dcac34920f7ef91076d51c25973393/downloadsV2/queryLinks @ 3
2024-11-05T22:58:27.846+1100    DEBUG   jdownloader/client.go:248       HTTP200 @ 3
2024-11-05T22:58:56.164+1100    DEBUG   jdownloader/client.go:235       POST https://api.jdownloader.org/my/disconnect?sessiontoken=TOKEN&rid=4&signature=3f4a8bfbdc123e9042c9d160646fa65c01ad122e4bab84b2ca5197cc9c06bc58 @ 4
2024-11-05T22:58:56.557+1100    DEBUG   jdownloader/client.go:248       HTTP200 @ 4
Error: unable to fully consume response body: context deadline exceeded (Client.Timeout or context cancellation while reading body)
Usage:
  jdcli download link list [flags]

Flags:
      --debug           Debugging flag
      --device string   Device name to use for this operation
  -h, --help            help for list

panic: unable to fully consume response body: context deadline exceeded (Client.Timeout or context cancellation while reading body)

goroutine 1 [running]:
main.main()
        /home/runner/work/jdownloader-cli/jdownloader-cli/cmd/cli.go:26 +0x56
rkosegi commented 1 week ago

Hi @HeyItsJono, thank you for report. I've seen this myself before, it's quite nondeterministic - probably depends on responsiveness of api.jdownloader.org. I need to think about how to make this more resilient. According to my experience, retrying command will eventually work.

HeyItsJono commented 3 days ago

Hi @HeyItsJono, thank you for report. I've seen this myself before, it's quite nondeterministic - probably depends on responsiveness of api.jdownloader.org. I need to think about how to make this more resilient. According to my experience, retrying command will eventually work.

Is there a way to interface with the JD instance directly over the local network? JD API allows direct connection which may bypass the issue with API timeouts, I know the Python JD library allows for this

rkosegi commented 2 days ago

Non-default API endpoint is not supported by CLI (yet?) Do you have a link to Python JD library that is capable of direct connection?

HeyItsJono commented 1 day ago

Sure, mind you I haven't tested it myself yet.

Sample: https://github.com/pglaum/pyjd/blob/master/examples/direct.py

Relevant parts of the Python Library: https://github.com/pglaum/pyjd/blob/master/pyjd/direct_connector.py https://github.com/pglaum/pyjd/blob/master/pyjd/direct_connection_helper.py