Open mrqaidi opened 6 years ago
makeRequest function need alot of improvement also i can not see curl_close called anywhere
When you send an API request to deluge, you have to send a request id. A number that increases with every request you send. See: https://dev.deluge-torrent.org/wiki/Development/DelugeRPC. The response from Deluge also contains the same id.
This API throws an error if the response from deluge does not contain the correct id. Thought to be honest I'm not sure exactly how this could happen since php runs synchronously.
Can you post the http request/responses?
And you're right about no closing function. I'll have to add a cleanup function or something.
aha i dont know whats wrong but something is not right sometimes there is no connection here is my error log
[14-Jun-2018 13:57:01 UTC] movie title : Cowboys & Aliens [14-Jun-2018 13:57:01 UTC] movie torrent url : https://yts.am/torrent/download/160C08A3F5CD5DDE2421A63EA315054CF378D23D [14-Jun-2018 13:57:03 UTC] success : movie created [14-Jun-2018 13:57:08 UTC] Request for method core.add_torrent_url failed due to curl error (no. 28): Operation timed out after 5001 milliseconds with 0 bytes received [14-Jun-2018 13:57:08 UTC] Request for method core.add_torrent_url returned unexpected http code: 0 (expected 200) [14-Jun-2018 13:57:08 UTC] Error : downloading torrent [14-Jun-2018 13:57:08 UTC] retry : download torrent [14-Jun-2018 13:57:13 UTC] Request for method core.add_torrent_url failed due to curl error (no. 28): Operation timed out after 5000 milliseconds with 0 bytes received [14-Jun-2018 13:57:13 UTC] Request for method core.add_torrent_url returned unexpected http code: 0 (expected 200) [14-Jun-2018 13:57:13 UTC] retry Error : downloading torrent
That seems like a problem with your deluge daemon, or possibly you're sending too many requests too quickly.
Are you re-sending the request immediately on failure? It looks like your first request times out, then you send a second one which returns http code 0 after 5 seconds (which means no response). Try increasing the curl timeout length. I set it to 5s arbitrarily.
CURLOPT_CONNECTTIMEOUT => 5,
CURLOPT_TIMEOUT => 5,
FYI I just pushed an update that you may want to look at. It increases the timeout, improves the error message of the first error you were seeing, and logs the last http request/response so you can debug easily.
thank you very much i will test this one and give you feedback
also if its possible make a debug mode in class if its enabled then do Exception otherwise just log it bocz right now in my script i dont want to be stopped
There's not really a need for that. You should be wrapping your calls in try/catch statements anyways:
try {
$deluge = new deluge("https://127.0.0.1:8112", "yourpassword");
$torrents = $deluge->getTorrents(null, null);
$status = $deluge->getTorrentStatus($torrents[0]->hash, array(), array());
$deluge->close(); //Closes the cURL handle
}
catch (Exception $e) {
if (debug)
log($e->getMessage());
else
throw $e;
}
Hi
i get some errors that i dont understand whats wrong
this one of them
PHP Fatal error: Uncaught exception 'Exception' with message 'Response id did not match request id' in class.deluge.php:501