Closed engrbm87 closed 6 years ago
I generally use the client for one-off operations and create a new instance every time.
If you want to re-use the client instance then try
client.disconnect()
client._create_socket()
client.connected = False
client.connect()
IF this works for you, please tell me here and I'll try to work that into the client.
How do you detect that connection has been lost and did you have auto-reconnect in mind ?
As a test i do the following:
client._create_socket()
client.connect()
except ConnectionRefusedError:
#log error
return
client.call(...)
So in case the exception is raised the function returns and doesn't do the call
function. But the problem is that i can't use client._create_socket()
because it is protected (starts with _) and this will create a linting error.
If you can add a reconnect() function with the code you mention above this will be great.
Can you try the new version I've commited?
You can install it with
pip install git+https://github.com/JohnDoee/deluge-client.git#develop
and there is an example on how to use reconnect in the new README file here
👍 Thanks a lot for the new reconnect option. This solved my problem without having to change anything in the code from my side. I just run the call function and in case the connection was lost before it simply reconnects.
Can you please merge this into the stable release. Thanks again
Hello, I am using Home Assistant to monitor Deluge using the deluge_client. In case the deluge daemon stops for any reason i am not able to re-connect to the daemon once it is back online. If i try to call the
connect()
function i get aValueError: attempt to connect already-connected SSLSocket!
I tried to call thedisconnect()
before callingconnect()
again but i get the same above error. Any suggestions on how to properly reconnect to deluge daemon.