question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SendMessage issue when send media file

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Hi,

I have checked the documentation and other examples on internet and I believe that my code is ok. It’s working fine when I try to send a text, but it doesn’t work for media (image).

I have tried to use MessageMedia.fromFilePath and MessageMedia.fromUrl and both return the image ok, but when I send the message nothing happens and there is no error.

Please, could you check if it is a bug or I am missing something?

Thanks in advance

Expected behavior

As a user, I expect to send the message using media files

Steps to Reproduce the Bug or Issue

Execute the code that I have provided with any image file

Relevant Code

client.on('ready', () => {
    console.log('READY');
    client.getChats().then((chats) => {

        client.sendMessage('34664547621@c.us', "test");

        //const media = MessageMedia.fromFilePath('coloured-lab-symbol-white.png');
        const media = MessageMedia.fromUrl('https://colouredlab.com/assets/coloured-lab-symbol-white.png');
        
        //console.log(media);

        client.sendMessage("34664547621@c.us", media, {caption: "image" } );

    })
});

Browser Type

Chromium

WhatsApp Account Type

Standard

Does your WhatsApp account have multidevice enabled?

Yes, I am using Multi Device

Environment

OS: Windows 11 Pro Phone OS: IOS 15.4.1 (I don’t if is relevant, because I am testing using the vscode + node my-code.js that opens a chromium with puppeter) whatsapp-web.js version 1.17.0 WhatsApp Web version 2.2222.11 Node.js Version v14.17.3

Additional context

No response

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
andresmv94commented, Sep 21, 2022

@remomfurlanetto In my case I had the same problem, and the problem was that for some rason on the final part of my code the client.destroy(); was executing before that the sendMessage finish the process, and the temporary solution was remove the client.destroy(); line. (put it inside a condition or in a setTime())

1reaction
remomfurlanettocommented, Sep 21, 2022

No, I didn’t. Everything that I tried regarding this functionality didn’t work. The message was never being delivered

On Wed, 21 Sept 2022 at 01:34, andresmv94 @.***> wrote:

@remomfurlanetto https://github.com/remomfurlanetto did you find some solution?

— Reply to this email directly, view it on GitHub https://github.com/pedroslopez/whatsapp-web.js/issues/1539#issuecomment-1253019112, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM5UVNSSKIF34UTOPT2YV43V7JCZDANCNFSM5ZUKFHCQ . You are receiving this because you were mentioned.Message ID: @.***>

– Sent from Gmail Mobile

Read more comments on GitHub >

github_iconTop Results From Across the Web

Chrome Extension : Issue with SendMessage - Stack Overflow
I am sending a message from content.js making the xrh call in the background js file and then passing the output to content.js...
Read more >
Sending Messages and Media | Twilio
Send a Media Message​​ To add a media Message (i.e. photos, videos) to your Conversation, you'll need to create a Message and add...
Read more >
How to Fix Failed to Send Message in your Phone! - YouTube
How to fix failed to send message in your phone Message Not send or couldn't send How to Fix Failed to Send Message...
Read more >
MMS unable to send message file too large
Is everybody having this issue where they can't even send a photo or a simple ... customers to send and receive text messages...
Read more >
Top 8 Ways to Fix Telegram Not Sending Messages on ...
3. Disable Background Restrictions. Telegram is famous for its ability to send large files. However, the app may fail to deliver such large ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found