Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No more new messages after socket failure #524

Open
ht-sp opened this issue Oct 8, 2024 · 0 comments
Open

No more new messages after socket failure #524

ht-sp opened this issue Oct 8, 2024 · 0 comments
Labels
waiting triage A maintainer acknowledged the issue, further discussion is needed

Comments

@ht-sp
Copy link

ht-sp commented Oct 8, 2024

Greetings.
I have encountered this situation where i see the following error in the log. After that the app is still running, but no more new messages are received. Restarting the app, resumes the session, but it will still not receive any more messages. Only creating and pairing a new session seems to help. The last time this problem occured about two hours after starting a new session.

Log:

13:23:38.371 [Thread-1] INFO  c.s.s.w.g.WhatsAppWebService - Disconnected, reason: RECONNECTING
13:23:39.523 [] DEBUG c.s.s.w.g.WhatsAppWebService - New message id xxx, type EMPTY, parent [email protected]
13:23:39.525 [] DEBUG c.s.s.w.g.WhatsAppWebService - New message id xxx, type EMPTY, parent [email protected]
Oct 08, 2024 1:23:39 PM it.auties.whatsapp.api.ErrorHandler lambda$defaultErrorHandler$3
SEVERE: [xxx] Socket failure at STREAM
java.lang.UnsupportedOperationException
	at java.base/java.util.ImmutableCollections.uoe(ImmutableCollections.java:142)
	at java.base/java.util.ImmutableCollections$AbstractImmutableCollection.add(ImmutableCollections.java:147)
	at it.auties.whatsapp.implementation.SocketHandler.addPastParticipant(SocketHandler.java:1250)
	at it.auties.whatsapp.implementation.StreamHandler.handleGroupStubType(StreamHandler.java:679)
	at it.auties.whatsapp.implementation.StreamHandler.addMessageForGroupStubType(StreamHandler.java:671)
	at it.auties.whatsapp.implementation.StreamHandler.handleGroupStubNotification(StreamHandler.java:643)
	at it.auties.whatsapp.implementation.StreamHandler.handleGroupNotification(StreamHandler.java:618)
	at it.auties.whatsapp.implementation.StreamHandler.digestNotification(StreamHandler.java:378)
	at it.auties.whatsapp.implementation.StreamHandler.digest(StreamHandler.java:116)
	at it.auties.whatsapp.implementation.SocketHandler.onMessage(SocketHandler.java:205)
	at it.auties.whatsapp.implementation.SocketSession$WebSocketSession.onMessage(SocketSession.java:119)
	at it.auties.whatsapp.net.WebSocketClient$MessageDecoder.payloadData(WebSocketClient.java:442)
	at it.auties.whatsapp.net.WebSocketClient$MessageDecoder.handlePayloadData(WebSocketClient.java:282)
	at it.auties.whatsapp.net.WebSocketClient$MessageDecoder.handleFrame(WebSocketClient.java:268)
	at it.auties.whatsapp.net.WebSocketClient$MessageDecoder.readFrame(WebSocketClient.java:255)
	at it.auties.whatsapp.net.WebSocketClient.lambda$listen$1(WebSocketClient.java:93)
	at it.auties.whatsapp.net.Response.complete(Response.java:8)
	at it.auties.whatsapp.net.SocketClient$SocketTransport$Secure.decodeSslBuffer(SocketClient.java:846)
	at it.auties.whatsapp.net.SocketClient$SocketTransport$Secure.lambda$fillSslBuffer$2(SocketClient.java:832)
	at it.auties.whatsapp.net.Response.complete(Response.java:8)
	at it.auties.whatsapp.net.SocketClient$SocketTransport$1.completed(SocketClient.java:566)
	at it.auties.whatsapp.net.SocketClient$SocketTransport$1.completed(SocketClient.java:552)
	at java.base/sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:129)
	at java.base/sun.nio.ch.UnixAsynchronousSocketChannelImpl.finishRead(UnixAsynchronousSocketChannelImpl.java:447)
	at java.base/sun.nio.ch.UnixAsynchronousSocketChannelImpl.finish(UnixAsynchronousSocketChannelImpl.java:195)
	at java.base/sun.nio.ch.UnixAsynchronousSocketChannelImpl.onEvent(UnixAsynchronousSocketChannelImpl.java:217)
	at java.base/sun.nio.ch.EPollPort$EventHandlerTask.run(EPollPort.java:305)
	at java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:113)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1583)
Oct 08, 2024 1:23:39 PM it.auties.whatsapp.api.ErrorHandler lambda$defaultErrorHandler$3
WARNING: [xxx] Ignored failure
Oct 08, 2024 1:23:39 PM it.auties.whatsapp.api.ErrorHandler lambda$defaultErrorHandler$3
SEVERE: [xxx] Socket failure at STREAM
java.lang.UnsupportedOperationException
	at java.base/java.util.ImmutableCollections.uoe(ImmutableCollections.java:142)
	at java.base/java.util.ImmutableCollections$AbstractImmutableCollection.add(ImmutableCollections.java:147)
	at it.auties.whatsapp.implementation.SocketHandler.addPastParticipant(SocketHandler.java:1250)
	at it.auties.whatsapp.implementation.StreamHandler.handleGroupStubType(StreamHandler.java:679)
	at it.auties.whatsapp.implementation.StreamHandler.addMessageForGroupStubType(StreamHandler.java:671)
	at it.auties.whatsapp.implementation.StreamHandler.handleGroupStubNotification(StreamHandler.java:643)
	at it.auties.whatsapp.implementation.StreamHandler.handleGroupNotification(StreamHandler.java:618)
	at it.auties.whatsapp.implementation.StreamHandler.digestNotification(StreamHandler.java:378)
	at it.auties.whatsapp.implementation.StreamHandler.digest(StreamHandler.java:116)
	at it.auties.whatsapp.implementation.SocketHandler.onMessage(SocketHandler.java:205)
	at it.auties.whatsapp.implementation.SocketSession$WebSocketSession.onMessage(SocketSession.java:119)
	at it.auties.whatsapp.net.WebSocketClient$MessageDecoder.payloadData(WebSocketClient.java:442)
	at it.auties.whatsapp.net.WebSocketClient$MessageDecoder.handlePayloadData(WebSocketClient.java:282)
	at it.auties.whatsapp.net.WebSocketClient$MessageDecoder.handleFrame(WebSocketClient.java:268)
	at it.auties.whatsapp.net.WebSocketClient$MessageDecoder.readFrame(WebSocketClient.java:255)
	at it.auties.whatsapp.net.WebSocketClient.lambda$listen$1(WebSocketClient.java:93)
	at it.auties.whatsapp.net.Response.complete(Response.java:8)
	at it.auties.whatsapp.net.SocketClient$SocketTransport$Secure.decodeSslBuffer(SocketClient.java:846)
	at it.auties.whatsapp.net.SocketClient$SocketTransport$Secure.lambda$fillSslBuffer$2(SocketClient.java:832)
	at it.auties.whatsapp.net.Response.complete(Response.java:8)
	at it.auties.whatsapp.net.SocketClient$SocketTransport$1.completed(SocketClient.java:566)
	at it.auties.whatsapp.net.SocketClient$SocketTransport$1.completed(SocketClient.java:552)
	at java.base/sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:129)
	at java.base/sun.nio.ch.UnixAsynchronousSocketChannelImpl.finishRead(UnixAsynchronousSocketChannelImpl.java:447)
	at java.base/sun.nio.ch.UnixAsynchronousSocketChannelImpl.finish(UnixAsynchronousSocketChannelImpl.java:195)
	at java.base/sun.nio.ch.UnixAsynchronousSocketChannelImpl.onEvent(UnixAsynchronousSocketChannelImpl.java:217)
	at java.base/sun.nio.ch.EPollPort$EventHandlerTask.run(EPollPort.java:305)
	at java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:113)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1583)
Oct 08, 2024 1:23:39 PM it.auties.whatsapp.api.ErrorHandler lambda$defaultErrorHandler$3
WARNING: [xxx] Ignored failure
13:23:39.559 [] DEBUG c.s.s.w.g.WhatsAppWebService - Connected: [PrivacySettingEntry[type=READ_RECEIPTS, value=EVERYONE, excluded=[]], PrivacySettingEntry[type=STATUS, value=CONTACTS, excluded=[]], PrivacySettingEntry[type=PROFILE_PIC, value=EVERYONE, excluded=[]], PrivacySettingEntry[type=ONLINE, value=EVERYONE, excluded=[]], PrivacySettingEntry[type=CALL_ADD, value=EVERYONE, excluded=[]], PrivacySettingEntry[type=ADD_ME_TO_GROUPS, value=EVERYONE, excluded=[]], PrivacySettingEntry[type=LAST_SEEN, value=CONTACTS, excluded=[]]]

Code:

while (!stopped) {

	WebOptionsBuilder webOptionsBuilder = Whatsapp.webBuilder()
			.newConnection(UUID.fromString(session.randomFixedUuid()))
			.name(session.name())
			.textPreviewSetting(TextPreviewSetting.DISABLED)
			.proxy(proxyUri)
			.historyLength(WebHistoryLength.extended());

	Whatsapp whatsapp = webOptionsBuilder
			.registered()
			.orElseGet(() -> webOptionsBuilder.unregistered(QrHandler.toTerminal()))
			.addLoggedInListener(api -> LOG.debug("Connected: %s".formatted(api.store().privacySettings())))
			.addDisconnectedListener((reason) -> {
				LOG.info("Disconnected, reason: %s".formatted(reason));
				if (reason != DisconnectReason.RECONNECTING && reason != DisconnectReason.RESTORE) {
					LOG.info("we are not logged in anymore");
				}
			})
			.addNewMessageListener((Whatsapp api, MessageInfo<?> message) -> LOG.debug("New message id %s, type %s, parent %s".formatted(message.id(), message.message().type(), message.parentJid())))
			.connect()
			.join();

	while (true) {
		if (whatsapp.store().jid().isPresent()) {
			LOG.info("Jid found, we are logged in now");
			break;
		}
	}

	while (!stopped) {
		Thread.sleep(1000);

		// [...] save data from whatsapp.store()
	}
}

Maybe i have to adapt my implementation or the like. Do you have any idea on how to avoid this problem?
Thank you in advance.

@Auties00 Auties00 added the waiting triage A maintainer acknowledged the issue, further discussion is needed label Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting triage A maintainer acknowledged the issue, further discussion is needed
Projects
None yet
Development

No branches or pull requests

2 participants