tgalal / yowsup

The WhatsApp lib
GNU General Public License v3.0
7.07k stars 2.23k forks source link

nodeData remains None in layers/coder/decoder.py:268, crashes with TypeError exception #1530

Closed sattva1 closed 8 years ago

sattva1 commented 8 years ago

Hi,

I'm encountering the following issue while receiving some messages in a group (i'm running @jlguardi's fork, but it seems to behave the same as wa16 branch in this respect):

Traceback (most recent call last):
  File "<...>/whatsapp_bot/server.py", line 104, in start
    self.stack.loop(timeout=0.5, discrete=0.5)
  File "<...>/whatsapp_bot/yowsup/stacks/yowstack.py", line 187, in loop
    asyncore.loop(*args, **kwargs)
  File "/usr/lib64/python2.7/asyncore.py", line 216, in loop
    poll_fun(timeout, map)
  File "/usr/lib64/python2.7/asyncore.py", line 156, in poll
    read(obj)
  File "/usr/lib64/python2.7/asyncore.py", line 87, in read
    obj.handle_error()
  File "/usr/lib64/python2.7/asyncore.py", line 83, in read
    obj.handle_read_event()
  File "/usr/lib64/python2.7/asyncore.py", line 449, in handle_read_event
    self.handle_read()
  File "<...>/whatsapp_bot/yowsup/layers/network/layer.py", line 102, in handle_read
    self.receive(data)
  File "<...>/whatsapp_bot/yowsup/layers/network/layer.py", line 110, in receive
    self.toUpper(data)
  File "<...>/whatsapp_bot/yowsup/layers/__init__.py", line 75, in toUpper
    self.__upper.receive(data)
  File "<...>/whatsapp_bot/yowsup/layers/stanzaregulator/layer.py", line 29, in receive
    self.processReceived()
  File "<...>/whatsapp_bot/yowsup/layers/stanzaregulator/layer.py", line 49, in processReceived
    self.toUpper(oneMessageData)
  File "<...>/whatsapp_bot/yowsup/layers/__init__.py", line 75, in toUpper
    self.__upper.receive(data)
  File "<...>/whatsapp_bot/yowsup/layers/auth/layer_crypt.py", line 65, in receive
    self.toUpper(payload)
  File "<...>/whatsapp_bot/yowsup/layers/__init__.py", line 75, in toUpper
    self.__upper.receive(data)
  File "<...>/whatsapp_bot/yowsup/layers/coder/layer.py", line 33, in receive
    node = self.reader.getProtocolTreeNode(data)
  File "<...>/whatsapp_bot/yowsup/layers/coder/decoder.py", line 16, in getProtocolTreeNode
    return self.nextTreeInternal(data)
  File "<...>/whatsapp_bot/yowsup/layers/coder/decoder.py", line 252, in nextTreeInternal
    nodeChildren = self.readList(read2, data)
  File "<...>/whatsapp_bot/yowsup/layers/coder/decoder.py", line 276, in readList
    listx.append(self.nextTreeInternal(data))
  File "<...>/whatsapp_bot/yowsup/layers/coder/decoder.py", line 268, in nextTreeInternal
    nodeData = "".join(map(chr, nodeData))
TypeError: an integer is required

Filtering out Nones expectedly fixes the crash, but i don't think it's a proper way to tackle the issue.

sattva1 commented 8 years ago

The issue is easily reproducible with the yowsup-cli (from the current "develop" branch):

  1. Start the first instance and login to the WA network.
  2. Start the second instance and login to the WA network.
  3. The first instance crashes with the exception above.
sattva1 commented 8 years ago

If nodeData is filtered out of non-int items, the first yowsup-cli instance disconnects (without a crash) with the following message:

ERROR:yowsup.layers.interface.interface:Stream Error type: conflict
{'text': '', 'conflict': None}

INFO:yowsup.layers.interface.interface:Initiating reconnect
general: Disconnected: Requested
tgalal commented 8 years ago

@sattva1 Thanks for writing how to reproduce that error