vshymanskyy / blynk-library-python

Blynk library for Python. Works with Python 2, Python 3, MicroPython.
https://blynk.io/
MIT License
281 stars 97 forks source link

App keeps on crashing when mobile app was opened or force closed. #30

Closed newrad closed 5 years ago

newrad commented 5 years ago

App keeps on crashing when I'm opening or force closing the Blynk mobile app where the sample Blynk python code is pointing to. No issue on running the app when the Blynk mobile app is already open.

Running the code using python2 or python3 is giving the same result. Same error when running lower version of Blynk server (used v0.41.0 or v0.41.0-1). No issue with my nodejs code using the same platform(I know python library is beta release).

The blynk app is running on Raspberry Pi with Raspbian Stretch Lite and connected to Blynk server v0.41.0-2 running on Ubuntu Server 18.04.2 LTS. Using Blynk v2.25.0 for IOS for control.


UPDATE: For now I was able to temporary bypass the error when I modify below lines in the BlynkLib.py.

            elif cmd == MSG_INTERNAL:
                try:
                    self.emit("int_"+args[1], args[2:])
                except:
                    pass

CODE: import BlynkLib import time blynk = BlynkLib.Blynk('568d2xxxxxxxxxxxxxxxxxxaadd', server='192.168.xx.xx', port=8080, heartbeat = 30) @blynk.VIRTUAL_WRITE(0) def v0_write_handler(value): print('Current V0 value: {}'.format(value)) @blynk.VIRTUAL_READ(1) def v1_read_handler(): blynk.virtual_write(1, int(time.time())) while True: blynk.run()


ERROR LOG: Traceback (most recent call last): File "testblynk.py", line 18, in blynk.run() File "/usr/local/lib/python3.5/dist-packages/BlynkLib.py", line 252, in run self.process(data) File "/usr/local/lib/python3.5/dist-packages/BlynkLib.py", line 213, in process self.emit("int_"+args[1], args[2:]) IndexError: list index out of range

jsikorsky commented 5 years ago

Confirm this, proposed fix #31 . I'm new to git VCS, so I hope the procedure is correct.

newrad commented 5 years ago

The proposed fix did resolve the issue. Thanks.

xjnIII commented 2 years ago

You can comment out these lines to solve the problem (/home/pi/.local/lib/python3.7/site-packages/BlynkLib.py) line 213

elif cmd == MSG_INTERNAL:

self.emit(“int_”+args[1], args[2:])

else: print("Unexpected command: ", cmd)

return self.disconnect()