RealZimboGuy / ewelink-api-java

Java Api for the Sonoff ewelink
http://ewelink-api-java.co.zw/
15 stars 5 forks source link

error while trying to change device status #9

Closed Elio-Chedid closed 5 months ago

Elio-Chedid commented 6 months ago

org.java_websocket.exceptions.WebsocketNotConnectedException at org.java_websocket.WebSocketImpl.send(WebSocketImpl.java:628) at org.java_websocket.WebSocketImpl.send(WebSocketImpl.java:605) at org.java_websocket.client.WebSocketClient.send(WebSocketClient.java:410) at com.github.realzimboguy.ewelink.api.EweLinkWebSocketClient.sendAndWait(EweLinkWebSocketClient.java:83) at com.github.realzimboguy.ewelink.api.EweLink.setDeviceStatus(EweLink.java:380) at com.github.realzimboguy.ewelink.api.TestCode.main(TestCode.java:35)

when the code tries to execute ewelink.setDeviceStatus method this exception is thrown any fix?

RealZimboGuy commented 6 months ago

Hi,

I think this is because of trying to call too soon after the login a message that requires the websocket. Can you try put a thread sleep of a few seconds after the setup of the api. Or before your first status call.

On Sat, Mar 30, 2024, 7:13 PM Elio-Chedid @.***> wrote:

org.java_websocket.exceptions.WebsocketNotConnectedException at org.java_websocket.WebSocketImpl.send(WebSocketImpl.java:628) at org.java_websocket.WebSocketImpl.send(WebSocketImpl.java:605) at org.java_websocket.client.WebSocketClient.send(WebSocketClient.java:410) at com.github.realzimboguy.ewelink.api.EweLinkWebSocketClient.sendAndWait(EweLinkWebSocketClient.java:83) at com.github.realzimboguy.ewelink.api.EweLink.setDeviceStatus(EweLink.java:380) at com.github.realzimboguy.ewelink.api.TestCode.main(TestCode.java:35)

when the code tries to execute ewelink.setDeviceStatus method this exception is thrown any fix?

— Reply to this email directly, view it on GitHub https://github.com/RealZimboGuy/ewelink-api-java/issues/9, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADYYQWERUFQNZSZNHBHBYXTY23QEHAVCNFSM6AAAAABFPWIG3GVHI2DSMVQWIX3LMV43ASLTON2WKOZSGIYTMNJYHAYDQNQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Elio-Chedid commented 6 months ago

Hi, I think this is because of trying to call too soon after the login a message that requires the websocket. Can you try put a thread sleep of a few seconds after the setup of the api. Or before your first status call. On Sat, Mar 30, 2024, 7:13 PM Elio-Chedid @.> wrote: org.java_websocket.exceptions.WebsocketNotConnectedException at org.java_websocket.WebSocketImpl.send(WebSocketImpl.java:628) at org.java_websocket.WebSocketImpl.send(WebSocketImpl.java:605) at org.java_websocket.client.WebSocketClient.send(WebSocketClient.java:410) at com.github.realzimboguy.ewelink.api.EweLinkWebSocketClient.sendAndWait(EweLinkWebSocketClient.java:83) at com.github.realzimboguy.ewelink.api.EweLink.setDeviceStatus(EweLink.java:380) at com.github.realzimboguy.ewelink.api.TestCode.main(TestCode.java:35) when the code tries to execute ewelink.setDeviceStatus method this exception is thrown any fix? — Reply to this email directly, view it on GitHub <#9>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADYYQWERUFQNZSZNHBHBYXTY23QEHAVCNFSM6AAAAABFPWIG3GVHI2DSMVQWIX3LMV43ASLTON2WKOZSGIYTMNJYHAYDQNQ . You are receiving this because you are subscribed to this thread.Message ID: @.>

I executed the test code where Thread.sleep(10000) was called

RealZimboGuy commented 5 months ago

not sure what to say the sample code still works for me

image

Leocim commented 5 months ago

@Elio-Chedid

Atualize a sua biblioteca Java-WebSocket para Java-WebSocket-1.5.6, pra mim deu certo, estava com o mesmo erro seu.

RealZimboGuy commented 5 months ago

thanks @Leocim

i have pushed a new version to maven central


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