Yowsup: Does not send image

Created on 25 Apr 2017  Â·  85Comments  Â·  Source: tgalal/yowsup

I am able to login to command line client.
/L shows Connected
/image send XXXXX /root/test/sample.jpg shows Sent.
but image is not delivered to target number, I am not able to figure out even after checking the debug log.

Have anybody faced such issue before?

All 85 comments

Hi, I'm going through the same thing too.

When I send to an android device the image arrives however for an iphone does not arrive, is there any problem?

Sorry for english, google translate

I'm the same problem. Some iphone's device receive the image other not.

Please, try with jpeg and also with png images.

@jlguardi I tried with jpeg and png but neither worked
I tried to send a video and audio but it returns me this error: AttributeError: type object 'DownloadableMediaMessageProtocolEntity' has no attribute 'fromFilePath'

I have the same problem

I updated whatsapp yesterday (iphone) to version 2.17.20

And now images sent by the bot do not arrive anymore

Same for geolocation

Same for newest Android Version

How can you solve it?

Could you provide debug logs with receipt, ack and read entities?

All looking normal, nothing fails.
But WhatsApp App isn't recieving anything.

Ack is not received when you send an image, because the recipient receives nothing

As if the message was not sent

@AragurDEV @langioletto The same happens to me, I do not get ack because the application did not receive anything. The log is perfect, I executed the example with -d and everything is normal

@tgalal

I tried with iPhone and WhatsApp 2.17.7 and everything works regularly.

The image and position sent by the bot are received regularly.

The problem is with the latest versions of whatsapp released a couple of days ago

With me just messages are coming in iphone version 2.17.20

You said that official app receives nothing. How do you know? Probably it receives an invalid message and discards it.

@jlguardi And how can we proceed? What can we do?

debug:

debugfile.txt

Guys, the current version (2.17.20) of whatsapp for iphone has changed the photo structure (I think), as it will allow grouping of images in the chat. Should be why it gives error when sending photo to whatsapp on iphone and android works normally. https://goo.gl/vVmpM5

The message are coming, but the images not. Any solution about this?

If you update whatzapp on android does not work anymore there

Geolocation also does not work!!!

Not just the pictures!!

What is your version of whatsapp on android? Because my version is up to date and working, I even opened the play store to see if it had an update

A friend of Mine tryed on Iphone (whatsapp version 2.17.11) and works. But 6 Iphones with 2.17.20 version dont receive the image. Only text.

WhatsApp 2.17.7 works

WhatsApp 2.17.146 It's my version in Android

@langioletto do you mean about the android ou iphone version? And @leogaletti thats version is work on android?

This version is working on Android

my debug, send to iphone in version 2.17.20:

debug.txt

So on the latest Android Beta 2.17.160 this feature is also not working.

I've been sending text only (decrypted) messages and it does not receive by Iphone Whatsapp version 2.17.20? Is there any solution to this? Appreciate if anyone could kindly share the codes if there is a solution to this issue.

Hey guys. I have tested that this error is only there when u use this Parameter "-M"
Without it works only for IOS. For Android i get the Message "Waiting for this Message..."

I updated my whatsapp to version 2.17.160 (android) and now it only works the messages. Any solution?

@fwmarcel

Where to remove parameter M?

@fwmarcel, here dont work without the "-M" parameter. Dont receive message on Android or iOS (whatsapp updated with last version)

IOS

If I kill whatsapp and send a picture from BOT I get the notification that I have received a new image

But when I open whatsapp in chat there is no new image

TRY

Kill whatsapp

/image send 44xxxxxxxxxxx /root/image.jpg

How can we figure out the possibly new message protocol? it seems to only affect multimedia messages, text seems to be fine, so it doesn't seem to be a complete overhaul of the protocol communication or structure
EDIT: the activity events seems to indicate the client reports the message as seen, could be that or whatsapp server doing it, but it seems to me that the message gets to the client and then it even tries to display it, but the incorrect structure causes it to not show it.

The exact same thing here. The notification comes but there is no image at all.
Using iPhone.

@CantuOSS maybe the structure for a received message is the same of a sent.
So, we could try log these messages and compare what's different.

This is the message the library is sending:

<message type="media" id="1234" to="[email protected]">
    <media type="image" mimetype="i" filehash="..." url="https://..." size="..." file="img.png" encoding="raw" width="100" height="100">
        ...binary data...
    </media>
