Closed friend-tom closed 8 months ago
Issue description:
- Phone num is registered,UUID is :f1ec81b3-b217-4499-a564-ee00773544f4
- The current blockage occurs while executing the whatsapp.connect() method, specifically during the decodeLength(socket.getInputStream()) step within the it.auties.whatsapp.socket.SocketSession#readMessages method. At this point, decodeLength is returning -1, even though socket.isConnected is true.
Environment Information:
- Whatsappweb4j Version : 3.5.1
- OS:MacOS 13.4.1 (22F82)
- JDK:java version "20.0.1" 2023-04-18
- Maven:Apache Maven 3.6.3
- IDE : IntelliJ IDEA 2023.1.3 (Ultimate Edition)
- Run mode : Junit Test .(Enabled -> Delegate IDE build/run actions to Maven)
Junit Test Code: `
@Test public void MobileTest() { try { MobileReplyTest rt = new MobileReplyTest(); rt.createApiByUUID(UUID.fromString("f1ec81b3-b217-4499-a564-ee00773544f4")); latch = new CountDownLatch(3); rt.log("store: %s", api.store().toJson()); rt.log("keys: %s", api.keys().toJson()); api.addNodeSentListener(outgoing -> System.out.printf("nodeSend:>>>%s%n",outgoing.toString())); api.addNodeReceivedListener(incoming -> System.out.printf("nodeReceived:>>>%s%n",incoming.toString())); api.connect().join(); rt.log("Connected:%s", api.isConnected()); // Test send message Chat chat = Chat.ofJid(ContactJid.of("__other__phone_no___")); api.sendMessage(chat, TextMessage.of("Hi,here is from test message!")).thenApply(messageInfo -> messageInfo.message()); api.store().contacts().forEach(contact -> System.out.println(contact)); List<Chat> chats = api.socketHandler().store().chats(); chats.forEach(chat1 -> System.out.println(chat1)); latch.await(); rt.log("All threads have finished."); } catch (Exception e) { throw new RuntimeException(e); } }
`
Console Log output: !!! No NodeListener related log output yet!
` it.auties.whatsapp.socket.SocketSession.connect()|Socket.Addr:g.whatsapp.net/199.193.116.105:443, it.auties.whatsapp.socket.SocketSession.readMessages()|Begin ReadMessage,socket.isConnected:true, it.auties.whatsapp.socket.SocketSession.sendBinary()|Begin sendBinary,Socket is:Socket[addr=g.whatsapp.net/199.193.116.105,port=443,localport=60930], it.auties.whatsapp.socket.SocketSession.sendBinary()|End sendBinary,Socket is:Socket[addr=g.whatsapp.net/199.193.116.105,port=443,localport=60930],bytes.length:46 it.auties.whatsapp.socket.Request.onSendSuccess()|return void! it.auties.whatsapp.socket.SocketSession.readMessages()|decodeLength(input):-1, it.auties.whatsapp.socket.SocketSession.readMessages()|Return break! Disconnected: RECONNECTING
` WireShark figure:
Local smile data: `
store: { "uuid" : "f1ec81b3-b217-4499-a564-ee00773544f4", "phoneNumber" : { "countryCode" : "CHINA", "numberWithoutPrefix" : 12345678912 }, "clientType" : "MOBILE", "version" : "2.23.16.77", "name" : "Whatsapp4j", "linkedDevicesKeys" : { }, "jid" : "8612345678912@s.whatsapp.net", "initializationTimeStamp" : 1692173189, "newChatsEphemeralTimer" : "OFF", "textPreviewSetting" : "ENABLED_WITH_INFERENCE", "historyLength" : "STANDARD", "autodetectListeners" : true, "automaticPresenceUpdates" : true, "releaseChannel" : "RELEASE", "device" : { "model" : "star2lte", "manufacturer" : "Samsung", "osType" : "ANDROID", "osVersion" : "8.0.0" } } keys: { "uuid" : "f1ec81b3-b217-4499-a564-ee00773544f4", "phoneNumber" : { "countryCode" : "CHINA", "numberWithoutPrefix" : 12345678912 }, "clientType" : "MOBILE", "registrationId" : 10332, "noiseKeyPair" : { "publicKey" : "tr6qUnRMovfUWcBro0Nv7Rz5xxxxxxxxxxxxxxxxxxxxx", "privateKey" : "gFoWCA3gvd4eLa4orUVttegxxxxxxxxxxxxxxxxxxxxx" }, "ephemeralKeyPair" : { "publicKey" : "2lLvJhxlWgLSmMV0j6wvH1Tuxxxxxxxxxxxxxxxxxxxxx", "privateKey" : "+A1PKlGgDQ1zazKer5Uinoxxxxxxxxxxxxxxxxxxxxxx" }, "identityKeyPair" : { "publicKey" : "slWHek5H9BHPH8l1G7uUiqxxxxxxxxxxxxxxxxxxxxx", "privateKey" : "8FPnbms4f0OyWTi9/E4k/xxxxxxxxxxxxxxxxxxxxx" }, "signedKeyPair" : { "id" : 10332, "keyPair" : { "publicKey" : "ekba7Y0gtnZf71P5GQoQxxxxxxxxxxxxxxxxxxxxx", "privateKey" : "EFsW6Wt/wsXLwfz9Kfjxxxxxxxxxxxxxxxxxxxxx" }, "signature" : "G1CFqu+sPv5JGEgKc09R3FBR+B6jHN6oeEAxxxxxxxxxxxxxxxxxxxxx==" }, "companionKeyPair" : { "publicKey" : "JI1pR9lrYMiECmgrDwvGGjOxxxxxxxxxxxxxxxxxxxxx", "privateKey" : "0M74jv6WE1yY5BxfIRpiP4xxxxxxxxxxxxxxxxxxxxx" }, "prologue" : "V0EFAw==", "phoneId" : "ead9881d-37f3-47e1-b99a-fd19cdaf134f", "deviceId" : "CfgbhJksQNGhsajt5p5OTA==", "recoveryToken" : "43c7036925ef588132fb6xxxxxxxxxxxxxxxxxxxxx", "registered" : true }
`
Is the phone being registered through the business api?
Issue description:
- Phone num is registered,UUID is :f1ec81b3-b217-4499-a564-ee00773544f4
- The current blockage occurs while executing the whatsapp.connect() method, specifically during the decodeLength(socket.getInputStream()) step within the it.auties.whatsapp.socket.SocketSession#readMessages method. At this point, decodeLength is returning -1, even though socket.isConnected is true.
Environment Information:
- Whatsappweb4j Version : 3.5.1
- OS:MacOS 13.4.1 (22F82)
- JDK:java version "20.0.1" 2023-04-18
- Maven:Apache Maven 3.6.3
- IDE : IntelliJ IDEA 2023.1.3 (Ultimate Edition)
- Run mode : Junit Test .(Enabled -> Delegate IDE build/run actions to Maven)
Junit Test Code: `
@Test public void MobileTest() { try { MobileReplyTest rt = new MobileReplyTest(); rt.createApiByUUID(UUID.fromString("f1ec81b3-b217-4499-a564-ee00773544f4")); latch = new CountDownLatch(3); rt.log("store: %s", api.store().toJson()); rt.log("keys: %s", api.keys().toJson()); api.addNodeSentListener(outgoing -> System.out.printf("nodeSend:>>>%s%n",outgoing.toString())); api.addNodeReceivedListener(incoming -> System.out.printf("nodeReceived:>>>%s%n",incoming.toString())); api.connect().join(); rt.log("Connected:%s", api.isConnected()); // Test send message Chat chat = Chat.ofJid(ContactJid.of("__other__phone_no___")); api.sendMessage(chat, TextMessage.of("Hi,here is from test message!")).thenApply(messageInfo -> messageInfo.message()); api.store().contacts().forEach(contact -> System.out.println(contact)); List<Chat> chats = api.socketHandler().store().chats(); chats.forEach(chat1 -> System.out.println(chat1)); latch.await(); rt.log("All threads have finished."); } catch (Exception e) { throw new RuntimeException(e); } }
` Console Log output: !!! No NodeListener related log output yet!
it.auties.whatsapp.socket.SocketSession.connect()|Socket.Addr:g.whatsapp.net/199.193.116.105:443, it.auties.whatsapp.socket.SocketSession.readMessages()|Begin ReadMessage,socket.isConnected:true, it.auties.whatsapp.socket.SocketSession.sendBinary()|Begin sendBinary,Socket is:Socket[addr=g.whatsapp.net/199.193.116.105,port=443,localport=60930], it.auties.whatsapp.socket.SocketSession.sendBinary()|End sendBinary,Socket is:Socket[addr=g.whatsapp.net/199.193.116.105,port=443,localport=60930],bytes.length:46 it.auties.whatsapp.socket.Request.onSendSuccess()|return void! it.auties.whatsapp.socket.SocketSession.readMessages()|decodeLength(input):-1, it.auties.whatsapp.socket.SocketSession.readMessages()|Return break! Disconnected: RECONNECTING
WireShark figure:Local smile data:
store: { "uuid" : "f1ec81b3-b217-4499-a564-ee00773544f4", "phoneNumber" : { "countryCode" : "CHINA", "numberWithoutPrefix" : 12345678912 }, "clientType" : "MOBILE", "version" : "2.23.16.77", "name" : "Whatsapp4j", "linkedDevicesKeys" : { }, "jid" : "[8612345678912@s.whatsapp.net](mailto:8612345678912@s.whatsapp.net)", "initializationTimeStamp" : 1692173189, "newChatsEphemeralTimer" : "OFF", "textPreviewSetting" : "ENABLED_WITH_INFERENCE", "historyLength" : "STANDARD", "autodetectListeners" : true, "automaticPresenceUpdates" : true, "releaseChannel" : "RELEASE", "device" : { "model" : "star2lte", "manufacturer" : "Samsung", "osType" : "ANDROID", "osVersion" : "8.0.0" } } keys: { "uuid" : "f1ec81b3-b217-4499-a564-ee00773544f4", "phoneNumber" : { "countryCode" : "CHINA", "numberWithoutPrefix" : 12345678912 }, "clientType" : "MOBILE", "registrationId" : 10332, "noiseKeyPair" : { "publicKey" : "tr6qUnRMovfUWcBro0Nv7Rz5xxxxxxxxxxxxxxxxxxxxx", "privateKey" : "gFoWCA3gvd4eLa4orUVttegxxxxxxxxxxxxxxxxxxxxx" }, "ephemeralKeyPair" : { "publicKey" : "2lLvJhxlWgLSmMV0j6wvH1Tuxxxxxxxxxxxxxxxxxxxxx", "privateKey" : "+A1PKlGgDQ1zazKer5Uinoxxxxxxxxxxxxxxxxxxxxxx" }, "identityKeyPair" : { "publicKey" : "slWHek5H9BHPH8l1G7uUiqxxxxxxxxxxxxxxxxxxxxx", "privateKey" : "8FPnbms4f0OyWTi9/E4k/xxxxxxxxxxxxxxxxxxxxx" }, "signedKeyPair" : { "id" : 10332, "keyPair" : { "publicKey" : "ekba7Y0gtnZf71P5GQoQxxxxxxxxxxxxxxxxxxxxx", "privateKey" : "EFsW6Wt/wsXLwfz9Kfjxxxxxxxxxxxxxxxxxxxxx" }, "signature" : "G1CFqu+sPv5JGEgKc09R3FBR+B6jHN6oeEAxxxxxxxxxxxxxxxxxxxxx==" }, "companionKeyPair" : { "publicKey" : "JI1pR9lrYMiECmgrDwvGGjOxxxxxxxxxxxxxxxxxxxxx", "privateKey" : "0M74jv6WE1yY5BxfIRpiP4xxxxxxxxxxxxxxxxxxxxx" }, "prologue" : "V0EFAw==", "phoneId" : "ead9881d-37f3-47e1-b99a-fd19cdaf134f", "deviceId" : "CfgbhJksQNGhsajt5p5OTA==", "recoveryToken" : "43c7036925ef588132fb6xxxxxxxxxxxxxxxxxxxxx", "registered" : true }
Is the phone being registered through the business api?
No, it's a call to the library's registration API, here's the relevant code : ` private static Whatsapp api; static { Security.addProvider(new BouncyCastleProvider()); } private Long phoneNum = 861234567812L; private void createApi() { api = Whatsapp.mobileBuilder().newConnection().unregistered().verificationCodeMethod(VerificationCodeMethod.SMS).verificationCodeSupplier(this::onScanCode) .register(phoneNum).join().addListener(this); log("uuid: %s", api.store().uuid().toString()); }
`
Fixed in the latest commit
Issue description:
Environment Information:
Junit Test Code: `
`
Console Log output: !!! No NodeListener related log output yet!
` WireShark figure:
Local smile data: `
store: { "uuid" : "f1ec81b3-b217-4499-a564-ee00773544f4", "phoneNumber" : { "countryCode" : "CHINA", "numberWithoutPrefix" : 12345678912 }, "clientType" : "MOBILE", "version" : "2.23.16.77", "name" : "Whatsapp4j", "linkedDevicesKeys" : { }, "jid" : "8612345678912@s.whatsapp.net", "initializationTimeStamp" : 1692173189, "newChatsEphemeralTimer" : "OFF", "textPreviewSetting" : "ENABLED_WITH_INFERENCE", "historyLength" : "STANDARD", "autodetectListeners" : true, "automaticPresenceUpdates" : true, "releaseChannel" : "RELEASE", "device" : { "model" : "star2lte", "manufacturer" : "Samsung", "osType" : "ANDROID", "osVersion" : "8.0.0" } } keys: { "uuid" : "f1ec81b3-b217-4499-a564-ee00773544f4", "phoneNumber" : { "countryCode" : "CHINA", "numberWithoutPrefix" : 12345678912 }, "clientType" : "MOBILE", "registrationId" : 10332, "noiseKeyPair" : { "publicKey" : "tr6qUnRMovfUWcBro0Nv7Rz5xxxxxxxxxxxxxxxxxxxxx", "privateKey" : "gFoWCA3gvd4eLa4orUVttegxxxxxxxxxxxxxxxxxxxxx" }, "ephemeralKeyPair" : { "publicKey" : "2lLvJhxlWgLSmMV0j6wvH1Tuxxxxxxxxxxxxxxxxxxxxx", "privateKey" : "+A1PKlGgDQ1zazKer5Uinoxxxxxxxxxxxxxxxxxxxxxx" }, "identityKeyPair" : { "publicKey" : "slWHek5H9BHPH8l1G7uUiqxxxxxxxxxxxxxxxxxxxxx", "privateKey" : "8FPnbms4f0OyWTi9/E4k/xxxxxxxxxxxxxxxxxxxxx" }, "signedKeyPair" : { "id" : 10332, "keyPair" : { "publicKey" : "ekba7Y0gtnZf71P5GQoQxxxxxxxxxxxxxxxxxxxxx", "privateKey" : "EFsW6Wt/wsXLwfz9Kfjxxxxxxxxxxxxxxxxxxxxx" }, "signature" : "G1CFqu+sPv5JGEgKc09R3FBR+B6jHN6oeEAxxxxxxxxxxxxxxxxxxxxx==" }, "companionKeyPair" : { "publicKey" : "JI1pR9lrYMiECmgrDwvGGjOxxxxxxxxxxxxxxxxxxxxx", "privateKey" : "0M74jv6WE1yY5BxfIRpiP4xxxxxxxxxxxxxxxxxxxxx" }, "prologue" : "V0EFAw==", "phoneId" : "ead9881d-37f3-47e1-b99a-fd19cdaf134f", "deviceId" : "CfgbhJksQNGhsajt5p5OTA==", "recoveryToken" : "43c7036925ef588132fb6xxxxxxxxxxxxxxxxxxxxx", "registered" : true }
`