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.

Authentication fails from last connection

See original GitHub issue

Hi @Auties00,

I’m using this piece of code to get a connection. When I removed all the serialized connections, I get a QR code and everything seems fine. But when I restart my application, it’s using the “lastConnection” and I got the error below.

Seems like something is off at serializing/deserializing the connections?

Whatsapp api;
if (Whatsapp.listConnections().isEmpty()) {
                var configuration = Whatsapp.Options.newOptions()
                        .description("MyApp")
                        .create();
                api = Whatsapp.newConnection(configuration);
            } else {
                api = Whatsapp.lastConnection();
            }
            api.connect().get();

Error

Caused by: java.lang.NullPointerException: Cannot invoke "it.auties.whatsapp.model.media.MediaConnection.auth()" because the return value of "it.auties.whatsapp.controller.Store.mediaConnection()" is null
	at it.auties.whatsapp.util.Medias.upload(Medias.java:51)
	at it.auties.whatsapp.model.message.standard.ImageMessage.simpleBuilder(ImageMessage.java:179)
	at it.auties.whatsapp.model.message.standard.ImageMessage$SimpleImageBuilder.create(ImageMessage.java:172)
	at be.geertdebaets.camera.service.WhatsAppService.sendImageMessageToGroup(WhatsAppService.java:147)
	... 1 more

Version: <version>3.0-RC13</version> (but was also on RC12)

Is this a bug/problem, or i’m a doing something wrong in setting up the connections?

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:34 (14 by maintainers)

github_iconTop GitHub Comments

2reactions
Auties00commented, Jun 30, 2022

Hi @Auties00,

I’m using this piece of code to get a connection. When I removed all the serialized connections, I get a QR code and everything seems fine. But when I restart my application, it’s using the “lastConnection” and I got the error below.

Seems like something is off at serializing/deserializing the connections?

Whatsapp api;
if (Whatsapp.listConnections().isEmpty()) {
                var configuration = Whatsapp.Options.newOptions()
                        .description("MyApp")
                        .create();
                api = Whatsapp.newConnection(configuration);
            } else {
                api = Whatsapp.lastConnection();
            }
            api.connect().get();

Error

Caused by: java.lang.NullPointerException: Cannot invoke "it.auties.whatsapp.model.media.MediaConnection.auth()" because the return value of "it.auties.whatsapp.controller.Store.mediaConnection()" is null
	at it.auties.whatsapp.util.Medias.upload(Medias.java:51)
	at it.auties.whatsapp.model.message.standard.ImageMessage.simpleBuilder(ImageMessage.java:179)
	at it.auties.whatsapp.model.message.standard.ImageMessage$SimpleImageBuilder.create(ImageMessage.java:172)
	at be.geertdebaets.camera.service.WhatsAppService.sendImageMessageToGroup(WhatsAppService.java:147)
	... 1 more

Version: <version>3.0-RC13</version> (but was also on RC12)

Is this a bug/problem, or i’m a doing something wrong in setting up the connections?

just fixed it, it will be available in the next update

1reaction
GDB4Jcommented, Jun 30, 2022

I’m trying all types of connection examples but I can’t get a QR code. When I try to do “api.connect().get()” (my last test is with some code of @GDB4J), but code is freezing and make serialized connection, under “.whatsappweb4j” only after stop application. I’m on MacOs.

There is some solutions?

Hi @19Maury85 , I’ve struggled aslo with getting a QRCode at first.

The easiest way to start is running one of the examples and see if you can get a QRCode there. There you will see the easiest way to get a connection is this one (I believe):

var api = Whatsapp.lastConnection()
                .connect()
                .get();

It wil create a new connection if no connection was saved before. Check also your {user.home}/.whatsappweb4j folder and perhaps try to delete everything from there On windows C:/users/<your_username>/.whatsappweb4j On Linux /home/<your_username>/.whatsappweb4j

My problem ended up using a too recent dependency version of “jakarta.websocket-api” See issues (but this when working with Spring Boot) : https://github.com/Auties00/WhatsappWeb4j/issues/111 https://github.com/Auties00/WhatsappWeb4j/issues/105

Kind regards

Read more comments on GitHub >

github_iconTop Results From Across the Web

5 Ways to Fix Wi-Fi Authentication Problems on Android
1. Start the Settings app. · 2. Go to your Wi-Fi settings. · 3. Tap and hold the Wi-Fi network you are trying...
Read more >
How to Fix Wi-Fi Authentication Problems on Android - Lifewire
Wi-Fi authentication errors happen when your phone or tablet won't fully connect to the Wi-Fi network. Here are several ways to get back ......
Read more >
Authentication Error Occurred? -10 Proven Fixes - Dr.Fone
Learn how to overcome Wifi authentication error in this extensive post. We have listed stepwise solutions to fix authentication error occurred on Android....
Read more >
Troubleshooting Authentication / Log in Failure with Systems ...
If you received the error like: Authentication failure: Invalid username or password" after you've correctly entered in your NetID and password, you maybe ......
Read more >
"Authentication failed" error when you try to log on to Unified ...
Fixes a problem in which you receive an "Authentication failed" error message when you use the UPN format to log on to a...
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