nocmt / ewelink-api-next

CoolKit v2 API Official Library
MIT License
19 stars 4 forks source link

Clarification for Web Socket Server #9

Closed geniqtech closed 12 months ago

geniqtech commented 1 year ago

Will the Web Socket Server work for Free account user? Tested using the sample code but onMessage event does not trigger when I turn my device on and off. Also I noticed that the connection automatically cuts off after a few minutes.

[2023-09-04T14:45:52.642] [INFO] as - WebSocket connection has been established [2023-09-04T14:45:52.642] [INFO] as - Send userOnline message: {"action":"userOnline","at":"","apikey":"","appid":"xxx","nonce":"yyy","userAgent":"app","sequence":"1693809952642"} [2023-09-04T14:48:32.651] [INFO] as - WebSocket connection has been closed

nocmt commented 1 year ago

Applicable to all users, it is necessary to ensure that at and user information have been obtained.

https://github.com/coolkit-carl/ewelink-api-next/blob/main/test/WSSControlDemo.ts

It is a relatively complete example that you can modify to use.

geniqtech commented 1 year ago

Tried referencing the example code but if I try to set at using: at: wsClient.at => the log file will print empty value for at.

If I try to manually set using: at: 'xxxxx' => the value of at will be printed in log file however it still does not work.

onMessage() event does not fire at all.

Can I also confirm that userApiKey is the same as appSecret?

geniqtech commented 1 year ago

Read through the guide/references again. It seems that for Web Socket Server, we will need to use userApiKey that is not the same as appSecret.

I'm using OAuth 2.0 method via free API. Where can I get this userApiKey?

geniqtech commented 1 year ago

@coolkit-carl Can't figure out what was your response in previous post. Can you kindly enlighten?

ghost commented 1 year ago

@coolkit-carl Can't figure out what was your response in previous post. Can you kindly enlighten?

image

geniqtech commented 12 months ago

Ok got it but would be clearer if the documentation stated this clearly in the first place. Also would be nice if this User API Key is shown on the developer portal.