Go Down

Topic: Strange network behavior on NodeMCU? Help Please (Read 105 times) previous topic - next topic

pomtom44

Hey team.
Having a odd problem with my NodeMCU's

I recently updated my firewall and my script stopped working, I found that I had accidently turned off ping between vlans. I allowed ICMP which is usually what ping runs over, but it still appears to be blocked.

So posting on another forum we got to the point where we know its the arduino having issues and not the firewall its self.

Turned on logging on firewall and noticed the following actions:

Ping router from Arduino - See the requests in firewall & arduino gets response. (Red line)
Send external web request from arduino - See requests in firewall & arduino gets response. (Orange Line)
Send web request to internal server - Arduino queries internal DNS and gets IP of web server, but no request send (Nothing in firewall logs) (Yellow and Blue)
Send ping to internal server - Arduino queries same dns server, gets ip, but no request sent (Firewall logs again) (Yellow and Green)

however, sending the ping and web request from desktop, shows both the firewall log blocking the ping request, and the rule allowing the web request.(Brown Purple Pink)

Have attached diagram again to help visualize whats going on
And can attach router logs or rules if required

https://imgur.com/a/g4TipmZ

Also have set a windows PC with the same IP address, and can ping the web server, so I know it's something wrong with the arduino's requests to the web server in particular, and not the firewall?

So for some reason, when doing any network traffic to that particular vlan / subnet from the arduino it wont send the requests.
Other devices with the same IP work fine, and other subnets / vlans work fine, just that particular range?

PaulS

Quote
so I know it's something wrong with the arduino's requests to the web server in particular,
But, you don't think it's a code problem, or you would have posted the code. I can't see what else is could be.

Unless your NodeMCU just doesn't like you. 8)
The art of getting good answers lies in asking good questions.

pomtom44

But, you don't think it's a code problem, or you would have posted the code. I can't see what else is could be.

Unless your NodeMCU just doesn't like you. 8)
Sorry heres the test code im using
(Note details have been hidden for privacy)

Code: [Select]

#include <DHT.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <ESP8266Ping.h>

//TimeDate Settings
const char* host = "http://api.timezonedb.com/v2/get-time-zone?key=##########&format=xml&fields=formatted&by=zone&zone=Pacific/Auckland";
String payload;
int nowyear;
int nowmonth;
int nowday;
int nowhour;
int nowmin;
int nowsec;

// WiFi credentials.
const char* WIFI_SSID = "####";
const char* WIFI_PASS = "####";
WiFiClientSecure wifiClient;
bool connection = false;
WiFiClient client;

//Network Addresses
const char* router = "##ROUTERip##";
const char* dbServer = "InternalServerDNSname";
String dbPath = "InternalServerWebAddress";

void setup() {
  //Open Serial
  Serial.begin(9600);
  Serial.setTimeout(2000);
  while (!Serial) { }

  Serial.println();
  Serial.println("#####");
  Serial.println();
 
  //Connect to Wifi
  bool pingtest = false;
  Serial.print("Connecting to WiFi");
  WiFi.begin(WIFI_SSID, WIFI_PASS);
  int wificount = 0;
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println();
  if (WiFi.status() == WL_CONNECTED) {
    connection = true;
    Serial.println("WiFi connected");
    Serial.println("IP address: ");
    Serial.println(WiFi.localIP());
    Serial.println(WiFi.subnetMask());
    Serial.println(WiFi.gatewayIP());
   
    Serial.println();
    Serial.println("#####");
    Serial.println();

    //Ping Router
    Serial.print("Pinging Router");   
    while (!pingtest) {
      if (Ping.ping(router) == true) {
        pingtest = true;
      } else {
        Serial.print(".");
        delay(1000);
      }
    }

    pingtest = false;

    Serial.println();
    Serial.println("#####");
    Serial.println();
   
    //Send request to External website
    int httpCode = 0;
    HTTPClient http;
    Serial.println("Connecting to TimezoneDB");
    http.begin(host);
    httpCode = http.GET();
    while (httpCode == 0) {
      Serial.print(".");
      delay(500);
      http.begin(host);
      httpCode = http.GET();
    }
    payload = http.getString();
    http.end();
    int colon = payload.indexOf(':'); 
    nowyear = payload.substring(colon - 13, colon - 9).toInt();
    nowmonth = payload.substring(colon - 8, colon - 6).toInt();
    nowday = payload.substring(colon - 5, colon - 3).toInt();
    nowhour = payload.substring(colon - 2, colon).toInt();
    nowmin = payload.substring(colon + 1, colon + 3).toInt();
    nowsec = payload.substring(colon + 4, colon + 6).toInt();
    Serial.print("Current local time is: ");
    Serial.print(nowhour);
    Serial.print(":");
    Serial.print(nowmin);
    Serial.print(":");
    Serial.print(nowsec);
    Serial.println();

    Serial.println();
    Serial.println("#####");
    Serial.println();

    //Ping Router
    Serial.print("Pinging Router");   
    while (!pingtest) {
      if (Ping.ping(router) == true) {
        pingtest = true;
      } else {
        Serial.print(".");
        delay(1000);
      }
    }
    pingtest = false;

    Serial.println();
    Serial.println("#####");
    Serial.println();
 
    //Send request to Internal website
    http.begin(dbPath);
    http.addHeader("Content-Type", "application/x-www-form-urlencoded");
    httpCode = http.GET();
    String httpPayload = http.getString();
    Serial.print("HTTP CODE: ");
    Serial.println(httpCode);   //Print HTTP return code
    Serial.print("httpPayload: ");
    Serial.println(httpPayload);    //Print request response payload

    Serial.println();
    Serial.println("#####");
    Serial.println();
   
    //Ping Interal Server   
    Serial.print("Pinging Server");
    while (!pingtest) {
      if (Ping.ping(dbServer) == true) {
        pingtest = true;
      } else {
        Serial.print(".");
        delay(1000);
      }
    }
  }
  pingtest = false;

  Serial.println();
  Serial.println("#####");
  Serial.println();

}



// the loop function runs over and over again forever
void loop() {
  Serial.println("Hello");
  delay(2000);
}

pomtom44

update, have done a pcap on the wifi AP.
can see pings to other locations going though, but not to the 4.x network range.
almost as if the arduino doesn't like that IP range?

Go Up