Connect the ESP32 to my local server with DNS

my console is:

[2643] IP: 192.168.0.153
[2644] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on ESP32

[2718] Connecting to X.ddns.net:8080
[8096] Connecting to X.ddns.net:8080
[13140] Connecting to X.ddns.net:8080
[18154] Connecting to X.ddns.net:8080

and my code is:

char ip[] = "192.168.0.153";
char auth[] = "hided";
char server[] = "X.ddns.net";

char ssid[] = "";
char pass[] = "";


#define STEPS 200

Stepper stepper(STEPS, 19, 18, 7, 17);

int previous = 0;

void setup() {
Serial.begin(9600);
Blynk.begin(auth, ssid, pass, server, 8080);
stepper.setSpeed(30);
}

how i can resolve this problem and my board successful connect to my local server with DNS?

So your local server isn’t on the same network as your device?

Do you have port 8080 forwarded to your local server on the router which connects the local server to the internet?

Also, are you running a DDNS updater on that network so that the public IP of your local server network is kept up to date when it changes?

Pete.

yes, it is in a same network, but only for testing, when i finish i move my board in different location, and my local server is a same place and i now.
port 8080 it`s open, and i have two router and i forwarded correctly i guess.!
image|690x468

My DNS is up to date, but it receives my IP from the ISP router, but I will change the DNS from the ISP and it will automatically take my external ip, now I put my external ip in DDNS alone , but the blynk application automatically connects via DDNS (X.ddns.net) and works, but ESP32 does not work when I connect to DDNS

Having the port open, and having it correctly forwarded to your local server are two very different things. I’d suggest that you share some screenshots of your port forwarding setup.

In that case your port forwarding for port 9443 is correct.

Not quite sure what you’re saying here, you need to explain your current setup in more detail.

Pete.

my ISP forwarded settings:

so my setup is like this: The provider router is connected to the router I bought, and the local server (blynk) is connected via WIFI to the router I bought

my ISP forwarded settings:

and my router forwarded settings plug in ISP router:

Your last image doesn’t show anything for port 8080

I use a similar setup to you, with a Huawei router provided by my ISP and a Netgear router which handles my internal traffic. I use this to get around my ISP locking down some of the features in their router, such as DNS settings.
I do things differently though. ALL data on all ports is forwarded from the ISP router to my own, and my port-forwarding is done in my own router.

Pete.

Do you mean that the last picture is not visible? or is it visible but I didn’t do the right thing with port 8080?
And in the end, what can I do to make ESP-32 work with DDNS? Did I write something in the wrong code? or why it doesn’t connect when I try to connect with DDNS.
When I try to connect to the local server ip, it goes and tells me this:

void setup() {
Serial.begin(9600);
Blynk.begin(auth, ssid, pass, IPAddress(192, 168, 0, 162), 8080);
stepper.setSpeed(30);
}

and my console:

[3142] Connected to WiFi
[3142] IP: 192.168.0.153
[3143] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on ESP32

[3217] Connecting to 192.168.0.162
[3580] Ready (ping: 10ms).

and if I try to connect with the external ip, it gives me the same error when I try to connect with the DDNS:


void setup() {
Serial.begin(9600);
Blynk.begin(auth, ssid, pass, IPAddress(5, 12, xx, xx), 8080);
stepper.setSpeed(30);
}

and console:

[2645] IP: 192.168.0.153
[2646] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on ESP32

[2720] Connecting to 5.12.xx.xx
[8091] Connecting to 5.12.xx.xx
[13259] Connecting to 5.12.xx.xx
[18483] Connecting to 5.12.xx.xx

What can I do to solve the problem?

I solved the problem, it was from port forwarding and for ESP 32 I used port 9443 and it worked, but the application didn’t work, but I put port 8080 for blynk app and it worked, now they both go through DDNS

char server[] = "xx.ddns.net";

void setup() {
Serial.begin(9600);
Blynk.begin(auth, ssid, pass, server, 9443);
stepper.setSpeed(30);
}

and console is:

[3145] Connected to WiFi
[3145] IP: 192.168.0.153
[3146] 
    ___  __          __
   / _ )/ /_ _____  / /__
  / _  / / // / _ \/  '_/
 /____/_/\_, /_//_/_/\_\
        /___/ v0.6.1 on ESP32

[3220] Connecting to xx.ddns.net:9443
[3426] Ready (ping: 13ms).

and in my own router i change this settings:

and finally work, uh

I’m still not sure you have it right, but it works in a roundabout way.
In your own router you should be forwarding:
WAN 9443 to LAN 9443
WAN 8080 to LAN 8080

Pete.

well, i have this settings in my ISP router:
WAN 9443 to LAN 9443
WAN 8080 to LAN 8080


and the other picture in another reply

Yes, that’s correct. But your other router screenshots seem to switch traffic from 8080 to 9443 and vice versa.

You want an incoming packet on port 8080 to travel through your first (ISP) router into your second router then on to your local server - still on port 8080.
That’s not happening, it’s being changed to port 9443 as far as I can tell from your screenshots.

The same applies to port 9443.

Outgoing traffic doesn’t need any re-direction. It knows where it’s destination is, it just needs to be able to access the Internet unchanged.

Pete.

Pete.