whatsapp-framework icon indicating copy to clipboard operation
whatsapp-framework copied to clipboard

Unable to send image

Open shubhamparamhans opened this issue 6 years ago • 11 comments

I used send_image function to send image but was getting 0% progress in progress listener. After debugging inside MediaUploader i was getting error [u'HTTP/1.1 400 Bad Request', u'Content-Type: application/json', u'Date: Mon, 09 Apr 2018 10:51:38 GMT', u'Connection: close', u'Content-Length: 0', u''] Is anyone else facing same issue?

shubhamparamhans avatar Apr 09 '18 10:04 shubhamparamhans

to help you please send your code. i have use send_image and not find any problem. thanks

natrya avatar Apr 25 '18 05:04 natrya

Did you make to get this resolved? Sending images hasn't been working for me too for a long time now. I hear this fork https://github.com/AragurDEV/yowsup managed to fix the image sending issues but may be incompatible with this framework

LabtronicsDesign avatar May 18 '18 23:05 LabtronicsDesign

I was looking at this repo yesterday, i have seen someone commented that they have also implemented reply feature. I think i should checkout there code and see if can find something interesting.

shubhamparamhans avatar May 19 '18 07:05 shubhamparamhans

my working code is like this.

            mac.send_image('app/assets/images/'+gambar, message.conversation, caption=isi)

natrya avatar May 19 '18 09:05 natrya

I have implemented the https://github.com/AragurDEV/yowsup Fork and managed to get text messages working. Images still dont work but i get a different traceback message this time:

[Whatsapp] Mac started

Error occured at transfer object of type 'int' has no len()
Traceback (most recent call last):
  File "D:\ProgramData\Anaconda3\lib\http\client.py", line 986, in send
    self.sock.sendall(data)
  File "D:\ProgramData\Anaconda3\lib\site-packages\urllib3\contrib\pyopenssl.py", line 316, in sendall
    sent = self._send_until_done(data[total_sent:total_sent + SSL_WRITE_BLOCKSIZE])
  File "D:\ProgramData\Anaconda3\lib\site-packages\urllib3\contrib\pyopenssl.py", line 304, in _send_until_done
    return self.connection.send(data)
  File "D:\ProgramData\Anaconda3\lib\site-packages\OpenSSL\SSL.py", line 1625, in send
    raise TypeError("data must be a memoryview, buffer or byte string")
TypeError: data must be a memoryview, buffer or byte string

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\ProgramData\Anaconda3\lib\site-packages\yowsup2-2.5.7-py3.6.egg\yowsup\layers\protocol_media\mediauploader.py", line 153, in run
    response = requests.post(uploadUrl, data=data, headers=headers)
  File "D:\ProgramData\Anaconda3\lib\site-packages\requests\api.py", line 112, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "D:\ProgramData\Anaconda3\lib\site-packages\requests\api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "D:\ProgramData\Anaconda3\lib\site-packages\requests\sessions.py", line 508, in request
    resp = self.send(prep, **send_kwargs)
  File "D:\ProgramData\Anaconda3\lib\site-packages\requests\sessions.py", line 618, in send
    r = adapter.send(request, **kwargs)
  File "D:\ProgramData\Anaconda3\lib\site-packages\requests\adapters.py", line 440, in send
    timeout=timeout
  File "D:\ProgramData\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 601, in urlopen
    chunked=chunked)
  File "D:\ProgramData\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 357, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "D:\ProgramData\Anaconda3\lib\http\client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "D:\ProgramData\Anaconda3\lib\http\client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "D:\ProgramData\Anaconda3\lib\http\client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "D:\ProgramData\Anaconda3\lib\http\client.py", line 1065, in _send_output
    self.send(chunk)
  File "D:\ProgramData\Anaconda3\lib\http\client.py", line 990, in send
    self.sock.sendall(d)
  File "D:\ProgramData\Anaconda3\lib\site-packages\urllib3\contrib\pyopenssl.py", line 315, in sendall
    while total_sent < len(data):
TypeError: object of type 'int' has no len()
Upload file failed!

Any ideas on what this may mean?

LabtronicsDesign avatar May 28 '18 12:05 LabtronicsDesign

$ pip uninstall pyOpenSSL fixed it! problem with that package being too strict with its inputs and requests package uses it preferentially, however it isn't necessary.

LabtronicsDesign avatar May 28 '18 13:05 LabtronicsDesign

I get same error as above while trying to send image. When I do a fresh setup with a new number I am able to send 3-4 images then suddenly this error is back.

I tried @SPWC fix but it says Skipping pyOpenssl as it is not installed.

ak4zh avatar Aug 07 '18 09:08 ak4zh

pip3 uninstall pyOpenSSL doesn't work for me

jersonjunior avatar Aug 17 '18 20:08 jersonjunior

I move /usr/lib/python3/dist-packages/OpenSSL to/usr/lib/python3/dist-packages/OpenSSL OpenSSL1 and works fine now

jersonjunior avatar Aug 17 '18 21:08 jersonjunior

I move /usr/lib/python3/dist-packages/OpenSSL to/usr/lib/python3/dist-packages/OpenSSL OpenSSL1 and works fine now

ok i used "mv /usr/lib/python3/dist-packages/OpenSSL to/usr/lib/python3/dist-packages/OpenSSL /usr/lib/python3/dist-packages/OpenSSL to/usr/lib/python3/dist-packages/OpenSSL1" restarted machine and works fine! i dont know if this is the correct method

gabrieru avatar Oct 07 '18 03:10 gabrieru

pip3 uninstall pyOpenSSL worked for me. Thank you!

Dan1001 avatar Dec 01 '18 21:12 Dan1001