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

Websocket error #13

Open
robozb opened this issue Dec 11, 2024 · 23 comments
Open

Websocket error #13

robozb opened this issue Dec 11, 2024 · 23 comments

Comments

@robozb
Copy link

robozb commented Dec 11, 2024

Dear Dev,

I got this error message on my Linux. I'd like to test the socket, please send me the API URL.

org.java_websocket.exceptions.WebsocketNotConnectedException: null
        at org.java_websocket.WebSocketImpl.send(WebSocketImpl.java:674) ~[Java-WebSocket-1.5.6.jar:?]
        at org.java_websocket.WebSocketImpl.send(WebSocketImpl.java:650) ~[Java-WebSocket-1.5.6.jar:?]
        at org.java_websocket.client.WebSocketClient.send(WebSocketClient.java:433) ~[Java-WebSocket-1.5.6.jar:?]
        at com.github.realzimboguy.ewelink.api.EweLinkWebSocketClient.sendAndWait(EweLinkWebSocketClient.java:83) ~[ewelink-api-java-3.3.3-RELEASE.jar:?]
        at com.github.realzimboguy.ewelink.api.EweLink.setDeviceStatus(EweLink.java:389) ~[ewelink-api-java-3.3.3-RELEASE.jar:?]
        at hu.wfs.log4j2peldaprojekt.EwelinkVezerles.lampaKapcsolasa(EwelinkVezerles.java:138) ~[classes/:?]
        at hu.wfs.log4j2peldaprojekt.EwelinkVezerles.lambda$osszesLampaKapcsolasa$0(EwelinkVezerles.java:125) ~[classes/:?]
        at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948) [?:?]
        at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658) [?:?]
        at hu.wfs.log4j2peldaprojekt.EwelinkVezerles.osszesLampaKapcsolasa(EwelinkVezerles.java:124) [classes/:?]
        at hu.wfs.log4j2peldaprojekt.EwelinkVezerles.vezerles(EwelinkVezerles.java:43) [classes/:?]
        at hu.wfs.log4j2peldaprojekt.EwelinkVezerles.main(EwelinkVezerles.java:37) [classes/:?]
        at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:279) [exec-maven-plugin-3.1.0.jar:?]
        at java.lang.Thread.run(Thread.java:829) [?:?]

My Linux opsystem:

java -version
openjdk version "11.0.25" 2024-10-15
OpenJDK Runtime Environment (build 11.0.25+9-post-Debian-1deb11u1)
OpenJDK 64-Bit Server VM (build 11.0.25+9-post-Debian-1deb11u1, mixed mode)
cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

My Win10 (where the same source works well):

jdk-17.0.6_windows-x64_bin

Thanks: Bela

@RealZimboGuy
Copy link
Owner

hi @robozb what version of the lib are you using ?

@robozb
Copy link
Author

robozb commented Dec 11, 2024

I guess the latest:

  <dependency>
      <groupId>com.github.realzimboguy.ewelink.api</groupId>
      <artifactId>ewelink-api-java</artifactId>
      <version>3.3.3-RELEASE</version>
  </dependency>   

@RealZimboGuy
Copy link
Owner

RealZimboGuy commented Dec 11, 2024

the logins go to

      baseUrl = "https://"+region+"-apia.coolkit.cc/v2/";

the websockets go to

      "wss://"+ region+"-pconnect3.coolkit.cc:8080/api/ws"

region comes from what you init the api ie "eu"

@robozb
Copy link
Author

robozb commented Dec 11, 2024

It is interesting, all things works well in Win10, but not on my Linux RPI4 on the same network.
The other network traffic works well as well on Linux. I created a jar-with-deps, all good with Win10 but not on Linux.

On Linux with almost the same JDK (Oracle 17) I got this errors all the time:

