Unable to connect rtorrent/rutorrent to sonarr

Sonarr version (exact version): 3.0.9.1549
Mono version (if Sonarr is not running on Windows): 6.12.0.182
OS: Ubuntu 22.04
Debug logs: https://dedi.kururin.tech/sonarr.trace.txt
https://dedi.kururin.tech/sonarr.debug.txt
https://dedi.kururin.tech/sonarr.txt
Description of issue:

I been trying my absolute best all day in connecting my rtorrent/rutorrent instance to sonarr. I have tried all the methods but none is working. Afaik my rtorrent setup is fine. Its using SCGI port 4000, and that’s reflected across my nginx and my rutorrent. Sonarr is unable to find the server still. I have tried the socket method and it still did not work.

Here’s how my sonarr config looks

[v3.0.9.1549] NzbDrone.Core.Download.Clients.DownloadClientException: Unable to connect to rTorrent, please check your settings ---> CookComputing.XmlRpc.XmlRpcServerException: Not Found
  at CookComputing.XmlRpc.XmlRpcClientProtocol.ReadResponse (CookComputing.XmlRpc.XmlRpcRequest req, System.Net.WebResponse webResp, System.IO.Stream respStm) [0x00038] in <a205b9da6b014c438c362c4bd859d7bc>:0 
  at CookComputing.XmlRpc.XmlRpcClientProtocol.Invoke (System.Object clientObj, System.Reflection.MethodInfo mi, System.Object[] parameters) [0x001a1] in <a205b9da6b014c438c362c4bd859d7bc>:0 
  at CookComputing.XmlRpc.XmlRpcClientProtocol.Invoke (System.Reflection.MethodInfo mi, System.Object[] Parameters) [0x00000] in <a205b9da6b014c438c362c4bd859d7bc>:0 
  at XmlRpcProxy27ea85d1-36fa-49f5-9494-b098d9eda697.GetVersion () [0x00011] in <1bf3164f067647cab7dc95af0c862784>:0 
  at NzbDrone.Core.Download.Clients.RTorrent.RTorrentProxy+<>c__DisplayClass2_0.<GetVersion>b__0 () [0x00000] in M:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone.Core\Download\Clients\rTorrent\RTorrentProxy.cs:73 
  at NzbDrone.Core.Download.Clients.RTorrent.RTorrentProxy.ExecuteRequest[T] (System.Func`1[TResult] task) [0x00000] in M:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone.Core\Download\Clients\rTorrent\RTorrentProxy.cs:279 
   --- End of inner exception stack trace ---
  at NzbDrone.Core.Download.Clients.RTorrent.RTorrentProxy.ExecuteRequest[T] (System.Func`1[TResult] task) [0x0000a] in M:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone.Core\Download\Clients\rTorrent\RTorrentProxy.cs:283 
  at NzbDrone.Core.Download.Clients.RTorrent.RTorrentProxy.GetVersion (NzbDrone.Core.Download.Clients.RTorrent.RTorrentSettings settings) [0x00023] in M:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone.Core\Download\Clients\rTorrent\RTorrentProxy.cs:73 
  at NzbDrone.Core.Download.Clients.RTorrent.RTorrent.TestConnection () [0x00000] in M:\BuildAgent\work\63739567f01dbcc2\src\NzbDrone.Core\Download\Clients\rTorrent\RTorrent.cs:217 

2023-02-05 20:47:53.9|Warn|SonarrErrorPipeline|Invalid request Validation failed: 
 -- Host: Unable to connect to rTorrent

Since I get this. I am pasting my nginx conf and rtorrent config and rutorrent config. I am not sure whats wrong here. I would appreciate any help possible!

Rtorrent Config:

## Instance layout (base paths)
method.insert = cfg.basedir,  private|const|string, (cat,"/home/rayz/rt/")
method.insert = cfg.download, private|const|string, (cat,(cfg.basedir),"download/")
method.insert = cfg.logs,     private|const|string, (cat,(cfg.basedir),"log/")
method.insert = cfg.logfile,  private|const|string, (cat,(cfg.logs),"rtorrent-",(system.time),".log")
method.insert = cfg.session,  private|const|string, (cat,(cfg.basedir),".session/")
method.insert = cfg.watch,    private|const|string, (cat,(cfg.basedir),"watch/")


## Create instance directories
execute.throw = sh, -c, (cat,\
    "mkdir -p \"",(cfg.download),"\" ",\
    "\"",(cfg.logs),"\" ",\
    "\"",(cfg.session),"\" ",\
    "\"",(cfg.watch),"/load\" ",\
    "\"",(cfg.watch),"/start\" ")


## Listening port for incoming peer traffic (fixed; you can also randomize it)
network.port_range.set = 50000-50000
network.port_random.set = no


