Losing Connection to Deluge

I’m having an issue with Sonarr not being able to connect to Deluge. It seems to happen whenever the computer running Sonarr and the VM that runs Deluge gets restarted. I also have CouchPotato set up with Deluge, and it does not lose connection with Deluge. I hit test in Sonarr, connection fails. I hit test in CouchPotato, test is successful. The other weird thing, if I open the Deluge webui in my browser and sign in, then hit Test on Deluge in Sonarr, it starts working. In fact, that is what I have to do to fix it every time my computer restarts (which really isn’t all that often). This show sup in the logs when it can’t connect:

“NzbDrone.Core.Download.Clients.DownloadClientException: Failed to connect to Deluge daemon.
at NzbDrone.Core.Download.Clients.Deluge.DelugeProxy.ConnectDaemon(IRestClient restClient) in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Download\Clients\Deluge\DelugeProxy.cs:line 300
at NzbDrone.Core.Download.Clients.Deluge.DelugeProxy.AuthenticateClient(IRestClient restClient) in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Download\Clients\Deluge\DelugeProxy.cs:line 275
at NzbDrone.Core.Download.Clients.Deluge.DelugeProxy.BuildClient(DelugeSettings settings) in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Download\Clients\Deluge\DelugeProxy.cs:line 251
at NzbDrone.Core.Download.Clients.Deluge.DelugeProxy.ProcessRequest[TResult](DelugeSettings settings, String action, Object[] arguments) in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Download\Clients\Deluge\DelugeProxy.cs:line 162
at NzbDrone.Core.Download.Clients.Deluge.DelugeProxy.GetTorrents(DelugeSettings settings) in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Download\Clients\Deluge\DelugeProxy.cs:line 68
at NzbDrone.Core.Download.Clients.Deluge.Deluge.GetItems() in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Download\Clients\Deluge\Deluge.cs:line 98”

Have you a lot of torrents running?

Sonarr relies on the HTTP API (same as the WebUI uses), whereas to my knowledge CP uses a connection directly to the daemon. Deluge’s Web API is a bit awkward and fails to connect to the daemon, which is what you’re seeing here.

We talked about switching to the daemon instead of the web API, but its quite a bit of effort.

I noticed that after I posted. CP uses different port and requires username and password to log in, figured it wasn’t the same type of connection. Now that I think about it, the first time I log into the Deluge Webui on a browser, I have to select the daemon to connect to. Any subsequent time I pull up the Webui, it automatically pulls up that Daemon. Maybe if Deluge had an option to autoconnect to a Daemon, that would help.

As for lots of torrents, yes I have way too many. I shaved it down some.

Thanks for the replies!

I’m having the same issue. It just popped out of nowhere. I noticed that shows aren’t being handled properly. They are donwloaded but not processed

Component Message Time
DownloadMonitoringService Unable to retrieve queue and history items from deluge: Object reference not set to an instance of an object 9:50pm
DownloadMonitoringService Unable to retrieve queue and history items from deluge: Object reference not set to an instance of an object 9:48pm
DownloadMonitoringService Unable to retrieve queue and history items from deluge: Object reference not set to an instance of an object 9:47pm
DownloadMonitoringService Unable to retrieve queue and history items from deluge: Object reference not set to an instance of an object 9:46pm
Tuesday, February 9 2016 9:46:36pm
GlobalExceptionHandlers SignalR Heartbeat interupted 9:45pm
DownloadClientCheck Unable to communicate with deluge. 9:45pm
Tuesday, February 9 2016 9:45:40pm
RestSharpExtensions Error communicating with server: The request timed out 9:45pm
DownloadMonitoringService Unable to retrieve queue and history items from deluge: Object reference not set to an instance of an object 9:45pm
GlobalExceptionHandlers SignalR Heartbeat interupted 9:44pm

Also when I go to test deluge in download clients, the test succeeds.

Hmm strange seems to be working ok for now after restarting deluge

I already had few issues when Deluge is too busy.

Well, it seems Sonarr is losing connectiong to Deluge more than I realized. I would like to kindly request the feature of connecting to the Deluge Daemon be added. I’ve switched back over to SickRage for now. I tried to set up a different torrent client, but my cousin set up a virtual machine that the torrent client runs on. He has some script running to change the port Deluge uses so that it matches the port used by the VPN. That’s over my head, so I could not get a different torrent client to work. I’m throwing a donation your way. If I’m going to request features, I figure I should. I’m not a jerk that will expect the feature to be added in a week. Keep up the good work, Sonarr is a great program!

1 Like

Have you tried restarting deluge? I haven’t had the issue since last night after trying that

I’m having this same issue all of the sudden. Everything has been working great all week until Thursday night when only two of my five shows downloaded, and then I had to process them manually. In playing with it this afternoon, I managed to get one torrent to automatically add, but the rest are timing out. I’ve restarted pc, restarted Deluge + Daemon several times, and testing in the settings is always successful, but it is repeatedly timing out consistently. Don’t have many torrent’s running at all (<30)

