0

sendMessage を使用して url から json コンテンツをクライアントに送信しようとしています。

def broadcast(self):
  response = urllib2.urlopen('http://localhost:8001/json?as_text=1')
  data = json.load(response)

  for c in self.clients:
     c.sendMessage(data)

エラーが発生します

File "myServer.py", line 63, in broadcast
c.sendMessage(data)
File "/Library/Python/2.7/site-packages/autobahn-0.6.3-py2.7.egg/autobahn    /websocket.py",     line 2605, in sendMessage
self.sendMessageHybi(payload, binary, payload_frag_size, sync, doNotCompress)
  File "/Library/Python/2.7/site-packages/autobahn-0.6.3-py2.7.egg/autobahn    /websocket.py", line 2671, in sendMessageHybi
    self.sendFrame(opcode = opcode, payload = payload, sync = sync, rsv = 4 if     sendCompressed else 0)
  File "/Library/Python/2.7/site-packages/autobahn-0.6.3-py2.7.egg/autobahn/websocket.py", line 2161, in sendFrame
raw = ''.join([chr(b0), chr(b1), el, mv, plm])
exceptions.TypeError: sequence item 4: expected string, dict found
4

1 に答える 1