json.decoder.JSONDecodeError: Unterminated string starting at: line 1 column 1021 (char 1020)
Closed this issue · 6 comments
rjsears commented
Hello -
Just wanted to let you know that I was receiving this error while talking to a TP-Link HS300:
json.decoder.JSONDecodeError: Unterminated string starting at: line 1 column 1021 (char 1020)
I was able to correct the issue by changing line 211 from this:
data, server = client_socket.recvfrom(1024)
to this:
data, server = client_socket.recvfrom(2048)
p-doyle commented
Can you send an example of what the raw message was? Its an easy update, just not something I encountered during my testing so I'm curious.
rjsears commented
You bet -
here it is:
Traceback (most recent call last):
File "/var/www/fish_tank_control/tank_control/tank_control_master.py",
line 25, in <module>
import power_strip
File "/var/www/fish_tank_control/tank_control/utilities/power_strip.py",
line 13, in <module>
power_strip = SmartPowerStrip(system_info.tank_name)
File
"/var/www/fish_tank_control/tank_control/utilities/KasaSmartPowerStrip.py",
line 19, in __init__
sys_info = self.get_system_info()
File
"/var/www/fish_tank_control/tank_control/utilities/KasaSmartPowerStrip.py",
line 44, in get_system_info
return self._udp_send_command('{"system":{"get_sysinfo":{}}}')
File
"/var/www/fish_tank_control/tank_control/utilities/KasaSmartPowerStrip.py",
line 213, in _udp_send_command
return json.loads(self._decrypt_command(data))
File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.6/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.6/json/decoder.py", line 355, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Unterminated string starting at: line 1
column 1021 (char 1020)
Process finished with exit code 1
Richard J. Sears
ATP ASMEL/Rotor, CFI, CFII, MEI
G-V / CE-525S / CE-500 / S-70
…On Sat, Feb 29, 2020 at 5:12 PM p-doyle ***@***.***> wrote:
Can you send an example of what the raw message was? Its an easy update,
just not something I encountered during my testing so I'm curious.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#3?email_source=notifications&email_token=ADB6CT3C6BGUNVZAMUZVCODRFGR5NA5CNFSM4K645IGKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENMJQCY#issuecomment-593008651>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADB6CT3OI5U4YGNFD5GA6TLRFGR5NANCNFSM4K645IGA>
.
p-doyle commented
Oh sorry I mean the message that came in from the HS300. Wondering what caused the increased length from what I've seen in the past.
rjsears commented
Absolutely, but not really sure what you are looking for - I am not getting
anything back at all from the power strip on the console. How can I grab
that info for you?
root@scripts:~/kasa_power_strip# python3
Python 3.6.9 (default, Nov 7 2019, 10:44:02)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>> from KasaSmartPowerStrip import SmartPowerStrip
>> power_strip = SmartPowerStrip('75planted')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/root/kasa_power_strip/KasaSmartPowerStrip.py", line 19, in __init__
sys_info = self.get_system_info()
File "/root/kasa_power_strip/KasaSmartPowerStrip.py", line 44, in
get_system_info
return self._udp_send_command('{"system":{"get_sysinfo":{}}}')
File "/root/kasa_power_strip/KasaSmartPowerStrip.py", line 213, in
_udp_send_command
return json.loads(self._decrypt_command(data))
File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.6/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.6/json/decoder.py", line 355, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Unterminated string starting at: line 1
column 1021 (char 1020)
>>
Richard J. Sears
ATP ASMEL/Rotor, CFI, CFII, MEI
G-V / CE-525S / CE-500 / S-70
…On Mon, Mar 2, 2020 at 12:17 PM p-doyle ***@***.***> wrote:
Oh sorry I mean the message that came in from the HS300. Wondering what
caused the increased length from what I've seen in the past.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#3?email_source=notifications&email_token=ADB6CT6MD6N4Q4TGKYIPLYLRFQA3NA5CNFSM4K645IGKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENQSSLI#issuecomment-593570093>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADB6CT4JUEEP6XJOTGIVA7DRFQA3NANCNFSM4K645IGA>
.
p-doyle commented
Ah nevermind, don't worry about it. I've updated the code.
Thanks for reporting!
rjsears commented
No problem at all, thanks for your great code :-)
Richard J. Sears
ATP ASMEL/Rotor, CFI, CFII, MEI
G-V / CE-525S / CE-500 / S-70
…On Mon, Mar 2, 2020 at 12:32 PM p-doyle ***@***.***> wrote:
Ah nevermind, don't worry about it. I've updated the code.
Thanks for reporting!
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#3?email_source=notifications&email_token=ADB6CT7Z65OBMYOSTVK3AR3RFQCU3A5CNFSM4K645IGKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENQUJII#issuecomment-593577121>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADB6CT6XLGA34FQV37MX3GTRFQCU3ANCNFSM4K645IGA>
.