tgalal / yowsup

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

Exception if message is sent directly to the number configured with Yowsup #1103

Closed idigevian closed 5 years ago

idigevian commented 9 years ago

Hi,

I am having a weird problem. I am getting an exception, if a message is sent only to the number which is configured in Yowsup. However, if this number is a part of a group then the message is correctly received. Also, the message is received correctly if i start the command line yowsup client.

I have copied-pasted the code verbatim for the Sample Application as given on the following link: https://github.com/tgalal/yowsup/wiki/Sample-Application

The exception i am getting is:

Traceback (most recent call last): File "/Users/vishalmudgal/Documents/workspace/primality/WhatsApp-Test/com/run.py", line 31, in stack.loop() #this is the program mainloop File "build/bdist.macosx-10.6-intel/egg/yowsup/stacks/yowstack.py", line 195, in loop File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 214, in loop poll_fun(timeout, map) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 155, in poll read(obj) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 87, in read obj.handle_error() File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 83, in read obj.handle_read_event() File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 442, in handle_read_event self.handle_read() File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/network/layer.py", line 86, in handle_read

File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/network/layer.py", line 94, in receive

File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/init.py", line 59, in toUpper

File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/stanzaregulator/layer.py", line 28, in receive

File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/stanzaregulator/layer.py", line 48, in processReceived

File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/init.py", line 59, in toUpper

File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/auth/layer_crypt.py", line 63, in receive File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/init.py", line 59, in toUpper

File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/coder/layer.py", line 35, in receive

File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/init.py", line 59, in toUpper

File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/logger/layer.py", line 14, in receive print "From: %s. Message: %s. Participant: %s" %(messageProtocolEntity.getFrom(), messageProtocolEntity.getBody(), messageProtocolEntity.getParticipant()) File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/init.py", line 59, in toUpper

File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/init.py", line 169, in receive

File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/init.py", line 105, in receive

File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/protocol_messages/layer.py", line 20, in recvMessageStanza self.toLower(receipt) File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/protocol_messages/protocolentities/message_text.py", line 38, in fromProtocolTreeNode

AttributeError: 'NoneType' object has no attribute 'getData'

Can you let me know what might be going wrong here ?

Thanks!

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

idigevian commented 9 years ago

Got the following posts: -https://github.com/tgalal/yowsup/issues/595; & -https://github.com/tgalal/yowsup/issues/690

And i added the YowAxolotlLayer as below:

layers = (
    EchoLayer,
    (YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, YowAckProtocolLayer),        
    YowAxolotlLayer,
) + YOWSUP_CORE_LAYERS

Now, when i run, i get the below exception:

Traceback (most recent call last): File "/Users/vishalmudgal/Documents/workspace/primality/WhatsApp-Test/com/run.py", line 33, in stack.loop() #this is the program mainloop File "build/bdist.macosx-10.6-intel/egg/yowsup/stacks/yowstack.py", line 195, in loop File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 214, in loop poll_fun(timeout, map) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 155, in poll read(obj) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 87, in read obj.handle_error() File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 83, in read obj.handle_read_event() File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 442, in handle_read_event self.handle_read() File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/network/layer.py", line 86, in handle_read

File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/network/layer.py", line 94, in receive

File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/init.py", line 59, in toUpper

File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/stanzaregulator/layer.py", line 28, in receive

File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/stanzaregulator/layer.py", line 48, in processReceived

File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/init.py", line 59, in toUpper

File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/auth/layer_crypt.py", line 63, in receive File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/init.py", line 59, in toUpper

File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/coder/layer.py", line 35, in receive

File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/init.py", line 59, in toUpper

File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/logger/layer.py", line 14, in receive print "From: %s. Message: %s. Participant: %s" %(messageProtocolEntity.getFrom(), messageProtocolEntity.getBody(), messageProtocolEntity.getParticipant()) File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/init.py", line 59, in toUpper

File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/axolotl/layer.py", line 117, in receive

File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/axolotl/layer.py", line 139, in onMessage

File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/axolotl/layer.py", line 222, in handleEncMessage

File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/axolotl/layer.py", line 259, in handlePreKeyWhisperMessage

File "/Library/Python/2.7/site-packages/axolotl/sessioncipher.py", line 90, in decryptPkmsg sessionRecord = self.sessionStore.loadSession(self.recipientId, self.deviceId) File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/axolotl/store/sqlite/liteaxolotlstore.py", line 47, in loadSession File "build/bdist.macosx-10.6-intel/egg/yowsup/layers/axolotl/store/sqlite/litesessionstore.py", line 20, in loadSession File "/Library/Python/2.7/site-packages/axolotl/state/sessionrecord.py", line 16, in init record.ParseFromString(serialized) File "/Library/Python/2.7/site-packages/google/protobuf/message.py", line 186, in ParseFromString self.MergeFromString(serialized) File "/Library/Python/2.7/site-packages/google/protobuf/internal/python_message.py", line 859, in MergeFromString if self._InternalParse(serialized, 0, length) != length: File "/Library/Python/2.7/site-packages/google/protobuf/internal/python_message.py", line 892, in InternalParse pos = field_decoder(buffer, new_pos, end, self, field_dict) File "/Library/Python/2.7/site-packages/google/protobuf/internal/decoder.py", line 652, in DecodeField raise _DecodeError('Truncated message.')

google.protobuf.message.DecodeError: Truncated message.

idigevian commented 9 years ago

So what i am trying to understand is, if the command line yowsup client is able to receive the message successfully, then what am i missing in the Python code on my machine.

idigevian commented 9 years ago

@tgalal Hi Tarek, bringing it to your attention.

Thanks!

kartikgola commented 8 years ago

@idigevian Hi! Did you find a workaround to this problem? I'm using python 3.5.2 and yowsup 2.5.0

deacix commented 8 years ago

You need to enabled encryption or do not disable with "-M".

xXcoronaXx commented 7 years ago

@idigevian @kartikgola Hi! Did you find a workaround to this problem?