0

It would be kind of push notification or something like that probably. I can first connect to server and send it any data for "registration"...

I found many examples with websockets but all of them was about ESP8266 is like "server". That's not this case...

  • 2
  • I found many examples with websockets but all of them was about ESP8266 is like "server" there. That's not this case... – mirec Jun 29 at 17:30
  • So look for more examples where the ESP8266 is the client? They must be out there somewhere. – Majenko Jun 29 at 18:14
  • 2
    have you looked into using MQTT? – jsotola Jun 29 at 18:58
1

It seems evident that you don't want your ESP8266 running as a server of any kind. That's understandable given that server programs consume a fair amount of system resources (CPU, RAM, etc.) that are in short supply. That means you'll have to use your ESP8266 as a client and this means either

  1. Polling - where the ESP8266 repeatedly connects to your "internet server" to explicitly ask for information at frequent intervals. Your internet server would have to be able to collect information in batches and hang onto it until your ESP8266 connects again to request the information.

  2. Socket connections - where your ESP8266 maintains a consistent socket connection to your "internet server." Note that the HTTP protocol relies on socket connections, but clients open a socket connection, request a web page and its images, CSS, etc., then disconnects the socket. You can also use sockets at a more basic level as a bytestream. This programming can be tricky, but ESP8266 does have examples of TCP socket communication like WiFiClient and ethernet client.

Client approaches have a variety of headaches:

  • server has to hang on to information until the client comes back to retrieve it
  • you have to work up some kind of data structure to track which information has been handled and which work must still be done
  • latency issues -- i.e., what happens when there's a delay in processing information.

Server approaches also have challenges:

  • server programs can be tricky to write so that they keep running. a single exception or fatal error can crash the program
  • server programs are vulnerable to DDoS or other attacks, and can easily overwhelm a small device like ESP8266
  • firewall and networking issues -- depending on how this device connects to the internet, it may or may not have a consistent IP address where it can be found, the ISP that connects it may not allow incoming connections for the ports that it listens on, etc.
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.