</message>

And this is the message when an image is received:

<message from="[email protected]" type="media" id="1234" t="5678" notify="Sender Name">
    <enc mediatype="image" v="2" type="msg">
        ...binary data...
    </enc>
</message>

I'll try to tweak and send messages in this format and what happens next.

@mniak I was thinking the same thing, i'll try to send messages with the new iOS client and check the recieved structure and post it when i can

@mniak @CantuOSS please test some group messages with the new iOS and Android Client. I cant receive messages from yowsup client in group. In normal chats i can receive it. I use yowsup from console and start it with a python script without the Parameter -M. When i use it with this Parameter the iOS client recieve nothing.

This problem occurs with the latest version of Whatsapp, in IOS and Android. Any solution?

@victorgt26 we are trying to figure out the changes in the media messsaging structure. Until we can figure out the new structure there is no way to send other than text messages

@CantuOSS normal text messages in groups arent working now.

@fwmarcel ok, didn't know that, individual text messages are working tho

@CantuOSS yeah. Normal private text messages are working, but text messages in groups not

My pull request above enables echoing IMAGE messages.

i still can't display the message under updated whatsapp client.

please help me the same problem. the image send and dont receive in whatsapp version 2.17.19 and post.

same problem!!! please help

@CantuOSS Is there any news regarding the solution of this problem?

facing same issue, yowsup says image is sent.. but not received on the recipient side

So, sending or receiving images are not working in yowsup right now?

nope, not working, image is getting sent with no telltale signs of error in
the debugging output but the image never gets received

On Tue, May 30, 2017 at 4:42 PM, rodrigoorrego notifications@github.com
wrote:

2086 https://github.com/tgalal/yowsup/issues/2086

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/tgalal/yowsup/issues/2016#issuecomment-304846922, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AM1tEe0btqVqveQcvYpWe3KMwn1Tdm0Rks5r-_mfgaJpZM4NH68z
.

Images and all other media should be sent with protobuf protocol and encrypted instead of plain mode.
Otherwise, new official app will ignore media content.

Image send
how can i do to work??

2017-05-30 13:49 GMT-03:00 jlguardi notifications@github.com:

Images and all other media should be sent with protobuf protocol and
encrypted instead of plain mode.
Otherwise, new official app will ignore media content.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/tgalal/yowsup/issues/2016#issuecomment-304939071, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AbbxtLtmYLhqLJO2afOLTjf7uY_wxDUOks5r_EiNgaJpZM4NH68z
.

please @jlguardi can you instruct us (or send documentation) on how to do this?

thanks in advance :)

@jlguardi waiting for your help.

thanks

I could not send image using yowsup in python
While sending image there is no error but not received on device.

Follow code

def request_image_upload(self, imagePath):
self.filePath = imagePath # only for the sake of simplicity of example, shoudn't do this
requestUploadEntity = RequestUploadIqProtocolEntity("image", filePath=imagePath)
self.layer._sendIq(requestUploadEntity, self.on_request_upload_result, self.on_request_upload_error)

def onRequestUploadError(self, errorRequestUploadIqProtocolEntity, requestUploadIqProtocolEntity):
print("Error requesting upload url")

def onUploadSuccess(self, filePath, jid, url):
#convenience method to detect file/image attributes for sending, requires existence of 'pillow' library
entity = ImageDownloadableMediaMessageProtocolEntity.fromFilePath(filePath, url, None, to)
self.toLower(entity)

def onUploadError(self, filePath, jid, url):
print("Upload file failed!")

def on_request_upload_result(self, resultRequestUploadIqProtocolEntity, requestUploadIqProtocolEntity):

if resultRequestUploadIqProtocolEntity.duplicate:
    self.on_upload_success(
        self.filePath,
        None,
        resultRequestUploadIqProtocolEntity.getUrl()
    )
else:
    uploader = MediaUploader(
        self.messageProtocolEntity.getFrom(),
        self.layer.getOwnJid(),
        self.filePath,
        resultRequestUploadIqProtocolEntity.getUrl(),
        resultRequestUploadIqProtocolEntity.getResumeOffset(),
        self.on_upload_success,
        self.on_upload_error,
        self.on_upload_progress,
        async=False
    )
    uploader.start()

def on_request_upload_error(self, errorRequestUploadIqProtocolEntity, requestUploadIqProtocolEntity):
logging.error("Error requesting upload url")

def on_upload_success(self, filePath, jid, url):

# convenience method to detect file/image attributes for sending, requires existence of 'pillow' library
entity = ImageDownloadableMediaMessageProtocolEntity.fromFilePath(
    filePath,
    url,
    None,
    self.messageProtocolEntity.getFrom()
)
self.layer.toLower(entity)

def on_upload_error(self, filePath, jid, url):
logging.error("Upload file failed!")

def on_upload_progress(self, filePath, jid, url, progress):
pass

There is some more information here #2123

I have solved this problem.
It seems that the official Whatsapp client now delivers only encrypted media messages.
In layers/axolotl/layer_send.py you have to remove the conditions that prevents media messages being processed by the axolotl layer.
Look at the "send" and "processPlaintextNodeAndSend" functions and remove the "media" type check.
After that I am able to send media messages (images, location, ecc) successfully.

EDIT: in order to successfully send location messages you have to add the line
location_message.jpeg_thumbnail = b''
in "serializeLocationToProtobuf" function.

Thanks @emiliojazz - I'll take a look at it now as I've got the same issue as everyone else.

Any chance you could paste your code of those two functions here to make it clearer for anyone else with the same issue? Just so we're not removing/commenting out incorrect or additional code blocks there?

Thanks again!

I'm getting following error:
Error requesting upload url

Kindly you can have an example of the lines to comment or make?

Thank you

@AragurDEV

You can kindly tell me the lines commented?

Maybe I've solved the mistake

Error requesting upload url

Thanks

@mikesalmonuk This is the output of my git diff after the changes:

https://pastebin.com/bUnzRbbB

I have followed the advices of @jlguardi and here we go.
I'm not sure it this modifications can break compatibility with older clients, maybe it is the WhatsApp server that takes care of this? Needs further investigations.
As you will notice there is also some typo to be corrected ("degress" in place of "degrees", also reported in another issue)

Hi @mikesalmonuk

With your patch, the geolocation send has returned to work

But with the image I get the following error

Request upload for file /root/xxxxxx.jpg for [email protected] failed

You have some suggestion?

I use python2.7

Very thanks

Okay so debug log is returnung "Feature not Implemented (501)"

https://pastebin.com/6SsHG4v7

Hi with the hint of @emiliojazz I am able to upload the image.
Here is my diff:
https://pastebin.com/Kzb1ZVVP
However, I always get a HTTP 400 error code in mediauploader.py line 122

I hope this information helps. Do you have any suggestions?

Thanks!

Hello @Bennik2000 i changed my code and too have error in line 134 mediauploader.py

UPLOAD URL: https://mmg.whatsapp.net/u/f/0MuHpfkb3nHfO2WX9wDxJ1mAlyEABVWyYg2lDQ/AtZTttpJnYOstD0ZRNDWEgfKpTXlMnMrpVQFUHc7PvbT

SSL_SOCK:
HTTP/1.1 400 Bad Request
Content-Type: application/json
Date: Tue, 01 Aug 2017 14:58:41 GMT
Connection: close
Content-Length: 0

[connected]:[connected]:
4.png => 55628226@s.whatsapp.net, 2%
4.png => 55628226
@s.whatsapp.net, 27% app.net, 5%
4.png => 55628226@s.whatsapp.net, 43% app.net, 29%
4.png => 55628226
@s.whatsapp.net, 48%sapp.net, 46%
4.png => 55628226@s.whatsapp.net, 59% app.net, 51%
4.png => 55628226
@s.whatsapp.net, 97% app.net, 62%
lines102]: | 4.png => 55628226@s.whatsapp.net, 100%
[u'HTTP/1.1 400 Bad Request', u'Content-Type: application/json', u'Date: Tue, 01 Aug 2017 14:49:55 GMT', u'Connection: close', u'Content-Length: 0', u'']
ERROR:yowsup.layers.protocol_media.mediauploader:Error occured at transfer json data not found
Traceback (most recent call last):
File "/home/user/web/host/whatsapp/config/yowsup/layers/protocol_media/mediauploader.py", line 134, in run
raise Exception("json data not found")
Exception: json data not found
ERROR:yowsup.demos.cli.layer:Upload file /home/user/web/host/whatsapp/10102/img_send/4.png to https://mmg.whatsapp.net/u/f/sP86c5Iyg_30IEnfbfgbOVmAlRMABVWyQrOt7Q/AtZTttpJnYOstD0ZRNDWEgfKpTXlMnMrpVQFUHc7PvbT for 55628226
@s.whatsapp.net failed!
Data e Hora: Tue Aug 01 2017 11:49:49 GMT-0300 (-03)
Traceback most! Reconectando...
ERROR:yowsup.layers.protocol_media.mediauploader:Error occured at transfer json data not found
Traceback (most recent call last):
File "/home/user/web/host/whatsapp/config/yowsup/layers/protocol_media/mediauploader.py", line 134, in run
raise Exception("json data not found")
Exception: json data not found
ERROR:yowsup.demos.cli.layer:Upload file /home/user/web/host/whatsapp/10102/img_send/4.png to https://mmg.whatsapp.net/u/f/sP86c5Iyg_30IEnfbfgbOVmAlRMABVWyQrOt7Q/AtZTttpJnYOstD0ZRNDWEgfKpTXlMnMrpVQFUHc7PvbT for 55628226*@s.whatsapp.net failed!

Send image with yowsup mediauploader.py hBAOS is:

--zzXXzzYYzzXXzzQQ
Content-Disposition: form-data; name="to"

5562982**@s.whatsapp.net
--zzXXzzYYzzXXzzQQ
Content-Disposition: form-data; name="from"

556293**@s.whatsapp.net
--zzXXzzYYzzXXzzQQ
Content-Disposition: form-data; name="file"; filename="09dd8c2662b96ce14928333f055c5580.png"
Content-Type: image/png

Send image with WhatsappWeb is:

------WebKitFormBoundaryAhnsYgUAoXwL7s45
Content-Disposition: form-data; name="hash"

HC4tq0OCjBMrA3chb+/VPQ6cfa252G3ls5G7XSNw=
------WebKitFormBoundaryAhnsYgUAoXwL7s45
Content-Disposition: form-data; name="refs"

NYWVQNBnFAt5G3recOAWYiCU0=
jNa-5uY_0e9qwACga1nsDH3kk=
------WebKitFormBoundaryAhnsYgUAoXwL7s45
Content-Disposition: form-data; name="file"; filename="blob"
Content-Type: application/octet-stream

Have you ever tried to upload an encrypted image? I think that WA is checking if the uploaded file is a plain image and if this is the case, the upload will fail.

No, I didn't try to upload an encrypted image since I did not have enough time to dig deeper into this problem, sorry.

Any references how to encrypt a image?

same like decrypt. The whole image inclusive the header will be encrypted with AES

@dazzzl Do you have an example?

I will give this a try, but since I'm not at work right now it will take a moment

no, but it should be easy. Just look at the decryption. You need only the plain text, it is your image, and a random key.

@dazzzl which description?

Look at the deCRYption in the source files. Somwere the image is decrypted and look what is done there. Then the encryption _should_ be straight forward

This is the decrypt routine from jlguardi in message_media_downloadable.py
def decrypt(self, encimg, refkey):
derivative = HKDFv3().deriveSecrets(refkey, binascii.unhexlify(self.cryptKeys), 112)
parts = ByteUtil.split(derivative, 16, 32)
iv = parts[0]
cipherKey = parts[1]
e_img = encimg[:-10]
AES.key_size=128
cr_obj = AES.new(key=cipherKey,mode=AES.MODE_CBC,IV=iv)
return cr_obj.decrypt(e_img)

Where do I get the refkey from?

you have to generate a new random key ... or you can use a constant ... but that is not secure ;-)

Were you able to solve this issue?
I am still getting 400 bad request.

@dazzzl Did you got image send working?

See issue 2149
It's not solved yet, but coming.

Okay so the issue got fixed.
Just see: https://github.com/tgalal/yowsup/issues/2149#issuecomment-329210637

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ikuraj picture ikuraj  Â·  5Comments

rroqueCoddera picture rroqueCoddera  Â·  3Comments

cyberp1983 picture cyberp1983  Â·  3Comments

bzero picture bzero  Â·  4Comments

darode picture darode  Â·  4Comments