• ESP 8266 (NodeMCU 1.0)
• Android 13
• Local Server ( Asia )
• Blynk 0.6.1
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// Your WiFi credentials
char ssid[] = "";
char pass[] = "";
// Blynk authentication token
char auth[] = "";
// Server and port settings
char blynkServer[] = "0.tcp.ap.ngrok.io"; // Your Serveo server domain
int port = ; // TCP port
void setup()
{
// Debug console
Serial.begin(115200);
// Connect to WiFi
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("Connected to WiFi!");
// Attempt to connect to Blynk server
Blynk.config(auth, blynkServer, port);
if (Blynk.connect()) {
Serial.println("Connected to Blynk server!");
} else {
Serial.println("Failed to connect to Blynk server.");
}
}
void loop()
{
Blynk.run();
}
I have tried using various library versions, different server versions, downgrading the ESP8266 Core from board managers, mix and match around. But failed regardless. I mainly use ngrok as my tunnel for TCP connection. I am able to connect via the mobile app, only problem is with ESP8266 fail to connect to the Blynk local server via the ngrok tunnel. I also decoded the error message using the ESP decoder, here it is:
Exception 4: Level1Interrupt: Level-1 interrupt as indicated by set level-1 bits in the INTERRUPT register
PC: 0x401002c6
EXCVADDR: 0x00000000
Decoding stack results
0x40204856: __delay(unsigned long) at C:\Users\GIGABYTE\Documents\ArduinoData\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/coredecls.h line 77
0x402011d9: BlynkArduinoClientGen ::connected() at C:\Users\GIGABYTE\Documents\Arduino\libraries\Blynk\src/Adapters/BlynkArduinoClient.h line 115
0x40201a89: BlynkProtocol >::run(bool) at C:\Users\GIGABYTE\Documents\Arduino\libraries\Blynk\src/Adapters/BlynkArduinoClient.h line 116
0x40201f19: setup() at C:\Users\GIGABYTE\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkProtocol.h line 52
0x402042a0: loop_wrapper() at C:\Users\GIGABYTE\Documents\ArduinoData\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266\core_esp8266_main.cpp line 255
0x40100e75: schedule_recurrent_function_us(std::function const&, unsigned int, std::function const&) at C:\Users\GIGABYTE\Documents\ArduinoData\packages\esp8266\hardware\esp8266\3.1.2\cores\esp8266/interrupts.h line 29
Sorry I am a newbie at this. I will provide as much information as possible if you need them.
I’m a bit confused by the info you’ve provided.
You seem to be saying that your sketch is crashing, and you’ve decided the crash dump data using ESP decoder. At what point does your sketch crash?
Is your device correctly connecting to WiFi?
Is this your Blynk legacy local server, or is it maintained by someone else?
If it’s yours, then have you tried putting your device on the same network as your server and testing a direct connection?
What version of Blynk Legacy local server are you running, and on what hardware platform, and using what Java version?
What TCP port are you using?
Pete.
Sorry for the confusion. I will answer your questions one by one.
- My device is correctly connected to Wi-Fi, i used another sketch to verify the connection
- It is my own Blynk legacy local server. I have tried locally connect as well, but it doesn’t work for the ESP8266. For some reason, connect it locally doesn’t even work for my mobile Blynk legacy app, but it does work after being port forwaded.
- I am running with server-0.41.16. and also server-0.41.17. I tried both as well when trouble shooting. My hardware platform is Windows 11, and using JDK 13.
- I’m using 9443 for the TCP port.
- More info here, I also tried to ping popular domains such as google.com using the ESP8266, and it does work. But i tried to use both http and https protocols to connect to my Blynk local server as well, doesn’t work. Thanks in advance for your swift response.
You should use 0.41.17 as earlier versions have a Log4j2 Java vulnerability.
Should be 8080 unless you’ve changed it from the default, and if you have changed it to 9443 then that will clash with the port used by the app.
I suspect you’re doing something wrong then, assuming that your mobile device is connected via WiFi to the same network, and you’re specifying the local IP address and port 9443 then it should work.
Pete.
Alright I will make sure that it runs on the newer version.
It does seem like it runs both on default? According to the blynk.log file. I have tried to connect using the portforwarded 8080 port but it didn’t work, only 9443 works.
I’m not sure about that as well, but it could be related to my router settings.
Thanks in advance.
Your router settings are irrelevant when the server, mobile device and ESP8266 are all connected to the same network. Port-forwarding rules only apply to external traffic.
The app connects via port 9443 by default, and devices connect via 8080 for tcp/ip (which is what your sketch is using) or 9443 for ssl/tls using a local certificate (which isn’t what you’re doing in your sketch).
Pete.
I see I see. I get it know, it seems like I’ll need to port forward both port 8080 and port 9443 using ngrok. Alright then I’ll try this method later on. Thank you for your suggestion
Update: It is working as intended. The connection has been established. Seems like I got confused with the port numbers. I apologize for what it seems like a rookie mistake. But I’m glad it got resolved. Thank you Pete.
2 Likes