## Tracker-less torrent and UDP tracker support
## (conservative settings for 'private' trackers, change for 'public')
dht.mode.set = disable
protocol.pex.set = no

trackers.use_udp.set = no


## Peer settings
throttle.max_uploads.set = 100
throttle.max_uploads.global.set = 250

throttle.min_peers.normal.set = 20
throttle.max_peers.normal.set = 60
throttle.min_peers.seed.set = 30
throttle.max_peers.seed.set = 80
trackers.numwant.set = 80

protocol.encryption.set = allow_incoming,try_outgoing,enable_retry


## Limits for file handle resources, this is optimized for
## an `ulimit` of 1024 (a common default). You MUST leave
## a ceiling of handles reserved for rTorrent's internal needs!
network.http.max_open.set = 50
network.max_open_files.set = 600
network.max_open_sockets.set = 300


## Memory resource usage (increase if you have a large number of items loaded,
## and/or the available resources to spend)
pieces.memory.max.set = 2048M
network.xmlrpc.size_limit.set = 4M


## Basic operational settings (no need to change these)
session.path.set = (cat, (cfg.session))
directory.default.set = (cat, (cfg.download))
log.execute = (cat, (cfg.logs), "execute.log")
#log.xmlrpc = (cat, (cfg.logs), "xmlrpc.log")
execute.nothrow = sh, -c, (cat, "echo >",\
    (session.path), "rtorrent.pid", " ",(system.pid))


## Other operational settings (check & adapt)
encoding.add = utf8
system.umask.set = 0027
system.cwd.set = (directory.default)
network.http.dns_cache_timeout.set = 25
schedule2 = monitor_diskspace, 15, 60, ((close_low_diskspace, 1000M))
pieces.hash.on_completion.set = yes
#view.sort_current = seeding, greater=d.ratio=
#keys.layout.set = qwerty
#network.http.capath.set = "/etc/ssl/certs"
#network.http.ssl_verify_peer.set = 0
#network.http.ssl_verify_host.set = 0


## Some additional values and commands
method.insert = system.startup_time, value|const, (system.time)
method.insert = d.data_path, simple,\
    "if=(d.is_multi_file),\
        (cat, (d.directory), /),\
        (cat, (d.directory), /, (d.name))"
method.insert = d.session_file, simple, "cat=(session.path), (d.hash), .torrent"


## Watch directories (add more as you like, but use unique schedule names)
## Add torrent
schedule2 = watch_load, 11, 10, ((load.verbose, (cat, (cfg.watch), "load/*.torrent")))
## Add & download straight away
schedule2 = watch_start, 10, 10, ((load.start_verbose, (cat, (cfg.watch), "start/*.torrent")))


## Run the rTorrent process as a daemon in the background
## (and control via XMLRPC sockets)
system.daemon.set = false
#network.scgi.open_local = /var/www/rt/.rtorrent.sock
#schedule2 = chmod_scgi_socket, 0, 0, "execute2=chmod,\"g+w,o=\",/var/www/rt/.rtorrent.sock"

## Logging:
##   Levels = critical error warn notice info debug
##   Groups = connection_* dht_* peer_* rpc_* storage_* thread_* tracker_* torrent_*
print = (cat, "Logging to ", (cfg.logfile))
log.open_file = "log", (cfg.logfile)
log.add_output = "info", "log"
#log.add_output = "tracker_debug", "log"

### END of rtorrent.rc ###
scgi_port = 127.0.0.1:4000

rutorrent config

