These are chat archives for Links2004/arduinoWebSockets

15th
Feb 2017
Mehrdad K
@mkeyno
Feb 15 2017 19:43
Markus can have both websoket client and server in a sketch
Markus
@Links2004
Feb 15 2017 19:43
sure, will work fine
Mehrdad K
@mkeyno
Feb 15 2017 19:49
you know at first I create Telegram bot to control my ESP module, but noticed Telegram bot is public user and every body can send message to my ESP and somehow it may chocking my module, then I decided to check new bot update in my own website and let my ESP connect to remote server by client websocket , may I know your idea about that
Markus
@Links2004
Feb 15 2017 19:51
will work fine no problems with firewalls and nat since the client will connect.
and you can secure it via https / ssl.
Mehrdad K
@mkeyno
Feb 15 2017 19:51
thanks Markus
Markus
@Links2004
Feb 15 2017 19:51
I recommand to use the webseocket ping to detect connection fails
Mehrdad K
@mkeyno
Feb 15 2017 19:52
when should I send ping in my loop
Markus
@Links2004
Feb 15 2017 19:53
all 30 sec is more than enough for most applications, since its only to detect fails on the network.
to get the ESP to reconnect when a problem has happend
Mehrdad K
@mkeyno
Feb 15 2017 19:56
so you said every 30 sec in loop check whether connection is live ?
Markus
@Links2004
Feb 15 2017 19:58
you only need to call the ping function the rest is done by the lib.
the implementation in the loop looks the same as the non sleep LED blinking example in the IDE.
Mehrdad K
@mkeyno
Feb 15 2017 20:01
so you said if ping function return false it will reconnected automatically , I just need to periodically run ping method ?
Markus
@Links2004
Feb 15 2017 20:02
not the ping function call itself but the webSocket.loop(); call will reconect.
but yes calling periodically the ping is all you need to do
since loop is in the code anyway ;)
szkr
@szkr
Feb 15 2017 20:36
Hi, how can i reinitalize websocketclient?
I have websocket server on my laptop, esp8266 is connected to the same router. When i turn off my laptop's wifi(not router), websocketclient won't fire up disconnected event and won't try to reconnect. When i try to call websocketclient.disconnect() in this situation, the esp waits few seconds, then resets.
Now i just call again beginssl but i can do it only once per esp reset-i'm losing 12kB of heap.
Markus
@Links2004
Feb 15 2017 20:37
call ping, it will detect the connection termination and on the next loop call try to reconnect.
the ESP can only detect TCP connection lost when you try to send something, the ping is as small as you can get.
szkr
@szkr
Feb 15 2017 20:41
Thanks, i'll try this. ATM i have my own heartbeat messages so websocketclient couldn't know when connection was lost
Mehrdad K
@mkeyno
Feb 15 2017 21:51
Markus do you have any idea how php code on remote server might be