jlguardi / yowsup

The python WhatsApp library
http://www.openwhatsapp.org
GNU General Public License v3.0
42 stars 23 forks source link

Media send error when I have two phones running simultaneously #33

Closed sento93 closed 8 years ago

sento93 commented 8 years ago

Hi, I am creating an application in which I need more than one phone running at once, if I use only one works well but if put two, I get the following logs

[2016-03-31 14:54:48,020: ERROR/MainProcess] Error occured at transfer u'https://mmi707.whatsapp.net/d/AiJuO_CRbN6rqmcuAgWYCn6k37rpRRcNwtCJsyXiHdHW.jpg' has type <type 'unicode'>, but expected one of: (<type 'str'>,) Traceback (most recent call last): File "/home/sento/whats/yowsup/layers/protocol_media/mediauploader.py", line 138, in run self.successCallback(sourcePath, self.jid, result["url"]) File "/home/sento/whats/yowsup_celery/layer.py", line 184, in caption, samurai) File "/home/sento/whats/yowsup_celery/layer.py", line 79, in do_send_image self.toLower(entity) File "/home/sento/whats/yowsup/layers/init.py", line 79, in toLower self.lower.send(data) File "/home/sento/whats/yowsup/layers/__init.py", line 192, in send s.send(data) File "/home/sento/whats/yowsup/layers/init.py", line 130, in send send(entity) File "/home/sento/whats/yowsup/layers/protocol_media/layer.py", line 37, in sendMessageEntity self.entityToLower(entity) File "/home/sento/whats/yowsup/layers/init.py", line 134, in entityToLower self.toLower(entity.toProtocolTreeNode()) File "/home/sento/whats/yowsup/layers/init.py", line 79, in toLower self.__lower.send(data) File "/home/sento/whats/yowsup/layers/axolotl/layer.py", line 122, in send self.handlePlaintextNode(node) File "/home/sento/whats/yowsup/layers/axolotl/layer.py", line 190, in handlePlaintextNode messageData = self.serializeToProtobuf(node) if v2 else node.getChild("body").getData() File "/home/sento/whats/yowsup/layers/axolotl/layer.py", line 502, in serializeToProtobuf return self.serializeMediaToProtobuf(node.getChild("media")) File "/home/sento/whats/yowsup/layers/axolotl/layer.py", line 514, in serializeMediaToProtobuf return self.serializeImageToProtobuf(mediaNode) File "/home/sento/whats/yowsup/layers/axolotl/layer.py", line 547, in serializeImageToProtobuf image_message.url = mediaNode["url"] File "/usr/local/lib/python2.7/dist-packages/google/protobuf/internal/python_message.py", line 471, in field_setter self._fields[field] = type_checker.CheckValue(new_value) File "/usr/local/lib/python2.7/dist-packages/google/protobuf/internal/type_checkers.py", line 103, in CheckValue raise TypeError(message) TypeError: u'https://mmi707.whatsapp.net/d/AiJuO_CRbN6rqmcuAgWYCn6k37rpRRcNwtCJsyXiHdHW.jpg' has type <type 'unicode'>, but expected one of: (<type 'str'>,) [2016-03-31 14:54:48,022: ERROR/MainProcess] Upload file /home/sento/whats/media/send/DSC00967.JPG to https://mmi707.whatsapp.net/u/mwMTnqR-mJOHhIlGCA7MC_5CsABS9Xv3oAMQ/AiJuO_CRbN6rqmcuAgWYCn6k37rpRRcNwtCJsyXiHdHW for 34XXXXXXXXX@s.whatsapp.net failed!

