Closed hamarna closed 10 months ago
Also there's a suggestion to create custom exception for Request::send which would contain Request object instead of IOException
When I call ::sendMessage and trying to handle it's future, I don't get any exceptions. Instead there's error at MESSAGE location.
Is there any proper way to handle message sending errors?
Can you show me the stack trace?
2023-08-14 18:04:52.373 [Thread-1782] WARN r.i.c.w.c.MobileWhatsappInstance.errorHandler$lambda$1 - Socket failure at MESSAGE:
java.util.concurrent.CompletionException: java.io.IOException: Cannot send Request[id=ebb49768-a33c-40a9-ac5d-89f9261484f1, body=Node[description=iq, attributes={xmlns=usync, to=s.whatsapp.net, id=ebb49768-a33c-40a9-ac5d-89f9261484f1, type=get}, content=[Node[description=usync, attributes={mode=query, last=true, context=message, index=0, sid=b857b2ff-6adb-4d45-93ee-808c6f5080a6}, content=[Node[description=query, content=[Node[description=devices, attributes={version=2}]]], Node[description=list, content=[Node[description=user, attributes={jid=hidden@s.whatsapp.net}], Node[description=user, attributes={jid=hidden@s.whatsapp.net}]]]]]]], future=java.util.concurrent.CompletableFuture@173bfa32[Not completed, 1 dependents], filter=null, caller=java.lang.RuntimeException: Node[description=iq, attributes={xmlns=usync, to=s.whatsapp.net, id=ebb49768-a33c-40a9-ac5d-89f9261484f1, type=get}, content=[Node[description=usync, attributes={mode=query, last=true, context=message, index=0, sid=b857b2ff-6adb-4d45-93ee-808c6f5080a6}, content=[Node[description=query, content=[Node[description=devices, attributes={version=2}]]], Node[description=list, content=[Node[description=user, attributes={jid=hidden@s.whatsapp.net}], Node[description=user, attributes={jid=hidden@s.whatsapp.net}]]]]]]] node timed out], an hidden exception occurred
at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:332)
at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:347)
at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:636)
at java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510)
at java.base/java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:2162)
at it.auties.whatsapp.model.request.Request.onSendError(Request.java:137)
at java.base/java.util.concurrent.CompletableFuture.uniExceptionally(CompletableFuture.java:990)
at java.base/java.util.concurrent.CompletableFuture$UniExceptionally.tryFire(CompletableFuture.java:974)
at java.base/java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:482)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.io.IOException: Cannot send Request[id=ebb49768-a33c-40a9-ac5d-89f9261484f1, body=Node[description=iq, attributes={xmlns=usync, to=s.whatsapp.net, id=ebb49768-a33c-40a9-ac5d-89f9261484f1, type=get}, content=[Node[description=usync, attributes={mode=query, last=true, context=message, index=0, sid=b857b2ff-6adb-4d45-93ee-808c6f5080a6}, content=[Node[description=query, content=[Node[description=devices, attributes={version=2}]]], Node[description=list, content=[Node[description=user, attributes={jid=hidden@s.whatsapp.net}], Node[description=user, attributes={jid=hidden@s.whatsapp.net}]]]]]]], future=java.util.concurrent.CompletableFuture@173bfa32[Not completed, 1 dependents], filter=null, caller=java.lang.RuntimeException: Node[description=iq, attributes={xmlns=usync, to=s.whatsapp.net, id=ebb49768-a33c-40a9-ac5d-89f9261484f1, type=get}, content=[Node[description=usync, attributes={mode=query, last=true, context=message, index=0, sid=b857b2ff-6adb-4d45-93ee-808c6f5080a6}, content=[Node[description=query, content=[Node[description=devices, attributes={version=2}]]], Node[description=list, content=[Node[description=user, attributes={jid=hidden@s.whatsapp.net}], Node[description=user, attributes={jid=hidden@s.whatsapp.net}]]]]]]] node timed out], an unknown exception occurred
... 5 common frames omitted
Caused by: java.util.concurrent.CompletionException: java.io.UncheckedIOException: Cannot send message
at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315)
at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320)
at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1807)
... 1 common frames omitted
Caused by: java.io.UncheckedIOException: Cannot send message
at it.auties.whatsapp.socket.SocketSession.lambda$sendBinary$3(SocketSession.java:108)
at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
... 1 common frames omitted
Caused by: java.net.SocketException: Socket is not connected
at java.base/java.net.Socket.getOutputStream(Socket.java:1000)
at it.auties.whatsapp.socket.SocketSession.lambda$sendBinary$3(SocketSession.java:104)
... 2 common frames omitted
This is related to the bad Mac error, I'll track the issue there
When I call ::sendMessage and trying to handle it's future, I don't get any exceptions. Instead there's error at MESSAGE location.
Is there any proper way to handle message sending errors?