Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error traces in Deluge 2.1.1 #22

Closed
ngosang opened this issue Sep 14, 2022 · 5 comments
Closed

Error traces in Deluge 2.1.1 #22

ngosang opened this issue Sep 14, 2022 · 5 comments

Comments

@ngosang
Copy link

ngosang commented Sep 14, 2022

Deluge exporter: 2.4.0

Deluge exporter is working fine and it's exposing the metrics as usual. There are no traces in Deluge exporter. The traces in Deluge only happen in version > 2.0

Traces in Deluge 2.1.1 every 30 seconds:

00:59:29 [INFO    ][deluge.core.rpcserver         :179 ] Deluge Client connection made from: 172.18.0.2:46016
00:59:29 [WARNING ][deluge.transfer               :111 ] Error occurred when parsing message header: Received invalid protocol version: 120. PROTOCOL_VERSION is 1..
00:59:29 [WARNING ][deluge.transfer               :112 ] This version of Deluge cannot communicate with the sender of this data.
00:59:29 [WARNING ][deluge.transfer               :130 ] Failed to decompress (0 bytes) and load serialized data with rencode: Error -5 while decompressing data: incomplete or truncated stream
00:59:29 [WARNING ][deluge.transfer               :111 ] Error occurred when parsing message header: Received invalid protocol version: 68. PROTOCOL_VERSION is 1..
00:59:29 [WARNING ][deluge.transfer               :112 ] This version of Deluge cannot communicate with the sender of this data.
00:59:29 [WARNING ][deluge.transfer               :130 ] Failed to decompress (0 bytes) and load serialized data with rencode: Error -5 while decompressing data: incomplete or truncated stream
00:59:29 [WARNING ][deluge.transfer               :111 ] Error occurred when parsing message header: Received invalid protocol version: 120. PROTOCOL_VERSION is 1..
00:59:29 [WARNING ][deluge.transfer               :112 ] This version of Deluge cannot communicate with the sender of this data.
00:59:29 [WARNING ][deluge.transfer               :130 ] Failed to decompress (0 bytes) and load serialized data with rencode: Error -5 while decompressing data: incomplete or truncated stream
00:59:30 [INFO    ][deluge.core.rpcserver         :205 ] Deluge client disconnected: [('SSL routines', '', 'unexpected eof while reading')]
@JohnDoee
Copy link

Those errors are likely because it's probing for deluge version and unrelated to any errors.

Nothing in that log says that there's a problem with the deluge-client library (although that does not mean there isn't)

@ngosang
Copy link
Author

ngosang commented Sep 17, 2022

@JohnDoee Thank you for your work on deluge-client library. To me it looks like your deluge-client is using some legacy RPC calls. Somehow it works fine but I don't know how to disable those warnings in Deluge.

Maybe you should consider to update your client library to make it compatible with Deluge 2.1 (latest stable release) and drop support for Python2 (if you want to).

There are only 2 Prometheus exporters for deluge and both of them use your library (and have this issue). There is not Prometheus exporter using the Web/HTTP API.

Other Prometheus exporter => https://github.com/LeiShi1313/downloader-exporter
Deluge RPC => https://deluge.readthedocs.io/en/latest/reference/rpc.html

@JohnDoee
Copy link

I've added Deluge 2.1.1 from PPA on Ubuntu 22.04 tests to libtc, which also uses deluge-client, and it passes everything. The tests ran successfully here https://github.com/JohnDoee/libtc/actions/runs/3076393158/jobs/4970516999

/# deluged -v
deluged 2.1.1
libtorrent: 2.0.5.0
Python: 3.10.4
OS: Linux Ubuntu 22.04 jammy

================ 269 passed, 2349 warnings in 566.13s (0:09:26) ================

@ngosang
Copy link
Author

ngosang commented Sep 18, 2022

@JohnDoee @gazpachoking As you guess, the warnings are caused by the version probe. In concrete, the lines 122 and 123.
https://github.com/JohnDoee/deluge-client/blob/0c2e5a9a3be903a38b4c957af9de9449f9d60093/deluge_client/client.py#L122
I fixed my issues by patching deluge-client and commenting those lines.

Since Deluge 2.1.1 is the latest version and all users will update eventually, you should consider improving that code to not hit the warnings. For example:

# test the latest version first 2.1
try:
  self._send_call(2, 1, 'daemon.info')
  # set small socket timeout here
  result = self._socket.recv(1)
  if ord(result[:1]) == 1:
    self.deluge_version = 2
    self.deluge_protocol_version = 1
    # If we need the specific version of deluge 2, this is it.
    daemon_version = self._receive_response(2, 1, partial_data=result)
    return
catch:
   pass

# test 2.0

# test 1.x

@tobbez
Copy link
Owner

tobbez commented Sep 22, 2022

Since Deluge 2.1.1 is the latest version and all users will update eventually, you should consider improving that code to not hit the warnings. For example:

# test the latest version first 2.1
try:
  self._send_call(2, 1, 'daemon.info')
  # set small socket timeout here
  result = self._socket.recv(1)
  if ord(result[:1]) == 1:
    self.deluge_version = 2
    self.deluge_protocol_version = 1
    # If we need the specific version of deluge 2, this is it.
    daemon_version = self._receive_response(2, 1, partial_data=result)
    return
catch:
   pass

# test 2.0

# test 1.x

This doesn't look like it would work as-is. The current version detection code in deluge-client appears to depend on the fact that deluge only replies to requests using the correct version, which means a reply is only guaranteed to exist after all 3 daemon.info _send_call calls.

That means the suggested code would hang (block in recv until the connection was broken) when attempting to connect to deluge versions other than 2.

If you (as the "set small socket timeout" comment suggests) attempt to solve that using a sleep plus a non-blocking read (by passing the MSG_DONTWAIT flag to recv) you have a different problem: you inflict unnecessary wait time on every user, and you break the code for high latency connections (a roundtrip latency longer than the sleep delay would be falsely detected as a version/protocol mismatch).

If possible at all (at a reasonable cost), this would have to be addressed in deluge-client (not deluge_exporter), so I'm closing this issue.

@tobbez tobbez closed this as not planned Won't fix, can't repro, duplicate, stale Sep 22, 2022
tobbez added a commit to tobbez/deluge-client that referenced this issue Oct 22, 2023
The only user of this fork is deluge_exporter, which has already dropped
support for Deluge 1. Users that were running pre-releases of Deluge 2
will most likely have upgraded to 2.0.0 or later at this point.

This fixes:

  JohnDoee#40
  tobbez/deluge_exporter#22

There's also a ticked filed against Deluge for adding a proper way to
determine a daemon's protocol version, which (if implemented) would make
it easier to support multiple protocol versions in the future:

https://dev.deluge-torrent.org/ticket/3609
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants