Skip to content

SinricP Doorbell - websockets problem?? #17

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

Closed
steve8266 opened this issue Dec 17, 2019 · 8 comments
Closed

SinricP Doorbell - websockets problem?? #17

steve8266 opened this issue Dec 17, 2019 · 8 comments

Comments

@steve8266
Copy link

Hi,
I'm still trying hard to get the doorbell working. I'm using all the latest libraries (note: vs 2.2.6 was same) and the original code etc, using platformio on a nodemcu. Sometimes when I compile it works absolutely fine, press the button and alexa does what she should. Other times and most often it fails to start properly - please see terminal output below (debug on). I dont think its my router because everything I've got on original sinric is still working 100%. It looks to me (non expert eye) that its some kind of websockets timeout issue. That's the only explanation I've got, but why does it work sometimes and not others...

I would really appreciate your help please. Terminal output as follows:
SDK:2.2.2-dev(38a443e)/Core:2.6.3=20603000/lwIP:STABLE-2_1_2_RELEASE/glue:1.2-16-ge23a07e/BearSSL:89454af

state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 6
cnt

connected with BTHub6-xxxxx, channel 11
dhcp client start...
....ip:192.168.x.xxx,mask:255.255.255.0,gw:192.168.x.xxx
connected!
WiFi: IP-Address is 192.168.x.xxx
[SinricPro:add()]: Adding device with id "5de3974a5xxxxxxxxxxxxxxxx".
[SinricPro:Websocket]: Connecting to WebSocket Server (ws.sinric.pro)
[SinricPro:Websocket]: headers:
appkey:f5dd293a-8ad0-xxxx-xxxx-xxxxxxxxxxxx
deviceids:5de3974a553xxxxxxxxxxxxx
restoredevicestates:false
platform:ESP8266
version:2.2.7
[WS-Client] connect ws...
[WS-Client] connected to ws.sinric.pro:80.
[WS-Client][sendHeader] sending header...
[WS-Client][sendHeader] handshake GET / HTTP/1.1
Host: ws.sinric.pro:80
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: woG190jRBoTZcY4NwXar6Q==
Sec-WebSocket-Protocol: arduino
appkey:f5dd293a-8ad0-xxxx-xxxx-xxxxxxxxxxxx
deviceids:5de3974axxxxxxxxxxxxxxxx
restoredevicestates:false
platform:ESP8266
version:2.2.7
User-Agent: arduino-WebSocket-Client

