sinricpro / non-sdk-issues

Report non sdk related issues here (Alexa, Google Home, SmartThings, IFTTT, API)
2 stars 0 forks source link

Frequently facing delays on ESP32 homemade switch triggering #25

Closed cefranco76 closed 3 years ago

cefranco76 commented 3 years ago

Hi,

I'm facing some issues when I trigger switches, it takes too long to command to take effect, sometimes I receive a timeout message or the command is completly ignored, even when I switch in SinricPro APP. I use ESP32 homemade switches and has been working for almost two years with Sinric v1 without this kind of problems.

I had supposed that the problem was my code, cause I use other libraries as MQTT for example and there's a lot of stuff going on in my loop(){}. So, to get the proof, I uploaded the switch.ino sketch provided on ESP32 SDK and the problem persisted.

Switch's key used on tests ==> "60622b4141a7a97d3ef507b0"

print2 print1

kakopappa commented 3 years ago

After looking at the logs, it seems your ESP device has connection issues. It connects/drops which may be the reason why commands do not get through. Maybe it drops the connection because you are blocking the loop(). Since you haven't uploaded the complete code it's very hard for us to debug this. Example "Switch" sketch worked for me

You can see these connection/disconnections in the "Activity Log" in Portal.

  1. Enable debug logs in the SDK. Uncomment this line https://github.com/sinricpro/esp8266-esp32-sdk/blob/master/examples/Switch/Switch/Switch.ino#L18
  2. Change the log level in Arduino

image

  1. Start a hotspot in your mobile. change the "Switch" sketch code to use the hotspot and connect to the server
cefranco76 commented 3 years ago

Hi kakopappa,

I've followed your instructions and upload the oficial "Switch.ino" in a ESP32 device. Approximately every five minutes the device is disconnected and connects again.

Is it normal? Is it related with my problem, in your opinion?! SwitchINO SwitchINO_B

cefranco76 commented 3 years ago

Look at this.... SwitchINO_C

sivar2311 commented 3 years ago

Please set the ESP Core debug level as mentioned by kakaopappa to see what happens on your ESP-32's WiFi side. The SinricProDebug log is not sufficient for this, because it tells nothing about WiFi / SSL.

kakopappa commented 3 years ago

I did a test with the latest version of SDK / ESP-Core/ WebSocket. It connects once and you can see WebSocket is sending heartbeats afterwards

image

cefranco76 commented 3 years ago

Well.... so it is! Any ideia how to solve?

SwitchINO_D

sivar2311 commented 3 years ago

These are not issues.

  1. Our SSL is not using certificates to verify the server - that's why you see "INSECURE" <- not an issue!
  2. setOption is not an error. SSL connection is established <- not related to this issue

The log from above does not show any disconnections like the log you posted before. Wether the time frame (5 mins) is to short, or the issue disappered due to some other reasons

kakopappa commented 3 years ago

whether you used a mobile hotspot vs WiFi is it same ?

On Fri, 9 Apr 2021 at 12:58 AM Boris Jäger @.***> wrote:

These are not issues.

  1. Our SSL is not using certificates to verify the server - that's why you see "INSECURE" <- not an issue!
  2. setOption is not an error. SSL connection is established <- not related to this issue

The log from above does not show any disconnections like the log you posted before. Wether the time frame (5 mins) is to short, or the issue disappered due to some other reasons

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sinricpro/non-sdk-issues/issues/25#issuecomment-816024331, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZAZZTMIMG2B7OMXKKQJODTHXVERANCNFSM42PWZV2Q .

cefranco76 commented 3 years ago

Nope, here is the debug when connected over mobile phone hotspot... It took a bit longer to appear the message "Cleanning SSL connection" and reconnect.

SwitchINO_E

whether you used a mobile hotspot vs WiFi is it same ? On Fri, 9 Apr 2021 at 12:58 AM Boris Jäger @.***> wrote: These are not issues. 1. Our SSL is not using certificates to verify the server - that's why you see "INSECURE" <- not an issue! 2. setOption is not an error. SSL connection is established <- not related to this issue The log from above does not show any disconnections like the log you posted before. Wether the time frame (5 mins) is to short, or the issue disappered due to some other reasons — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#25 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABZAZZTMIMG2B7OMXKKQJODTHXVERANCNFSM42PWZV2Q .

cefranco76 commented 3 years ago

These are not issues.

  1. Our SSL is not using certificates to verify the server - that's why you see "INSECURE" <- not an issue!
  2. setOption is not an error. SSL connection is established <- not related to this issue

The log from above does not show any disconnections like the log you posted before. Wether the time frame (5 mins) is to short, or the issue disappered due to some other reasons

Yeah, the disconnection doesn't appear, but notice that we have a new connection in a 5 minute interval.

sivar2311 commented 3 years ago

Did you set your wifi router to a fixed channel? Or does your router switch wifi channels automaticly when a channel is "full" and a better chan el is available?

sivar2311 commented 3 years ago

oh. i did not see that the last post was a screenshot from mobile hotspot connection. So it happens on both wifi's? (Router and Mobile Hotspot)

cefranco76 commented 3 years ago

Did you set your wifi router to a fixed channel? Or does your router switch wifi channels automaticly when a channel is "full" and a better chan el is available?

image

cefranco76 commented 3 years ago

oh. i did not see that the last post was a screenshot from mobile hotspot connection. So it happens on both wifi's? (Router and Mobile Hotspot)

Yes, the last debug print was over a mobile hotspot connection. But now with an unknown error code.

sivar2311 commented 3 years ago

I set my router to a fixed channel, because the esp tends to disconnect on a channel change.

cefranco76 commented 3 years ago

I set my router to a fixed channel, because the esp tends to disconnect on a channel change.

Well, it worth a test! I'll do it and let you know later. Thanks.

cefranco76 commented 3 years ago

It's clear the different behavior:

Here we've got a hotspot mobile connection SwitchINO_F

And here, a WiFi connection with a fixed channel. SwitchINO_G

sivar2311 commented 3 years ago

Mobile Hotspot looks clean to me... What's your conclusion on this?

cefranco76 commented 3 years ago

I have no idea! Hope you can help me with some tip. Otherwise... I'll keep searching.

cefranco76 commented 3 years ago

Although the disconnections are still happening, the switches turned more responsive after I reset to default some router configurations. I'd like to thank you guys for your time and hints. I'll keep monitoring.

Router firewall is blocking something from SinricPRO, cause when it's off all works. But unfortunately is not configurable.

kakopappa commented 3 years ago

Have you tried this on an ESP8266 board by any chance? If you do a google search for "ssl_client.cpp UNKNOWN ERROR CODE (0050)" there are a lot of questions around this

Please make sure you have a stable connection to the server. in future versions, we may throttle reconnecting clients.

cefranco76 commented 3 years ago

Have you tried this on an ESP8266 board by any chance

No, I haven't. I do not own any ESP8266 device. Things got really better since last friday but yet with some disconnections.

I'll keep investigating, for sure.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.