mdopp / simple-sonoff-server

Emulates the original sonoff-cloud-servers within your local network.
BSD 2-Clause "Simplified" License
144 stars 47 forks source link

Disconnects exactly after one minute and never connects again #31

Open juancgalvez opened 6 years ago

juancgalvez commented 6 years ago

I tried with node-red-contrib-sonoff-server and noticed that after exactly one minute the device times out and disconnects.

Then I installed your software and the same thing happens exactly one minute after the device connects for the first time, and never reconnects again.

This is what I get:

SONOFF Server Started On Port 1080 API Server Started On Port 1081 WS | Server is up 192.168.7.118:1443 to ::ffff:192.168.7.108:27428 REQ | WS | DEV | {"userAgent":"device","apikey":"22d634b7-6a4b-4253-be7d-7835fcc213ad","deviceid":"100000xxxx","action":"register","version":2,"romVersion":"1.2.0","model":"ITA-GZ1-GL","ts":206} INFO | WS | Device 100000xxxx registered RES | WS | DEV | {"error":0,"deviceid":"100000xxxx","apikey":"111111111-1111-1111-1111-111111111111"} REQ | WS | DEV | {"userAgent":"device","apikey":"111111111-1111-1111-1111-11111111111","deviceid":"100000xxxx","action":"date"} RES | WS | DEV | {"error":0,"deviceid":"100000xxxx","apikey":"111111111-1111-1111-1111-111111111111","date":"2018-05-24T21:23:42.314Z"} REQ | WS | DEV | {"userAgent":"device","apikey":"111111111-1111-1111-1111-11111111111","deviceid":"100000xxxx","action":"update","params":{"switch":"off","fwVersion":"1.2.0"}} RES | WS | DEV | {"error":0,"deviceid":"100000xxxx","apikey":"111111111-1111-1111-1111-111111111111"} REQ | WS | DEV | {"userAgent":"device","apikey":"111111111-1111-1111-1111-11111111111","deviceid":"100000xxxx","action":"query","params":["timers"]} RES | WS | DEV | {"error":0,"deviceid":"100000xxxx","apikey":"111111111-1111-1111-1111-111111111111","params":{}} Connection closed: connection timed out (408) Device 100000xxxx disconnected

I replaced my device's last four digits with xxxx.

What could be wrong?

pabloalcantara commented 6 years ago

I was having the same problem on m Raspberry pi 3. So I changed to Windows and now the disconnection rate is much, much less.

juancgalvez commented 6 years ago

Thank you for your reply.

I upgraded my Sonoff to firmware version 1.6 and everything stopped working. The device didn't even connect to itead's server.

Finally, I flashed Espurna and everything is working fine with Node-red using MQTT and HTTP API.

ricardojlrufino commented 6 years ago

It looks like the updated firmware does an SSL certificate validation, so it will not work.

ricardojlrufino commented 6 years ago

On disconnecting every time, it happens to me too ... Even in the Java implementation I did. But, it reconnects again ... but this seems to me to be a problem

It seems to me that some PING / PONG control is missing in particular.

mdopp commented 6 years ago

@juancgalvez upgrading to 1.6 will break the the used interface due to a verified ssl certificate mirko/SonOTA#58

6

mdopp commented 6 years ago

@ricardojlrufino I would search for the disconnects inside your local network or an software. Using OpenHab on a Raspberry runs fine, without unexpected disconnects

ricardojlrufino commented 6 years ago

I implemented a java version, and a fixed a BUG in PING, because it have no data... A library I used had this problem