[2016-03-31 15:15:19,621: ERROR/MainProcess] Error occured at transfer Message com.whatsapp.proto.Message is missing req uired fields: image_message.media_key Traceback (most recent call last): File "/home/sento/whats/yowsup/layers/protocol_media/mediauploader.py", line 138, in run self.successCallback(sourcePath, self.jid, result["url"]) File "/home/sento/whats/yowsup_celery/layer.py", line 184, in caption, samurai) File "/home/sento/whats/yowsup_celery/layer.py", line 79, in do_send_image self.toLower(entity) File "/home/sento/whats/yowsup/layers/init.py", line 79, in toLower self.lower.send(data) File "/home/sento/whats/yowsup/layers/__init.py", line 192, in send s.send(data) File "/home/sento/whats/yowsup/layers/init.py", line 130, in send send(entity) File "/home/sento/whats/yowsup/layers/protocol_media/layer.py", line 37, in sendMessageEntity self.entityToLower(entity) File "/home/sento/whats/yowsup/layers/init.py", line 134, in entityToLower self.toLower(entity.toProtocolTreeNode()) File "/home/sento/whats/yowsup/layers/init.py", line 79, in toLower self.__lower.send(data) File "/home/sento/whats/yowsup/layers/axolotl/layer.py", line 122, in send self.handlePlaintextNode(node) File "/home/sento/whats/yowsup/layers/axolotl/layer.py", line 190, in handlePlaintextNode messageData = self.serializeToProtobuf(node) if v2 else node.getChild("body").getData() File "/home/sento/whats/yowsup/layers/axolotl/layer.py", line 502, in serializeToProtobuf return self.serializeMediaToProtobuf(node.getChild("media")) File "/home/sento/whats/yowsup/layers/axolotl/layer.py", line 514, in serializeMediaToProtobuf return self.serializeImageToProtobuf(mediaNode) File "/home/sento/whats/yowsup/layers/axolotl/layer.py", line 557, in serializeImageToProtobuf return m.SerializeToString() File "/usr/local/lib/python2.7/dist-packages/google/protobuf/internal/python_message.py", line 813, in SerializeToString self.DESCRIPTOR.full_name, ','.join(self.FindInitializationErrors()))) EncodeError: Message com.whatsapp.proto.Message is missing required fields: image_message.media_key [2016-03-31 15:15:19,623: ERROR/MainProcess] Upload file /home/sento/whats/media/send/DSCI0001.JPG to https://mmi747.whatsapp.net/u/0fwyKIo4RhNwghc_LRsNev3BIABS9YCfGqsg/AtEgyqeo7qdFHpPqQEOFfd7bnykSRez6KM3CmoXpmuGt for 34XXXXXXXXX@s.whatsapp.net failed!

Any idea how to fix it?? Thanks

daemonserj commented 8 years ago

I workaround it just do str(url)

sento93 commented 8 years ago

If I put it I get the second log

daemonserj commented 8 years ago

yeah, I getting "image_message.media_key" error too, it seems ImageDownloadableMediaMessageProtocolEntity.fromFilePath somehow changed ...

antoniespinosa commented 8 years ago

I have the same problem when I'm running a single phone its ok, but when i run 2 phones simultaneously only works one phone, the other gets this error

