Hi, I have made a simple local server to receive the data from ESP and put it in data base
the server is working fine as I tested it using postman. the server is listening to port 127.0.0.1:3000
my problem is that client.connect(host,port) returns false.
#include "Arduino.h"
#include "WiFi.h"
WiFiClient client;
const IPAddress server(192,168,1,10);
const int httpPort = 3000;
const char* ssid = "******";
const char* password = "********";
void setup()
{
Serial.begin(115200);
Serial.println();
Serial.println("Booted");
Serial.println("Connecting to Wi-Fi");
WiFi.begin (ssid, password);
WiFi.mode(WIFI_STA);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
yield();
}
Serial.println("WiFi connected");
if (client.connect(server,httpPort )){
Serial.println("Client Connected");
}
else{
Serial.println("No Connection");
}
}
// The loop function is called in an endless loop
void loop()
{
//Add your repeated code here
}
UPDATE: I used Port Listener v1.03, to listen to port 3000 and the client connected successfully, but I still cant see why when I listen from the server I can not connect
UPDATE: I used Port Listener v1.03, to listen to port 3000 and the client connected successfully, but I still cant see why when I listen from the server I can not connect
This sounds like a web server configuration problem. Can a web browser running on a computer different access the web server? If not, the web server may be configured to only allow access from the computer running the web server. Check the web server docs. In some systems, configuring the web server IP as 127.0.0.1 will cause the web server to reject connections from all computers except the computer running the web server.
When I used AMMPS a long time ago, it did not like non-standard port numbers, that is, anything other than 80 and 8080. I would give port 80 try just in case this issue exists with the web server.
gdsports:
This sounds like a web server configuration problem. Can a web browser running on a computer different access the web server? If not, the web server may be configured to only allow access from the computer running the web server. Check the web server docs. In some systems, configuring the web server IP as 127.0.0.1 will cause the web server to reject connections from all computers except the computer running the web server.
When I used AMMPS a long time ago, it did not like non-standard port numbers, that is, anything other than 80 and 8080. I would give port 80 try just in case this issue exists with the web server.
Thank you, it worked now I reconfigured my local server with 0.0.0.0 IP instead of 27.0.0.1