System.Net.WebException: The request was aborted: The operation has timed out.
at NzbDrone.Core.Rest.RestSharpExtensions.ValidateResponse(IRestResponse response, IRestClient restClient) in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Rest\RestSharpExtensions.cs:line 33
at NzbDrone.Core.Rest.RestSharpExtensions.Read[T](IRestResponse restResponse, IRestClient restClient) in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Rest\RestSharpExtensions.cs:line 60
at NzbDrone.Core.Rest.RestSharpExtensions.ExecuteAndValidate[T](IRestClient client, IRestRequest request) in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Rest\RestSharpExtensions.cs:line 72
at NzbDrone.Core.Download.Clients.Deluge.DelugeProxy.ProcessRequest[TResult](IRestClient client, String action, Object[] arguments) in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Download\Clients\Deluge\DelugeProxy.cs:line 226
at NzbDrone.Core.Download.Clients.Deluge.DelugeProxy.ProcessRequest[TResult](DelugeSettings settings, String action, Object[] arguments) in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Download\Clients\Deluge\DelugeProxy.cs:line 191
at NzbDrone.Core.Download.Clients.Deluge.DelugeProxy.SetLabel(String hash, String label, DelugeSettings settings) in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Download\Clients\Deluge\DelugeProxy.cs:line 157
at NzbDrone.Core.Download.Clients.Deluge.Deluge.AddFromTorrentFile(RemoteEpisode remoteEpisode, String hash, String filename, Byte[] fileContent) in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Download\Clients\Deluge\Deluge.cs:line 62
at NzbDrone.Core.Download.TorrentClientBase1.DownloadFromWebUrl(RemoteEpisode remoteEpisode, String torrentUrl) in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Download\TorrentClientBase.cs:line 146 at NzbDrone.Core.Download.TorrentClientBase1.Download(RemoteEpisode remoteEpisode) in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Download\TorrentClientBase.cs:line 90
at NzbDrone.Core.Download.DownloadService.DownloadReport(RemoteEpisode remoteEpisode) in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Download\DownloadService.cs:line 66
at NzbDrone.Core.Download.ProcessDownloadDecisions.ProcessDecisions(List`1 decisions) in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Download\ProcessDownloadDecisions.cs:line 74

Request Failed: The underlying connection was closed: A connection that was expected to be kept alive was closed by the server.

Exception
System.Net.WebException: The underlying connection was closed: A connection that was expected to be kept alive was closed by the server. —> System.IO.IOException: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. —> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
— End of inner exception stack trace —
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Security._SslStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security._SslStream.StartReading(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.TlsStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
— End of inner exception stack trace —
at NzbDrone.Core.Rest.RestSharpExtensions.ValidateResponse(IRestResponse response, IRestClient restClient) in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Rest\RestSharpExtensions.cs:line 33
at NzbDrone.Core.Rest.RestSharpExtensions.Read[T](IRestResponse restResponse, IRestClient restClient) in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Rest\RestSharpExtensions.cs:line 60
at NzbDrone.Core.Rest.RestSharpExtensions.ExecuteAndValidate[T](IRestClient client, IRestRequest request) in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Rest\RestSharpExtensions.cs:line 72
at NzbDrone.Core.Download.Clients.Deluge.DelugeProxy.ProcessRequest[TResult](IRestClient client, String action, Object[] arguments) in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Download\Clients\Deluge\DelugeProxy.cs:line 226
at NzbDrone.Core.Download.Clients.Deluge.DelugeProxy.ProcessRequest[TResult](DelugeSettings settings, String action, Object[] arguments) in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Download\Clients\Deluge\DelugeProxy.cs:line 181
at NzbDrone.Core.Download.Clients.Deluge.DelugeProxy.SetLabel(String hash, String label, DelugeSettings settings) in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Download\Clients\Deluge\DelugeProxy.cs:line 157
at NzbDrone.Core.Download.Clients.Deluge.Deluge.AddFromTorrentFile(RemoteEpisode remoteEpisode, String hash, String filename, Byte[] fileContent) in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Download\Clients\Deluge\Deluge.cs:line 62
at NzbDrone.Core.Download.TorrentClientBase1.DownloadFromWebUrl(RemoteEpisode remoteEpisode, String torrentUrl) in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Download\TorrentClientBase.cs:line 146 at NzbDrone.Core.Download.TorrentClientBase1.Download(RemoteEpisode remoteEpisode) in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Download\TorrentClientBase.cs:line 90
at NzbDrone.Core.Download.DownloadService.DownloadReport(RemoteEpisode remoteEpisode) in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Core\Download\DownloadService.cs:line 66
at NzbDrone.Api.Indexers.ReleaseModule.DownloadRelease(ReleaseResource release) in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Api\Indexers\ReleaseModule.cs:line 67
at NzbDrone.Api.Indexers.ReleaseModule.<.ctor>b__0(Object x) in m:\BuildAgent\work\6c3239faf2b92630\src\NzbDrone.Api\Indexers\ReleaseModule.cs:line 46
at CallSite.Target(Closure , CallSite , Func`2 , Object )
at Nancy.Routing.Route.<>c__DisplayClass4.b__3(Object parameters, CancellationToken context)
Close

For people using deluge in linux you have options, first you can strip down your init script (systemd has more options in case the process fails so it should be ok) to only start the daemon. Then you’ll have to control the web daemon under monit or supervisord.

For monit you can move the whole deluge-web to another init script (leaving behind deluged of course) and place a monit conf to watch this process.

monit or supervisord can watch pid and trigger a start in case the process is not available.

I had this problem myself using deluge in a limited VPS (128MB RAM) i started using monit to prevent failure of the web daemon and it worked , but at the end I opted for transmission, which is more suitable for low resource environments.

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