/Java17SDK/jdk-17.0.12/bin/java -jar ~/Ewelink_2023_09_II/ewelink-with-deps.jar
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
2024 10:00:58.702 [main] INFO  hu.wfs.log4j2peldaprojekt.EwelinkVezerles -- app start...
2024 10:00:58.707 [main] INFO  hu.wfs.log4j2peldaprojekt.EwelinkVezerles -- initEwelink START...
2024 10:01:10.530 [main] INFO  hu.wfs.log4j2peldaprojekt.EwelinkVezerles -- initEwelink STOP...
2024 10:01:10.532 [main] INFO  hu.wfs.log4j2peldaprojekt.EwelinkVezerles -- Osszes lampa lekapcsolasa START...
2024 10:01:10.537 [main] INFO  hu.wfs.log4j2peldaprojekt.EwelinkVezerles -- lampaKapcsolasa... FOLYOSO_AJTO off
2024 10:01:10.609 [main] ERROR hu.wfs.log4j2peldaprojekt.EwelinkVezerles -- Problemas lampa: FOLYOSO_AJTO->1001110a16->off
org.java_websocket.exceptions.WebsocketNotConnectedException: null
        at org.java_websocket.WebSocketImpl.send(WebSocketImpl.java:674) ~[ewelink-with-deps.jar:?]
        at org.java_websocket.WebSocketImpl.send(WebSocketImpl.java:650) ~[ewelink-with-deps.jar:?]
        at org.java_websocket.client.WebSocketClient.send(WebSocketClient.java:433) ~[ewelink-with-deps.jar:?]
        at com.github.realzimboguy.ewelink.api.EweLinkWebSocketClient.sendAndWait(EweLinkWebSocketClient.java:83) ~[ewelink-with-deps.jar:?]
        at com.github.realzimboguy.ewelink.api.EweLink.setDeviceStatus(EweLink.java:389) ~[ewelink-with-deps.jar:?]
        at hu.wfs.log4j2peldaprojekt.EwelinkVezerles.lampaKapcsolasa(EwelinkVezerles.java:138) ~[ewelink-with-deps.jar:?]
        at hu.wfs.log4j2peldaprojekt.EwelinkVezerles.lambda$osszesLampaKapcsolasa$0(EwelinkVezerles.java:125) ~[ewelink-with-deps.jar:?]
        at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992) [?:?]
        at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762) [?:?]
        at hu.wfs.log4j2peldaprojekt.EwelinkVezerles.osszesLampaKapcsolasa(EwelinkVezerles.java:124) [ewelink-with-deps.jar:?]
        at hu.wfs.log4j2peldaprojekt.EwelinkVezerles.vezerles(EwelinkVezerles.java:43) [ewelink-with-deps.jar:?]
        at hu.wfs.log4j2peldaprojekt.EwelinkVezerles.main(EwelinkVezerles.java:37) [ewelink-with-deps.jar:?]
2024 10:01:10.647 [main] INFO  hu.wfs.log4j2peldaprojekt.EwelinkVezerles -- lampaKapcsolasa... FOLYOSO_KONYHA off
2024 10:01:10.656 [main] ERROR hu.wfs.log4j2peldaprojekt.EwelinkVezerles -- Problemas lampa: FOLYOSO_KONYHA->1001111531->off
org.java_websocket.exceptions.WebsocketNotConnectedException: null
        at org.java_websocket.WebSocketImpl.send(WebSocketImpl.java:674) ~[ewelink-with-deps.jar:?]
        at org.java_websocket.WebSocketImpl.send(WebSocketImpl.java:650) ~[ewelink-with-deps.jar:?]
        at org.java_websocket.client.WebSocketClient.send(WebSocketClient.java:433) ~[ewelink-with-deps.jar:?]
        at com.github.realzimboguy.ewelink.api.EweLinkWebSocketClient.sendAndWait(EweLinkWebSocketClient.java:83) ~[ewelink-with-deps.jar:?]
        at com.github.realzimboguy.ewelink.api.EweLink.setDeviceStatus(EweLink.java:389) ~[ewelink-with-deps.jar:?]
        at hu.wfs.log4j2peldaprojekt.EwelinkVezerles.lampaKapcsolasa(EwelinkVezerles.java:138) ~[ewelink-with-deps.jar:?]
        at hu.wfs.log4j2peldaprojekt.EwelinkVezerles.lambda$osszesLampaKapcsolasa$0(EwelinkVezerles.java:125) ~[ewelink-with-deps.jar:?]
        at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992) [?:?]
        at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762) [?:?]
        at hu.wfs.log4j2peldaprojekt.EwelinkVezerles.osszesLampaKapcsolasa(EwelinkVezerles.java:124) [ewelink-with-deps.jar:?]
        at hu.wfs.log4j2peldaprojekt.EwelinkVezerles.vezerles(EwelinkVezerles.java:43) [ewelink-with-deps.jar:?]
        at hu.wfs.log4j2peldaprojekt.EwelinkVezerles.main(EwelinkVezerles.java:37) [ewelink-with-deps.jar:?]

