Arduino icon indicating copy to clipboard operation
Arduino copied to clipboard

ESP (NODE MCU) responding to devices only connected in the same network??

Open shekhars271991 opened this issue 9 years ago • 6 comments

#include<ESP8266WiFi.h> #include<ESP8266WebServer.h>

ESP8266WebServer server; char* ssid="skr"; char* pass="12345678"; uint8_t pin_led =16;

void setup() { // put your setup code here, to run once: pinMode(pin_led,OUTPUT); WiFi.begin(ssid,pass); Serial.begin(115200); while(WiFi.status()!=WL_CONNECTED) { Serial.print("."); delay(500); } Serial.println(""); Serial.print("IP Address: "); Serial.print(WiFi.localIP()); //webserver code server.on("/",{server.send(200,"text/plain","Hello World!");}); server.on("/toggle",toggleLED); server.begin(); }

void loop() { // put your main code here, to run repeatedly:

server.handleClient();

} void toggleLED() {

digitalWrite(pin_led,!digitalRead(pin_led)); server.send(204,""); }

shekhars271991 avatar Dec 03 '17 06:12 shekhars271991

@shekhars271991 Can you please add some information as to what you are asking? Your heading is insufficient and it is much more respectful to provide more relevant words so that a reader does not have to try and guess what your problem is.

RudyFiero avatar Dec 03 '17 19:12 RudyFiero

most likely he is in a private WiFi and experiences the fact he can't reach the esp from the internet ...

5chufti avatar Dec 03 '17 20:12 5chufti

Yes most likely. But that is a guess. And nothing about the conditions of his network or the external network are provided. On top of this there is nothing here to indicate there is an issue with the Arduino environment. Just on the face of it it looks like _"I don't know what I am doing and I want you guys to figure out this for me."

This is not a support forum. This is for dealing with code issues or improvements. Questions regarding lack of understanding should be directed to places like http://www.esp8266.com/ but even there, because you are asking for free help, make it easier on people to understand what the problem is.

@shekhars271991 Do you have port forwarding enabled on your router? Do you know that your internal IP address is only useable inside your network? What have you tried? How do you know that you are getting into your network form the public network? Find the answers to these questions and you will have most likely solved your problem. The ESP8266 will respond only if you get the request to it.

See the second post in this issue. https://github.com/esp8266/Arduino/issues/3897

RudyFiero avatar Dec 03 '17 21:12 RudyFiero

@shekhars271991 no basic info, no basic settings, description is too vague. Closing due to lack of info.

devyte avatar Dec 05 '17 01:12 devyte

hello everyone, Sorry about not providing detailed information about the issue.

the problem you guessed is right, i have not set port forwarding in my router and since I have been using my NODE MCU from an external network this was not working.

After port forwarding the issue is resolved.

But, the thing is i was to build a IoT device (a product of sorts) which can be just plugged and played i.e. i wanted to achieve this without setting up port forwarding specifically in the router of every user who uses this device. Im really not good in networking, wanted to know if it was possible to achieve this by any code in the NODE MCU, (by making it public somehow).

Thanks a lot for your help.

shekhars271991 avatar Dec 05 '17 07:12 shekhars271991

Routers prevent exposure from Public networks. It is easy to get out of a private network but it should be hard to get in. And that is what the router does. If you want a publicly accessible connection into a private network it must be enabled from the inside, to configure the router to allow access.

The other option is to have a publicly available server on the net and the device inside the private network call out to it. This is how many MQTT based systems work. A user interacts with the Broker and not directly on the device. There a quite a few Brokers with GUI/dashboards to make presentation and access easy.

RudyFiero avatar Dec 05 '17 13:12 RudyFiero