[2016-03-31 17:48:57,694: WARNING/MainProcess] Traceback (most recent call last): [2016-03-31 17:48:57,694: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup_celery/stack.py", line 68, in asynloop [2016-03-31 17:48:57,694: WARNING/MainProcess] asyncore.loop(timeout) [2016-03-31 17:48:57,694: WARNING/MainProcess] File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 216, in loop [2016-03-31 17:48:57,695: WARNING/MainProcess] poll_fun(timeout, map) [2016-03-31 17:48:57,695: WARNING/MainProcess] File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 156, in poll [2016-03-31 17:48:57,695: WARNING/MainProcess] read(obj) [2016-03-31 17:48:57,695: WARNING/MainProcess] File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 87, in read [2016-03-31 17:48:57,695: WARNING/MainProcess] obj.handle_error() [2016-03-31 17:48:57,695: WARNING/MainProcess] File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 83, in read [2016-03-31 17:48:57,696: WARNING/MainProcess] obj.handle_read_event() [2016-03-31 17:48:57,696: WARNING/MainProcess] File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/asyncore.py", line 449, in handle_read_event [2016-03-31 17:48:57,696: WARNING/MainProcess] self.handle_read() [2016-03-31 17:48:57,696: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup/layers/network/layer.py", line 88, in handle_read [2016-03-31 17:48:57,696: WARNING/MainProcess] self.receive(data) [2016-03-31 17:48:57,696: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup/layers/network/layer.py", line 96, in receive [2016-03-31 17:48:57,696: WARNING/MainProcess] self.toUpper(data) [2016-03-31 17:48:57,696: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup/layers/init.py", line 75, in toUpper [2016-03-31 17:48:57,697: WARNING/MainProcess] self.upper.receive(data) [2016-03-31 17:48:57,697: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup/layers/stanzaregulator/layer.py", line 29, in receive [2016-03-31 17:48:57,697: WARNING/MainProcess] self.processReceived() [2016-03-31 17:48:57,697: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup/layers/stanzaregulator/layer.py", line 49, in processReceived [2016-03-31 17:48:57,697: WARNING/MainProcess] self.toUpper(oneMessageData) [2016-03-31 17:48:57,697: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup/layers/__init.py", line 75, in toUpper [2016-03-31 17:48:57,697: WARNING/MainProcess] self.upper.receive(data) [2016-03-31 17:48:57,697: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup/layers/auth/layer_crypt.py", line 65, in receive [2016-03-31 17:48:57,698: WARNING/MainProcess] self.toUpper(payload) [2016-03-31 17:48:57,698: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup/layers/__init.py", line 75, in toUpper [2016-03-31 17:48:57,698: WARNING/MainProcess] self.upper.receive(data) [2016-03-31 17:48:57,698: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup/layers/coder/layer.py", line 35, in receive [2016-03-31 17:48:57,698: WARNING/MainProcess] self.toUpper(node) [2016-03-31 17:48:57,698: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup/layers/__init.py", line 75, in toUpper [2016-03-31 17:48:57,698: WARNING/MainProcess] self.upper.receive(data) [2016-03-31 17:48:57,699: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup/layers/logger/layer.py", line 14, in receive [2016-03-31 17:48:57,699: WARNING/MainProcess] self.toUpper(data) [2016-03-31 17:48:57,699: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup/layers/__init.py", line 75, in toUpper [2016-03-31 17:48:57,699: WARNING/MainProcess] self.upper.receive(data) [2016-03-31 17:48:57,699: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup/layers/axolotl/layer.py", line 141, in receive [2016-03-31 17:48:57,700: WARNING/MainProcess] self.toUpper(protocolTreeNode) [2016-03-31 17:48:57,700: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup/layers/__init.py", line 75, in toUpper [2016-03-31 17:48:57,700: WARNING/MainProcess] self.upper.receive(data) [2016-03-31 17:48:57,700: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup/layers/__init.py", line 188, in receive [2016-03-31 17:48:57,700: WARNING/MainProcess] s.receive(data) [2016-03-31 17:48:57,700: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup/layers/init.py", line 120, in receive [2016-03-31 17:48:57,701: WARNING/MainProcess] if not self.processIqRegistry(node): [2016-03-31 17:48:57,701: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup/layers/init.py", line 155, in processIqRegistry [2016-03-31 17:48:57,701: WARNING/MainProcess] successClbk(protocolTreeNode, originalIq) [2016-03-31 17:48:57,701: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup/layers/protocol_media/layer.py", line 78, in onRequestUploadSuccess [2016-03-31 17:48:57,701: WARNING/MainProcess] self.toUpper(ResultRequestUploadIqProtocolEntity.fromProtocolTreeNode(resultNode)) [2016-03-31 17:48:57,701: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup/layers/init.py", line 75, in toUpper [2016-03-31 17:48:57,701: WARNING/MainProcess] self.upper.receive(data) [2016-03-31 17:48:57,701: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup/layers/interface/interface.py", line 75, in receive [2016-03-31 17:48:57,702: WARNING/MainProcess] if not self.processIqRegistry(entity): [2016-03-31 17:48:57,702: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup/layers/interface/interface.py", line 54, in processIqRegistry [2016-03-31 17:48:57,702: WARNING/MainProcess] successClbk(entity, originalIq) [2016-03-31 17:48:57,702: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup_celery/layer.py", line 253, in [2016-03-31 17:48:57,702: WARNING/MainProcess] original_entity, caption, samurai) [2016-03-31 17:48:57,702: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup_celery/layer.py", line 180, in on_request_upload_result [2016-03-31 17:48:57,702: WARNING/MainProcess] result_request_upload_iq_protocol_entity.getIp(), caption, samurai) [2016-03-31 17:48:57,703: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup_celery/layer.py", line 79, in do_send_image [2016-03-31 17:48:57,703: WARNING/MainProcess] self.toLower(entity) [2016-03-31 17:48:57,703: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup/layers/__init.py", line 79, in toLower [2016-03-31 17:48:57,703: WARNING/MainProcess] self.lower.send(data) [2016-03-31 17:48:57,703: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup/layers/__init.py", line 192, in send [2016-03-31 17:48:57,703: WARNING/MainProcess] s.send(data) [2016-03-31 17:48:57,703: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup/layers/init.py", line 130, in send [2016-03-31 17:48:57,703: WARNING/MainProcess] send(entity) [2016-03-31 17:48:57,703: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup/layers/protocol_media/layer.py", line 37, in sendMessageEntity [2016-03-31 17:48:57,703: WARNING/MainProcess] self.entityToLower(entity) [2016-03-31 17:48:57,703: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup/layers/init.py", line 134, in entityToLower [2016-03-31 17:48:57,704: WARNING/MainProcess] self.toLower(entity.toProtocolTreeNode()) [2016-03-31 17:48:57,704: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup/layers/init.py", line 79, in toLower [2016-03-31 17:48:57,704: WARNING/MainProcess] self.*lower.send(data) [2016-03-31 17:48:57,704: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup/layers/axolotl/layer.py", line 122, in send [2016-03-31 17:48:57,704: WARNING/MainProcess] self.handlePlaintextNode(node) [2016-03-31 17:48:57,704: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup/layers/axolotl/layer.py", line 190, in handlePlaintextNode [2016-03-31 17:48:57,704: WARNING/MainProcess] messageData = self.serializeToProtobuf(node) if v2 else node.getChild("body").getData() [2016-03-31 17:48:57,704: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup/layers/axolotl/layer.py", line 457, in serializeToProtobuf [2016-03-31 17:48:57,704: WARNING/MainProcess] return self.serializeMediaToProtobuf(node.getChild("media")) [2016-03-31 17:48:57,704: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup/layers/axolotl/layer.py", line 469, in serializeMediaToProtobuf [2016-03-31 17:48:57,705: WARNING/MainProcess] return self.serializeImageToProtobuf(mediaNode) [2016-03-31 17:48:57,705: WARNING/MainProcess] File "/Users/girien/Documents/test/yowsup/layers/axolotl/layer.py", line 512, in serializeImageToProtobuf [2016-03-31 17:48:57,705: WARNING/MainProcess] return m.SerializeToString() [2016-03-31 17:48:57,705: WARNING/MainProcess] File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/google/protobuf/internal/python_message.py", line 1063, in SerializeToString [2016-03-31 17:48:57,705: WARNING/MainProcess] self.DESCRIPTOR.full_name, ','.join(self.FindInitializationErrors()))) [2016-03-31 17:48:57,705: WARNING/MainProcess] EncodeError: Message com.whatsapp.proto.Message is missing required fields: image_message.media_key [2016-03-31 17:48:57,706: ERROR/MainProcess] Task wakizashi.yowsup_celery.tasks.listen[27eedf12-9efa-4359-b6dc-73d9fc559905] raised unexpected: UnexpectedError("<class 'google.protobuf.message.EncodeError'>",) Traceback (most recent call last): File "/usr/local/lib/python2.7/site-packages/celery/app/trace.py", line 240, in trace_task R = retval = fun(_args, _kwargs) File "/usr/local/lib/python2.7/site-packages/celery/app/trace.py", line 438, in __protected_call* return self.run(_args, _kwargs) File "/Users/girien/Documents/test/yowsup_celery/tasks.py", line 33, in listen return self.stack.asynloop() File "/Users/girien/Documents/test/yowsup_celery/stack.py", line 90, in asynloop raise exceptions.UnexpectedError(str(exc_info[0])) UnexpectedError: <class 'google.protobuf.message.EncodeError'>

daemonserj commented 8 years ago

strange, that I have this issue with just one application running

antoniespinosa commented 8 years ago

In my case probably its a celery problem (I run yowsup from celery) any idea?

jlguardi commented 8 years ago

Th cause isn't it two lines. The cause is that media encryption isn't full tested and obviously, there is a bug. Disable media encryption by now (edit axolotl/layer.py)

sento93 commented 8 years ago

Sorry. What I have to change in axolotl/leyer to disable encryption? Another thing , if I only start celery looks good but fails whith django started.

jlguardi commented 8 years ago

Media encryption is already disabled in master. Update your code and should work.