@robozb
Copy link
Author

robozb commented Dec 11, 2024

the logins go to

      baseUrl = "https://"+region+"-apia.coolkit.cc/v2/";

the websockets go to

      "wss://"+ region+"-pconnect3.coolkit.cc:8080/api/ws"

region comes from what you init the api ie "eu"

Thank you so much! I check it out :)

@RealZimboGuy
Copy link
Owner

are you doing eweLink.getWebSocket(new WssResponse() {

there has been some issues with trying to turn on/off a device too fast from init. slower things like PI might not have fully setup the websocket connection yet

@robozb
Copy link
Author

robozb commented Dec 11, 2024

I guess this is the code block where the exception arised:

    void lampaKapcsolasa(Lampa lampa, Kapcsolas kapcsolas) {
        if(MOTION_ERTESITES)
            detectionPause();
        try {
            logger.info(String.format(
                "lampaKapcsolasa... %s %s",
                lampa.name(),
                kapcsolas.name()));
            eweLink.setDeviceStatus(lampa.deviceID,kapcsolas.name());
        } catch (Throwable kivetel) {
            logger.error("Problemas lampa: "+lampa.name()+"->"+lampa.deviceID+"->"+kapcsolas.name(),kivetel);
        }        
        if(MOTION_ERTESITES)
            detectionStart();
    }

Sorry for the hungarian language :)

@RealZimboGuy
Copy link
Owner

is

EweLink eweLink  

declared as a static instance or only created once ?

@robozb
Copy link
Author

robozb commented Dec 11, 2024

I'd like to test the API urls to make sure the error not in my code.

@RealZimboGuy
Copy link
Owner

we had issues here #9

where if you did not create the websocket listener it was giving the same error but that should be fixed now

@RealZimboGuy
Copy link
Owner

can you enable log level debug on

 com.github.realzimboguy.ewelink.api

image

expect to see this

@robozb
Copy link
Author

robozb commented Dec 11, 2024

Sorry, here is the code:

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package hu.wfs.log4j2peldaprojekt;

import com.github.realzimboguy.ewelink.api.EweLink;
import com.github.realzimboguy.ewelink.api.wss.WssResponse;
import com.github.realzimboguy.ewelink.api.wss.wssrsp.WssRspMsg;
import java.net.URL;
import java.util.Arrays;
import java.util.Random;


import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.LoggerContext;


/**
 *
 * @author Beci
 */
public class EwelinkVezerles {

    static final boolean MOTION_ERTESITES=false;
    static Logger logger = LogManager.getLogger(EwelinkVezerles.class);
    
    public static void main(String[] args) throws Throwable {
        LoggerContext context = (org.apache.logging.log4j.core.LoggerContext) 
        LogManager.getContext(false);
        // this will force a reconfiguration
        context.setConfigLocation(Naplozo.class.getResource("/log4j2.konfig.xml").toURI());
        logger.info("app start...");
        EwelinkVezerles ev=new EwelinkVezerles();
        ev.vezerles();        
    }    

    
    void vezerles() throws Throwable {
        initEwelink();
        osszesLampaKapcsolasa(Kapcsolas.off);
        float alvas;
        do {
            logger.info("lampa fel-,le-kapcsolasi ciklus START...");
            try {
                Lampa lampa=getRandomLampa();
                lampaKapcsolasa(lampa, Kapcsolas.on);
                alvas=getRandom(5, 30);logger.info("ON SLEEP: "+alvas+" PERC");sleep(alvas);
                lampaKapcsolasa(lampa, Kapcsolas.off);
                alvas=getRandom(2, 5);logger.info("OFF SLEEP: "+alvas+" PERC");sleep(alvas);
            } catch (Throwable kivetel) {
                kivetel.printStackTrace();
            }
            logger.info("lampa fel-,le-kapcsolasi ciklus STOP...");
        } while (true);        
    }
        
    Lampa getRandomLampa() {
        Lampa[] lampak = Lampa.values(); // Az összes lehetséges szín
        int randomIndex = new Random().nextInt(lampak.length); // Véletlen index generálása
        return lampak[randomIndex]; // Visszatérés a véletlenül választott színnel        
    }
    
    enum Kapcsolas {
        on,off
    }
    
    enum Lampa {
        FOLYOSO_AJTO("1001110a16"),
        FOLYOSO_KONYHA("1001111531"),
        WC("1001110831");
        
        private String deviceID;        
        
        private Lampa(String deviceID) {
            this.deviceID = deviceID;
        }
    }        

    
    float getRandom(int tol, int ig) {
        return tol + new Random().nextFloat() * (ig - tol);
    }
    
    void sleep(float perc) {
        try {
            logger.info(String.format("sleep (%.2f)...",perc));
            Thread.currentThread().sleep((int)(perc*1000f*60f));
        } catch (Throwable kivetel) {
            kivetel.printStackTrace();
        }
    }
    
    EweLink eweLink;
    
    public void initEwelink() throws Throwable {
        logger.info("initEwelink START...");
        eweLink = new EweLink("eu", "???", "???", "+36", 60);
        eweLink.login();

        eweLink.getWebSocket(new WssResponse() {

            @Override
            public void onMessage(String s) {
            }

            @Override
            public void onMessageParsed(WssRspMsg rsp) {
            }

            @Override
            public void onError(String error) {
            }
        });  

        Thread.sleep(5000);     
        logger.info("initEwelink STOP...");
    }
    
    void osszesLampaKapcsolasa(Kapcsolas kapcsolas) {
        logger.info("Osszes lampa lekapcsolasa START...");
        Arrays.stream(Lampa.values()).forEach(
            lampa->lampaKapcsolasa(lampa,kapcsolas)
        );
        logger.info("Osszes lampa lekapcsolasa STOP...");
    }
       
    void lampaKapcsolasa(Lampa lampa, Kapcsolas kapcsolas) {
        if(MOTION_ERTESITES)
            detectionPause();
        try {
            logger.info(String.format(
                "lampaKapcsolasa... %s %s",
                lampa.name(),
                kapcsolas.name()));
            eweLink.setDeviceStatus(lampa.deviceID,kapcsolas.name());
        } catch (Throwable kivetel) {
            logger.error("Problemas lampa: "+lampa.name()+"->"+lampa.deviceID+"->"+kapcsolas.name(),kivetel);
        }        
        if(MOTION_ERTESITES)
            detectionStart();
    }
    
    public static void detectionStart() {
        try {
            logger.info("detectionStart...");
            Thread.currentThread().sleep(1000);
            new URL("http://127.0.0.1:8080/1/detection/start").getContent();
            new URL("http://127.0.0.1:8080/2/detection/start").getContent();
            Thread.currentThread().sleep(1000);
        } catch (Exception e) {
            logger.error("Motion Detection pause problema!",e);
        }
    }


    public static void detectionPause() {
        try {
            logger.info("detectionPause...");
            Thread.currentThread().sleep(1000);
            new URL("http://127.0.0.1:8080/1/detection/pause").getContent();
            new URL("http://127.0.0.1:8080/2/detection/pause").getContent();
            Thread.currentThread().sleep(1000);
        } catch (Exception e) {
            logger.error("Motion Detection pause problema!",e);
        }
    }
    
}




@robozb
Copy link
Author

robozb commented Dec 11, 2024

Thank you so much for your lot of help :)