[write] n: 367 t: 7126
[WS-Client][sendHeader] sending header... Done (33927us).
[WS-Client][handleHeader] RX: HTTP/1.1 101 Switching Protocols
[WS-Client][handleHeader] RX: Server: nginx
[WS-Client][handleHeader] RX: Date: Tue, 17 Dec 2019 20:56:39 GMT
[WS-Client][handleHeader] RX: Connection: upgrade
[WS-Client][handleHeader] RX: Upgrade: websocket
[WS-Client][handleHeader] RX: Sec-WebSocket-Accept: bCCnndFQKswdSP7/ex9TKFqCDYk=
[WS-Client][handleHeader] RX: Sec-WebSocket-Protocol: arduino
[WS-Client][handleHeader] Header read fin.
[WS-Client][handleHeader] Client settings:
[WS-Client][handleHeader] - cURL: /
[WS-Client][handleHeader] - cKey: woG190jRBoTZcY4NwXar6Q==
[WS-Client][handleHeader] Server header:
[WS-Client][handleHeader] - cCode: 101
[WS-Client][handleHeader] - cIsUpgrade: 1
[WS-Client][handleHeader] - cIsWebsocket: 1
[WS-Client][handleHeader] - cAccept: bCCnndFQKswdSP7/ex9TKFqCDYk=
[WS-Client][handleHeader] - cProtocol: arduino
[WS-Client][handleHeader] - cExtensions:
[WS-Client][handleHeader] - cVersion: 0
[WS-Client][handleHeader] - cSessionId:
[WS-Client][handleHeader] Websocket connection init done.
[WS][0][headerDone] Header Handling Done.
[SinricPro:Websocket]: connected
[WS][0][handleWebsocketWaitFor] size: 2 cWsRXsize: 0
[readCb] n: 2 t: 7313
[WS][0][handleWebsocketWaitFor][readCb] size: 2 ok: 1
[WS][0][handleWebsocket] ------- read massage frame -------
[WS][0][handleWebsocket] fin: 1 rsv1: 0 rsv2: 0 rsv3 0 opCode: 1
[WS][0][handleWebsocket] mask: 0 payloadLen: 24
[readCb] n: 24 t: 7335
[WS][0][handleWebsocket] text: {"timestamp":1576616199}
[SinricPro:Websocket]: receiving data
[SinricPro.handleReceiveQueue()]: 1 message(s) in receiveQueue
[SinricPro.handleReceiveQueue()]: Signature is valid. Processing message...
[SinricPro:extractTimestamp(): Got Timestamp 1576616199
[HBtimeout] pong TIMEOUT! lp=-290499 millis=10001 pi=10001 count=1
[WS-Client] sending HB ping
[WS][0][sendFrame] ------- send message frame -------
[WS][0][sendFrame] fin: 1 opCode: 9 mask: 1 length: 0 headerToPayload: 0
[write] n: 6 t: 10009
[WS][0][sendFrame] sending Frame Done (3042us).
bcn_timout,ap_probe_send_start
pm open,type:2 0
ap_probe_send over, rest wifi status to disassoc
state: 5 -> 0 (1)
rm 0
pm close 7
[WS-Client] connection lost.
[WS-Client] client disconnected.
[SinricPro:Websocket]: disconnected
[WS-Client] connect ws...
[WS-Client] connection to ws.sinric.pro:80 Failed
[WS-Client] client disconnected.
[WS-Client] connect ws...
[WS-Client] connection to ws.sinric.pro:80 Failed
................etc etc continuously..............

Your comments/advice please.
Regards, Steve

@sivar2311
Copy link
Collaborator

Hi Steve,

this looks like a weak wifi connection.

@steve8266
Copy link
Author

I’m 2m away from the router. And did a scan check. It’s strong.

@steve8266
Copy link
Author

Also tried with different nodemcu board

@steve8266
Copy link
Author

But you’ve set me thinking. Maybe the ip the router allocates or the channel it’s picking up. I’ll compare a good run with the bad runs to see if there’s a pattern. Also I have UDP packets buzzing around on my network cos of other home automation stuff. Could that interfere??

@kakopappa
Copy link
Contributor

kakopappa commented Dec 18, 2019 via email

@sivar2311
Copy link
Collaborator

I compared the log with my own log.
Problem starts here (i dont have this in my logs)

pm open,type:2 0
ap_probe_send over, rest wifi status to disassoc
state: 5 -> 0 (1)
rm 0
pm close 7

Your module seems to disconnect from wifi and set sleepmode (see here esp8266/Arduino#4455 (comment))
(Even Ivan Grokhotkov doesnt know the complete meaning, because there is no documentation about).
I think the tip about setSleepMode could be the right way.

@sivar2311
Copy link
Collaborator

While investigating about ESP wifi logs i can say this is a wifi issue!
bcn_timout,ap_probe_send_start means:
ESP didnt received AP beacon for a while and do a request to your access point ("Hey AP, are you still there?")
ap_probe_send over, rest wifi status to disassoc means:
ESP didnt get a response from AP -> ESP is closing wifi connection.

Are your other ESP's connected to the same Access Point?
Try to use another Acccess Point -> Use your phone to open an Access Point and connect your ESP to this one

@steve8266
Copy link
Author

Gents,
Many thanks indeed for your time and advice. I’ll try the nosleep straightaway but also follow the AP route separately at same time. Regards, Steve

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

3 participants