Comments (17)
Awesome. Thank you. It would be great to see this written into the Pro Switch example code.
from python-sdk.
can you please help me to add code to re-connect automatically when disconnected.
from python-sdk.
Might maybe problem with ISP! Try in mobile hotspot once!
from python-sdk.
i'm using jio hotspot. It disconnects after a certain random amount of time. websocket connection is not consistent.
from python-sdk.
I faced this error too.
Try in different ISP.
from python-sdk.
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.
Can I try removing ping interval and ping timeout as stated below
from python-sdk.
Not an optional solution. If you remove ping. Maintaining a live connection will be lost.
from python-sdk.
How about catching this exception and reconnect?
from python-sdk.
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.
@DevMiser sure I'll back to you on this.
from python-sdk.
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.
https://websockets.readthedocs.io/en/stable/intro.html?highlight=disconnect#producer
This will work. So I'll update this
from python-sdk.
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.
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.
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.
@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)
- CPU 100% busy on Raspberry HOT 11
- Example Read Temperature
- Error runing with websocket client HOT 3
- Cant get the sdk to run HOT 5
- Multiple range instances HOT 3
- Error on RaiseEvent setBrightness HOT 1
- immediately disconnects on enigma2 HOT 12
- ImportError: no module named 'SinricPro' HOT 1
- Connection to server lost HOT 2
- Python example HOT 2
- Websocket asyncio blocked on recv()
- Connect to sockets using env
- Actions as class methods HOT 4
- Typo in _sinricpro_constants.py HOT 1
- Energy Monitoring Sensor Python Example HOT 2
- Python example using websocket HOT 5
- Connection with Server Closed HOT 1
- New release? HOT 2
- Porting to Micropython HOT 9
- Missing dependency on setuptools HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-sdk.