@robozb
Copy link
Author

robozb commented Dec 11, 2024

can you enable log level debug on

 com.github.realzimboguy.ewelink.api

image

expect to see this

The debuged output on Linux (still Win10 ok)

/Java17SDK/jdk-17.0.12/bin/java -jar ~/Ewelink_2023_09_II/hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-w                                                                                                                                                                                                ith-dependencies.jar
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
2024 10:18:58.455 [main] INFO  hu.wfs.log4j2peldaprojekt.EwelinkVezerles -- app start...
2024 10:18:58.460 [main] INFO  hu.wfs.log4j2peldaprojekt.EwelinkVezerles -- initEwelink START...
2024 10:18:58.590 [main] INFO  com.github.realzimboguy.ewelink.api.EweLink -- EweLinkApi startup params : eu ???
2024 10:18:59.470 [main] INFO  com.github.realzimboguy.ewelink.api.EweLink -- {"lang":"en","countryCode":"+36","email":"???","password":"???","os":"Android","model":"Pixel 4a (5G)_bramble","romVersion":"13","appVersion":"5.0.0"}
2024 10:18:59.485 [main] INFO  com.github.realzimboguy.ewelink.api.EweLink -- Login Request:{}LoginRequest{lang='en', countryCode='+36', email='???', password='???', os='Android', model='Pixel 4a (5G)_bramble', romVersion='13', appVersion='5.0.0'}
2024 10:19:05.549 [main] INFO  com.github.realzimboguy.ewelink.api.EweLink -- Login Response Code :200
2024 10:19:05.554 [main] INFO  com.github.realzimboguy.ewelink.api.EweLink -- Login Response Raw:{}{"error":0,"msg":"","data":{"user":{"timezone":{"id":"Europe/Budapest","offset":2},"accountLevel":10,"countryCode":"+36","email":"???","apikey":"???-3c64-4f3c-a0b6-1664d23aeda0","accountConsult":false,"appForumEnterHide":false,"appVersion":"5.9.0","denyRecharge":false,"ipCountry":"HU"},"at":"52ea643be3791eb6ba35d441c830dab0fa666881","rt":"5b92685aeb25cf170317d3a5e1c7dfe7dd7e5951","region":"eu"}}
2024 10:19:05.590 [main] INFO  com.github.realzimboguy.ewelink.api.EweLink -- Login Response:{}com.github.realzimboguy.ewelink.api.model.login.LoginResponse@64bce832
2024 10:19:05.591 [main] INFO  com.github.realzimboguy.ewelink.api.EweLink -- accessToken:{}52ea643be3791eb6ba35d441c830dab0fa666881
2024 10:19:05.593 [main] INFO  com.github.realzimboguy.ewelink.api.EweLink -- apiKey:{}???-3c64-4f3c-a0b6-1664d23aeda0
2024 10:19:05.684 [Thread-1] INFO  com.github.realzimboguy.ewelink.api.EweLink$WebSocketMonitor -- Websocket Monitor Thread start
2024 10:19:10.683 [main] INFO  hu.wfs.log4j2peldaprojekt.EwelinkVezerles -- initEwelink STOP...
2024 10:19:10.685 [main] INFO  hu.wfs.log4j2peldaprojekt.EwelinkVezerles -- Osszes lampa lekapcsolasa START...
2024 10:19:10.692 [main] INFO  hu.wfs.log4j2peldaprojekt.EwelinkVezerles -- lampaKapcsolasa... FOLYOSO_AJTO off
2024 10:19:10.693 [main] INFO  com.github.realzimboguy.ewelink.api.EweLink -- Setting device 1001110a16 status to off
2024 10:19:10.826 [main] DEBUG com.github.realzimboguy.ewelink.api.EweLink -- StatusChange WS Request:{"sequence":"1733908750694","userAgent":"app","action":"update","deviceid":"1001110a16","apikey":"???-3c64-4f3c-a0b6-1664d23aeda0","selfApikey":"???-3c64-4f3c-a0b6-1664d23aeda0","params":{"switch":"off"}}
2024 10:19:10.833 [main] ERROR hu.wfs.log4j2peldaprojekt.EwelinkVezerles -- Problemas lampa: FOLYOSO_AJTO->1001110a16->off
org.java_websocket.exceptions.WebsocketNotConnectedException: null
        at org.java_websocket.WebSocketImpl.send(WebSocketImpl.java:674) ~[hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at org.java_websocket.WebSocketImpl.send(WebSocketImpl.java:650) ~[hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at org.java_websocket.client.WebSocketClient.send(WebSocketClient.java:433) ~[hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at com.github.realzimboguy.ewelink.api.EweLinkWebSocketClient.sendAndWait(EweLinkWebSocketClient.java:83) ~[hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at com.github.realzimboguy.ewelink.api.EweLink.setDeviceStatus(EweLink.java:389) ~[hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at hu.wfs.log4j2peldaprojekt.EwelinkVezerles.lampaKapcsolasa(EwelinkVezerles.java:138) ~[hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at hu.wfs.log4j2peldaprojekt.EwelinkVezerles.lambda$osszesLampaKapcsolasa$0(EwelinkVezerles.java:125) ~[hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992) [?:?]
        at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762) [?:?]
        at hu.wfs.log4j2peldaprojekt.EwelinkVezerles.osszesLampaKapcsolasa(EwelinkVezerles.java:124) [hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at hu.wfs.log4j2peldaprojekt.EwelinkVezerles.vezerles(EwelinkVezerles.java:43) [hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at hu.wfs.log4j2peldaprojekt.EwelinkVezerles.main(EwelinkVezerles.java:37) [hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
2024 10:19:10.875 [main] INFO  hu.wfs.log4j2peldaprojekt.EwelinkVezerles -- lampaKapcsolasa... FOLYOSO_KONYHA off
2024 10:19:10.876 [main] INFO  com.github.realzimboguy.ewelink.api.EweLink -- Setting device 1001111531 status to off
2024 10:19:10.878 [main] DEBUG com.github.realzimboguy.ewelink.api.EweLink -- StatusChange WS Request:{"sequence":"1733908750877","userAgent":"app","action":"update","deviceid":"1001111531","apikey":"???-3c64-4f3c-a0b6-1664d23aeda0","selfApikey":"???-3c64-4f3c-a0b6-1664d23aeda0","params":{"switch":"off"}}
2024 10:19:10.879 [main] ERROR hu.wfs.log4j2peldaprojekt.EwelinkVezerles -- Problemas lampa: FOLYOSO_KONYHA->1001111531->off
org.java_websocket.exceptions.WebsocketNotConnectedException: null
        at org.java_websocket.WebSocketImpl.send(WebSocketImpl.java:674) ~[hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at org.java_websocket.WebSocketImpl.send(WebSocketImpl.java:650) ~[hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at org.java_websocket.client.WebSocketClient.send(WebSocketClient.java:433) ~[hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at com.github.realzimboguy.ewelink.api.EweLinkWebSocketClient.sendAndWait(EweLinkWebSocketClient.java:83) ~[hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at com.github.realzimboguy.ewelink.api.EweLink.setDeviceStatus(EweLink.java:389) ~[hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at hu.wfs.log4j2peldaprojekt.EwelinkVezerles.lampaKapcsolasa(EwelinkVezerles.java:138) ~[hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at hu.wfs.log4j2peldaprojekt.EwelinkVezerles.lambda$osszesLampaKapcsolasa$0(EwelinkVezerles.java:125) ~[hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992) [?:?]
        at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762) [?:?]
        at hu.wfs.log4j2peldaprojekt.EwelinkVezerles.osszesLampaKapcsolasa(EwelinkVezerles.java:124) [hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at hu.wfs.log4j2peldaprojekt.EwelinkVezerles.vezerles(EwelinkVezerles.java:43) [hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at hu.wfs.log4j2peldaprojekt.EwelinkVezerles.main(EwelinkVezerles.java:37) [hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
2024 10:19:10.882 [main] INFO  hu.wfs.log4j2peldaprojekt.EwelinkVezerles -- lampaKapcsolasa... WC off
2024 10:19:10.894 [main] INFO  com.github.realzimboguy.ewelink.api.EweLink -- Setting device 1001110831 status to off
2024 10:19:10.896 [main] DEBUG com.github.realzimboguy.ewelink.api.EweLink -- StatusChange WS Request:{"sequence":"1733908750895","userAgent":"app","action":"update","deviceid":"1001110831","apikey":"???-3c64-4f3c-a0b6-1664d23aeda0","selfApikey":"???-3c64-4f3c-a0b6-1664d23aeda0","params":{"switch":"off"}}
2024 10:19:10.899 [main] ERROR hu.wfs.log4j2peldaprojekt.EwelinkVezerles -- Problemas lampa: WC->1001110831->off
org.java_websocket.exceptions.WebsocketNotConnectedException: null
        at org.java_websocket.WebSocketImpl.send(WebSocketImpl.java:674) ~[hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at org.java_websocket.WebSocketImpl.send(WebSocketImpl.java:650) ~[hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at org.java_websocket.client.WebSocketClient.send(WebSocketClient.java:433) ~[hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at com.github.realzimboguy.ewelink.api.EweLinkWebSocketClient.sendAndWait(EweLinkWebSocketClient.java:83) ~[hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at com.github.realzimboguy.ewelink.api.EweLink.setDeviceStatus(EweLink.java:389) ~[hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at hu.wfs.log4j2peldaprojekt.EwelinkVezerles.lampaKapcsolasa(EwelinkVezerles.java:138) ~[hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at hu.wfs.log4j2peldaprojekt.EwelinkVezerles.lambda$osszesLampaKapcsolasa$0(EwelinkVezerles.java:125) ~[hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992) [?:?]
        at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762) [?:?]
        at hu.wfs.log4j2peldaprojekt.EwelinkVezerles.osszesLampaKapcsolasa(EwelinkVezerles.java:124) [hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at hu.wfs.log4j2peldaprojekt.EwelinkVezerles.vezerles(EwelinkVezerles.java:43) [hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at hu.wfs.log4j2peldaprojekt.EwelinkVezerles.main(EwelinkVezerles.java:37) [hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
2024 10:19:10.902 [main] INFO  hu.wfs.log4j2peldaprojekt.EwelinkVezerles -- Osszes lampa lekapcsolasa STOP...
2024 10:19:10.903 [main] INFO  hu.wfs.log4j2peldaprojekt.EwelinkVezerles -- lampa fel-,le-kapcsolasi ciklus START...
2024 10:19:10.904 [main] INFO  hu.wfs.log4j2peldaprojekt.EwelinkVezerles -- lampaKapcsolasa... FOLYOSO_KONYHA on
2024 10:19:10.905 [main] INFO  com.github.realzimboguy.ewelink.api.EweLink -- Setting device 1001111531 status to on
2024 10:19:10.906 [main] DEBUG com.github.realzimboguy.ewelink.api.EweLink -- StatusChange WS Request:{"sequence":"1733908750905","userAgent":"app","action":"update","deviceid":"1001111531","apikey":"???-3c64-4f3c-a0b6-1664d23aeda0","selfApikey":"???-3c64-4f3c-a0b6-1664d23aeda0","params":{"switch":"on"}}
2024 10:19:10.908 [main] ERROR hu.wfs.log4j2peldaprojekt.EwelinkVezerles -- Problemas lampa: FOLYOSO_KONYHA->1001111531->on
org.java_websocket.exceptions.WebsocketNotConnectedException: null
        at org.java_websocket.WebSocketImpl.send(WebSocketImpl.java:674) ~[hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at org.java_websocket.WebSocketImpl.send(WebSocketImpl.java:650) ~[hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at org.java_websocket.client.WebSocketClient.send(WebSocketClient.java:433) ~[hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at com.github.realzimboguy.ewelink.api.EweLinkWebSocketClient.sendAndWait(EweLinkWebSocketClient.java:83) ~[hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at com.github.realzimboguy.ewelink.api.EweLink.setDeviceStatus(EweLink.java:389) ~[hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at hu.wfs.log4j2peldaprojekt.EwelinkVezerles.lampaKapcsolasa(EwelinkVezerles.java:138) [hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at hu.wfs.log4j2peldaprojekt.EwelinkVezerles.vezerles(EwelinkVezerles.java:49) [hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
        at hu.wfs.log4j2peldaprojekt.EwelinkVezerles.main(EwelinkVezerles.java:37) [hu.wfs.EweLink_2023_09_II-1.0-SNAPSHOT-jar-with-dependencies.jar:?]
2024 10:19:10.927 [main] INFO  hu.wfs.log4j2peldaprojekt.EwelinkVezerles -- ON SLEEP: 6.1539936 PERC
2024 10:19:10.931 [main] INFO  hu.wfs.log4j2peldaprojekt.EwelinkVezerles -- sleep (6.15)...
2024 10:19:35.685 [Thread-1] DEBUG com.github.realzimboguy.ewelink.api.EweLink$WebSocketMonitor -- send websocket ping
2024 10:19:35.704 [WebSocketConnectReadThread-17] DEBUG com.github.realzimboguy.ewelink.api.EweLinkWebSocketClient -- pong

@RealZimboGuy
Copy link
Owner

code looks ok, try to check network

  telnet    eu-apia.coolkit.cc 443
  
  telnet   eu-pconnect3.coolkit.cc 8080

then next to check if server SSL CA certificates ok

  curl -v https://eu-apia.coolkit.cc/v2/user/login
  
  npm install -g wscat
  wscat -c wss://eu-pconnect3.coolkit.cc:8080/api/ws

@RealZimboGuy
Copy link
Owner

curl should return {"error":403,"msg":"api not found","data":{}}%

and wscat should show
Connected (press CTRL+C to quit)

@robozb
Copy link
Author

robozb commented Dec 11, 2024

The results:

Python:

 cat test_ws.py
import websocket

def on_message(ws, message):
    print(f"Message received: {message}")

def on_error(ws, error):
    print(f"Error: {error}")

def on_close(ws, close_status_code, close_msg):
    print("Connection closed")

def on_open(ws):
    print("Connection opened")
    ws.send("Hello, WebSocket!")

url = "wss://eu-pconnect3.coolkit.cc:8080/api/ws"

ws = websocket.WebSocketApp(url,
                            on_message=on_message,
                            on_error=on_error,
                            on_close=on_close)
ws.on_open = on_open
ws.run_forever()
robozb@rpi4:~ $ python test_ws.py
Connection opened
Connection closed
robozb@rpi4:~ $ ^C

@robozb
Copy link
Author

robozb commented Dec 11, 2024

The next one

telnet    eu-apia.coolkit.cc 443
Trying 3.66.104.106...
Connected to eu-api-elb-1968000189.eu-central-1.elb.amazonaws.com.

@robozb
Copy link
Author

robozb commented Dec 11, 2024

the next ones:

telnet   eu-pconnect3.coolkit.cc 8080
Trying 18.196.59.155...
Connected to eu-pconnect3.coolkit.cc.
Escape character is '^]'.
^CConnection closed by foreign host.
robozb@rpi4:~ $ curl -v https://eu-apia.coolkit.cc/v2/user/login
*   Trying 3.66.104.106:443...
* Connected to eu-apia.coolkit.cc (3.66.104.106) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*  CAfile: /etc/ssl/certs/ca-certificates.crt
*  CApath: /etc/ssl/certs
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
* TLSv1.3 (IN), TLS handshake, Server hello (2):
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
* TLSv1.3 (IN), TLS handshake, Certificate (11):
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
* TLSv1.3 (IN), TLS handshake, Finished (20):
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.3 (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256
* ALPN, server accepted to use h2
* Server certificate:
*  subject: CN=*.coolkit.cc
*  start date: Feb  5 00:00:00 2024 GMT
*  expire date: Mar  5 23:59:59 2025 GMT
*  subjectAltName: host "eu-apia.coolkit.cc" matched cert's "*.coolkit.cc"
*  issuer: C=US; O=Amazon; CN=Amazon RSA 2048 M03
*  SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x559ce50060)
> GET /v2/user/login HTTP/2
> Host: eu-apia.coolkit.cc
> user-agent: curl/7.74.0
> accept: */*
>
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* Connection state changed (MAX_CONCURRENT_STREAMS == 128)!
< HTTP/2 200
< date: Wed, 11 Dec 2024 09:28:22 GMT
< content-type: application/json
< content-length: 45
<
* Connection #0 to host eu-apia.coolkit.cc left intact
{"error":403,"msg":"api not found","data":{}}robozb@rpi4:

@robozb
Copy link
Author

robozb commented Dec 11, 2024

So it seems the connection was successful

@RealZimboGuy
Copy link
Owner

a bit of a guess, can you try with another JRE ie

https://docs.aws.amazon.com/corretto/latest/corretto-17-ug/downloads-list.html

@robozb
Copy link
Author

robozb commented Dec 11, 2024

The wscat output:

root@rpi4:~# wscat -c wss://eu-pconnect3.coolkit.cc:8080/api/ws
Connected (press CTRL+C to quit)
>

@robozb
Copy link
Author

robozb commented Dec 11, 2024

a bit of a guess, can you try with another JRE ie

https://docs.aws.amazon.com/corretto/latest/corretto-17-ug/downloads-list.html

Thanks for your help! I will give a feedback about the solution (if it is possible :) )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants