Hello, before anything thanks for your time and for any help.
I have a server in raspberry PI running raspbian with LAMP (http://www.pihome.eu/2018/03/25/download-lamp-apache-php-7-0-and-mysql-mariadb-and-phpmyadmin-server-img-file/) that holds a PHP page in port 80.
I have an mkr1000 sending data successfully to the server via HTTP POST REQUEST (code shown below)
/*
Simple POST client for ArduinoHttpClient library
Connects to server once every five seconds, sends a POST request
and a request body
created 14 Feb 2016
by Tom Igoe
this example is in the public domain
*/
#include <ArduinoHttpClient.h>
#include <WiFi101.h>
///////please enter your sensitive data in the Secret tab/arduino_secrets.h
/////// Wifi Settings ///////
char ssid[] = "MyUserVodafon";
char pass[] = "JKHAS765ShjhSHD";
//char serverAddress[] = "192.168.0.200"; // server address
char serverAddress[] = "worden-ipsubs-1267.dataplicity.io"; // server address
int port = 80;
WiFiClient wifi;
HttpClient client = HttpClient(wifi, serverAddress, port);
int status = WL_IDLE_STATUS;
String response;
int statusCode = 0;
void setup() {
Serial.begin(9600);
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to Network named: ");
Serial.println(ssid); // print the network name (SSID);
// Connect to WPA/WPA2 network:
status = WiFi.begin(ssid, pass);
delay(1000);
}
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your WiFi shield's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
}
void loop() {
Serial.println("1) making POST request");
String contentType = "application/x-www-form-urlencoded";
String postData = "";
// Variables SQL a chorizo para POST
String CadenaValores = "/dht11.php?QuienSoy=ARDUINO";
//Navegamos a la pagina (INSERT SQL, ver paginas PHP, ejem dht11.php)
client.post(CadenaValores, contentType, postData);
// read the status code and body of the response
statusCode = client.responseStatusCode();
response = client.responseBody();
Serial.print("2) Status code: ");
Serial.println(statusCode);
Serial.print("3) RESPONSE: ");
Serial.println(response);
Serial.println("4) Fin loop");
delay(5000);
}
It is working locally but the problem comes when trying to make a POST from outside the LAN with another mkr1000.
I have used (www.dataplicity.com) to control the raspberry PI, and also activated an option called wormhole that gives me a weird looking domain name like (https://nt-foxter-1181.dataplicity.io) that apparently let me do all I could in LAN with the IP number 192.168.0.200 but outside of the LAN .
Same code, same arduino, the only thing that I have changed in the second mkr1000 is the serverAddress,
//char serverAddress[] = "192.168.0.200"; // server address (ONLY FOR LAN)
char serverAddress[] = "chameleon-ipsubs-955.dataplicity.io"; // server address
and instead of getting Status Code 200, it shows Status Code 301
and instead of getting the echo from the response I usually get from the php page, it shows an error page.
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>
I am really stuck and google results it's starting to only show purple results so I am running out of ideas and that is why I came here to ask for some help or hints.
Thanks a lot for any help.