Giter Site home page Giter Site logo

Comments (17)

DevMiser avatar DevMiser commented on August 21, 2024 1

Awesome. Thank you. It would be great to see this written into the Pro Switch example code.

from python-sdk.

neeraj-partha avatar neeraj-partha commented on August 21, 2024

can you please help me to add code to re-connect automatically when disconnected.

from python-sdk.

thegoliathgeek avatar thegoliathgeek commented on August 21, 2024

Might maybe problem with ISP! Try in mobile hotspot once!

from python-sdk.

neeraj-partha avatar neeraj-partha commented on August 21, 2024

i'm using jio hotspot. It disconnects after a certain random amount of time. websocket connection is not consistent.

from python-sdk.

thegoliathgeek avatar thegoliathgeek commented on August 21, 2024

I faced this error too.
Try in different ISP.

from python-sdk.

neeraj-partha avatar neeraj-partha commented on August 21, 2024

Unfortunately I don't have access to any other isp. Can we somehow add code to reconnect when this situation occur? Please help. Thank you

from python-sdk.

neeraj-partha avatar neeraj-partha commented on August 21, 2024

Can I try removing ping interval and ping timeout as stated below

https://stackoverflow.com/questions/54101923/1006-connection-closed-abnormally-error-with-python-3-7-websockets

from python-sdk.

thegoliathgeek avatar thegoliathgeek commented on August 21, 2024

Not an optional solution. If you remove ping. Maintaining a live connection will be lost.

from python-sdk.

neeraj-partha avatar neeraj-partha commented on August 21, 2024

How about catching this exception and reconnect?

from python-sdk.

DevMiser avatar DevMiser commented on August 21, 2024

Can this be caught by the DisconnectCallbackHandler?
https://sinricpro.github.io/esp8266-esp32-sdk/class_sinric_pro_class.html#a654bb017ca55b448d55bb36e0346f38a
I'm not sure if this works in python.
Can you tell me how to convert the code example (SinricPro.onDisconnected({ Serial.printf("Disconnected from SinricPro\r\n"); });) into python?

from python-sdk.

thegoliathgeek avatar thegoliathgeek commented on August 21, 2024

@DevMiser sure I'll back to you on this.

from python-sdk.

DevMiser avatar DevMiser commented on August 21, 2024

I tried the following, but it did not work:

def onDisconnected(cb):
if cb == 'None':
print ("Disconnected from Sinric Pro")

callbacks = {
'powerState': onPowerState,
'Disconnected': onDisconnected
}

from python-sdk.

thegoliathgeek avatar thegoliathgeek commented on August 21, 2024

https://websockets.readthedocs.io/en/stable/intro.html?highlight=disconnect#producer

This will work. So I'll update this

from python-sdk.

DevMiser avatar DevMiser commented on August 21, 2024

I am now using this solution to reconnect automatically after being disconnected - using a while loop. When there is an error, it moves to the next lines in the code, which prints the time of the error, and then waits 20 minutes and runs the program again (by which time hopefully the ISP interruption or other cause of the error has been resolved). Here is the modification to the applicable portion of the code in the simple example:

if name == 'main':
while True:
client = SinricPro(appKey,deviceIdArr,callbacks,enable_log=False, restore_states=True, secretKey=secretKey)
udp_client = SinricProUdp(callbacks,deviceIdArr,enable_trace=False)
client.handle_all(udp_client)
print ("Disconnected from SinricPro at: %s" % time.ctime())
sleep(1200)
print ("Reconnection attempted at: %s" % time.ctime())

You may also need to add "import time" in a line before "from time import sleep" in the simple example.

from python-sdk.

buddydip avatar buddydip commented on August 21, 2024

https://websockets.readthedocs.io/en/stable/intro.html?highlight=disconnect#producer

This will work. So I'll update this

Hi @ImDhanush,
Have you updated the SDK as I am facing the same issue while using Python SDK for which I have sent you an email also.

Thanks,
Dipankar

from python-sdk.

buddydip avatar buddydip commented on August 21, 2024

I have stopped using Sinric Pro and switched to OpenHAB because of the above issue. I felt OpenHAB much better in features and stability and more powerful as the local installation is also provided as a package which can be setup only by simple config (installed in Raspberry Pi) and can work even without internet connection in a local network

from python-sdk.

thegoliathgeek avatar thegoliathgeek commented on August 21, 2024

@buddydip Sorry for the inconvenience. This existing python-sdk has many bugs. So am trying to rewrite the whole sdk. This might take some time. Thanks

from python-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.