<?php
	// configuration parameters

	// for snoopy client
	$httpUserAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36';
	$httpTimeOut = 30; // in seconds
	$httpUseGzip = true;
	$httpIP = null;				// IP string. Or null for any.
	$httpProxy = array
	(
		'use' 	=> false,
		'proto'	=> 'http',		// 'http' or 'https'
		'host'	=> 'PROXY_HOST_HERE',
		'port'	=> 3128
	);

	// for xmlrpc actions
	$rpcTimeOut = 5; // in seconds
	$rpcLogCalls = false;
	$rpcLogFaults = true;

	// for php
	$phpUseGzip = true;
	$phpGzipLevel = 9;

	$schedule_rand = 10;			// rand for schedulers start, +0..X seconds

	$do_diagnostic = true;			// Diagnose ruTorrent. Recommended to keep enabled, unless otherwise required.
	$al_diagnostic = true;			// Diagnose auto-loader. Set to "false" to make composer plugins work.

	$log_file = '/tmp/errors.log';		// path to log file (comment or leave blank to disable logging)

	$saveUploadedTorrents = true;		// Save uploaded torrents to profile/torrents directory or not
	$overwriteUploadedTorrents = false;     // Overwrite existing uploaded torrents in profile/torrents directory or make unique name

	$topDirectory = '/home/rayz/rt';	// Upper available directory. Absolute path with trail slash.
	$forbidUserSettings = false;

	$scgi_port = 4000;
	$scgi_host = "127.0.0.1";

	// For web->rtorrent link through unix domain socket 
	// (scgi_local in rtorrent conf file), change variables 
	// above to something like this:
	//
	// $scgi_port = 0;
	// $scgi_host = "unix:///home/rayz/rt/rpc.socket";
	//
	//

	$XMLRPCMountPoint = "/RPC2";		// DO NOT DELETE THIS LINE!!! DO NOT COMMENT THIS LINE!!!
	$throttleMaxSpeed = 327625*1024;	// DO NOT EDIT THIS LINE!!! DO NOT COMMENT THIS LINE!!!
	// Can't be greater then 327625*1024 due to limitation in libtorrent ResourceManager::set_max_upload_unchoked function.

	$pathToExternals = array(
		"python" => '/usr/bin/python3',
		"php" 	=> '/usr/bin/php',	// Something like /usr/bin/php. If empty, will be found in PATH.
		"curl"	=> '/usr/bin/curl',	// Something like /usr/bin/curl. If empty, will be found in PATH.
		"gzip"	=> '/usr/bin/gzip',	// Something like /usr/bin/gzip. If empty, will be found in PATH.
		"id"	=> '/usr/bin/id',	// Something like /usr/bin/id. If empty, will be found in PATH.
		"stat"	=> '/usr/bin/stat',	// Something like /usr/bin/stat. If empty, will be found in PATH.
		"ffmpeg" => '/usr/bin/ffmpeg',
		"sox"	=> '/usr/bin/sox',
	);

	$localhosts = array( 			// list of local interfaces
		"127.0.0.1",
		"localhost",
	);

	$profilePath = '../../share';		// Path to user profiles
	$profileMask = 0777;			// Mask for files and directory creation in user profiles.
						// Both Webserver and rtorrent users must have read-write access to it.
						// For example, if Webserver and rtorrent users are in the same group then the value may be 0770.

	$tempDirectory = null;			// Temp directory. Absolute path with trail slash. If null, then autodetect will be used.

	$canUseXSendFile = false;		// If true then use X-Sendfile feature if it exist

	$locale = "UTF8";

	$enableCSRFCheck = false;		// If true then Origin and Referer will be checked
	$enabledOrigins = array();		// List of enabled domains for CSRF check (only hostnames, without protocols, port etc.).
						// If empty, then will retrieve domain from HTTP_HOST / HTTP_X_FORWARDED_HOST

Nginx Conf

server {
	listen 80;
        server_name xxx;
	# Redirect all non-https requests
	rewrite ^ https://$host$request_uri? permanent;
}

server {
	listen 443 ssl http2;
	server_name xxx;
        root xxx;
        index index.html index.htm index.php index.nginx-debian.html;

	# Certificate(s) and private key
	ssl_certificate     xxx;
	ssl_certificate_key xxx;

	ssl_dhparam xxx;
	ssl_protocols TLSv1.2 TLSv1.3;	
	ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
	ssl_prefer_server_ciphers off;
	#ssl_protocols TLSv1.3 TLSv1.2;
	#ssl_prefer_server_ciphers on;
	#ssl_ecdh_curve secp521r1;
	#ssl_ciphers TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:EECDH+AESGCM:EDH+AESGCM;
	ssl_session_cache shared:TLS:2m;
	ssl_buffer_size 4k;

	# OCSP stapling
	ssl_stapling on;
	ssl_stapling_verify on;
	resolver 1.1.1.1 1.0.0.1;
	sendfile off;

	auth_basic "Restricted";
	auth_basic_user_file file;

	location / {
		try_files $uri $uri/ =404;
	}

	location /RPC2 {
		include /etc/nginx/scgi_params;
		scgi_pass 127.0.0.1:4000;
		#scgi_pass unix:/var/www/rt/.rtorrent.sock;
	}

	# pass the PHP scripts to FastCGI server listening on socket
	#
	location ~ \.php$ {
                try_files $uri =404;
		fastcgi_split_path_info ^(.+\.php)(/.+)$;
		fastcgi_pass unix:/run/php/php8.2-fpm.sock;
		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
		fastcgi_param SCRIPT_NAME $fastcgi_script_name;
		fastcgi_index index.php;
		include fastcgi_params;
	}
}

Bumping this :slight_smile:

Looks like the path to the rutorrent API is wrong as the request is getting a Not Found response.

Looks like the path to the rutorrent API is wrong as the request is getting a Not Found response.

Would you know how to put the right API? I tried everything and nothing is working :confused:

My only suggestions are the what’s in the help text below it, it depends on how things are setup.

I am only running things in reverse proxy. Both for sonarr and everything else. RPC2 is not working as a endpoint.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.