Problem HTTP query with WIFI v12

Wireless communications in Waspmote, topologies, node types...
jotabeles
Posts: 30
Joined: Thu Mar 09, 2017 1:07 am

Problem HTTP query with WIFI v12

Post by jotabeles » Tue Jun 20, 2017 4:05 am

Hi,
I have a platform to recieve data from the waspmote, and i was using a program from the while a time ago, but some days ago it doesn't work. I am not sure what could be the problem.
I probe the WIFI with the example and it works good, but when i try to connect to my server it doesn't.
I am using also a GPRS+GPS module and it works very good with my platform.

With the WIFI module i recieve this error:
HTTP/1.1 400 Bad Request
Date: Tue, 20 Jun 2017 01:48:04 GMT
Server: Apache/2.4.18 (Ubuntu)
Content-Length: 306
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
<hr>
<address>Apache/2.4.18 (Ubuntu) Server at 104.236.32.106 Port 80</address>
</body></html>
*CLOS*

If you have an idea of what could be wrong with my platform, it would be helpful, because i don't have any problem with GPRS+GPS module.

Thanks.

jotabeles
Posts: 30
Joined: Thu Mar 09, 2017 1:07 am

Re: Problem HTTP query with WIFI v12

Post by jotabeles » Tue Jun 20, 2017 5:59 am

I probe with this code


// Include WIFI library
#include <WaspWIFI.h>

// choose socket (SELECT USER'S SOCKET)
///////////////////////////////////////
uint8_t socket=SOCKET0;
///////////////////////////////////////

// WiFi AP settings (CHANGE TO USER'S AP)
/////////////////////////////////
char ESSID[] = "REDWP";
char AUTHKEY[] = "waposatsoft";
/////////////////////////////////

// WEB server settings
/////////////////////////////////
char HOST[] = "potenciometro.waposat.com";
char URL[] = "GET$/lectura.sensor.php?";
char body[] = "id1=1";
/////////////////////////////////


// define variable for communication status
uint8_t status;
uint8_t counter=0;
//char body[100];
unsigned long previous;


void setup()
{
if( WIFI.ON(socket) == 1 )
{
USB.println(F("WiFi switched ON"));
}
else
{
USB.println(F("WiFi did not initialize correctly"));
}

// reset to avoid previous configuration stored in the module
//WIFI.resetValues();

// 1. Configure the transport protocol (UDP, TCP, FTP, HTTP...)
WIFI.setConnectionOptions(HTTP|CLIENT_SERVER);
// 2. Configure the way the modules will resolve the IP address.
WIFI.setDHCPoptions(DHCP_ON);
// 3. Configure how to connect the AP
WIFI.setJoinMode(MANUAL);
// 4. Set the AP authentication key
WIFI.setAuthKey(WPA1,AUTHKEY);
// 5. Save Data to module's memory
WIFI.storeData();


USB.println(F("Set up done"));
}


void loop()
{
// Switch ON the WiFi module on the desired socket
if( WIFI.ON(socket) == 1 )
{
USB.println(F("WiFi switched ON"));
}
else
{
USB.println(F("WiFi did not initialize correctly"));
}

// If it is manual, call join giving the name of the AP
if( WIFI.join(ESSID) )
{
USB.println(F("Joined"));

///////////////////////////////////////////
// Create the HTTP body with sensor data
///////////////////////////////////////////
//RTC.ON();
//RTC.getTime();
//counter++;
//snprintf( body, sizeof(body), "counter=%u&hour=%02u&minute=%02u&second=%02u", counter, RTC.hour, RTC.minute, RTC.second );

USB.print(F("body:"));
USB.println(body);

///////////////////////////////////////////
// Send the HTTP get/post query (specifying the WEB server so DNS is used)
///////////////////////////////////////////
status = WIFI.getURL(DNS, HOST, URL, body);
//status = WIFI.getURL(DNS, HOST, URL);

if( status == 1)
{
USB.println(F("\nHTTP query OK."));
USB.print(F("WIFI.answer:"));
USB.println(WIFI.answer);

/*
* At this point, it could be possible
* to parse the web server information
*/
}
else
{
USB.println(F("\nHTTP query ERROR"));
USB.println(WIFI.answer);
counter--;
}
}
else
{
USB.println(F("NOT joined"));
}


// switch off module
WIFI.OFF();
USB.println(F("***************************"));
delay(1000);
}


/**********************************************************************************************************
END
/**********************************************************************************************************


I have change one line of WIFI librarie, i put USB.println(answer); before the next instruction
memcpy(aux, answer, sizeof(answer));

Because WIFI.aswer only print CMD or *OPEN*CMD

Now it send

H#
WiFi switched ON
Set up done
WiFi switched ON
Joined
body:id1=1
HTTP/1.1 400 Bad Request
Date: Tue, 20 Jun 2017 03:40:42 GMT
Server: Apache/2.4.18 (Ubuntu)
Content-Length: 306
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
<hr>
<address>Apache/2.4.18 (Ubuntu) Server at 104.236.32.106 Port 80</address>
</body></html>
*CLOS*

HTTP query ERROR
CMD
***************************

This is the URL and is workining good if i put it on a browser
http://potenciometro.waposat.com/lectur ... .php?id1=1

The browser show me:
id1 ha sido enviado exitosamente, su valor es: 1 no se ha encontrado a id2 no se ha encontrado a v1 no se ha encontrado a v2 no voy a guardar nada ...

I think, the way WiFi send information is important, but i can't know how it exactly work, If you could send me the code of your web example
pruebas.libelium.com/getpost_frame_parser.php
It would be helpful.

Thanks

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Problem HTTP query with WIFI v12

Post by libelium-dev » Tue Jun 20, 2017 1:28 pm

Hi,

What API are you using? Could you try to use the API v028?

We have run your code and we get this output

Code: Select all

H#
WiFi switched ON
Set up done
WiFi switched ON
Joined
body:id1=1

HTTP query OK.
WIFI.answer:HTTP/1.1 200 OK
Date: Tue, 20 Jun 2017 11:18:17 GMT
Server: Apache/2.4.18 (Ubuntu)
Vary: Accept-Encoding
Content-Length: 150
Content-Type: text/html; charset=UTF-8
....
....
Regards

jotabeles
Posts: 30
Joined: Thu Mar 09, 2017 1:07 am

Re: Problem HTTP query with WIFI v12

Post by jotabeles » Fri Jun 23, 2017 12:12 am

Dear,

To be honest, i don't have idea what is wrong, i update my waspmote API to 028 and I am using Waspmote PRO IDE - 06, both i download from this page: http://www.libelium.com/development/was ... plications

I am using Linux version.
Devices:
Waspmote v1.5
WiFi SMA 5 DBi (v1.2)
6600mAh rechargeable battery
Here is a picture of the connection which i am using to test.
https://drive.google.com/file/d/0B7AdhC ... sp=sharing
https://drive.google.com/file/d/0B7AdhC ... sp=sharing

But i have the same answer. I have already using the same code:

// WEB server settings
/////////////////////////////////
/*
char HOST[] = "www.arduino.cc";
char URL[] = "GET$/latest.txt?";
char body[] = "id1=1";
*/

char HOST[] = "potenciometro.waposat.com";
char URL[] = "GET$/lectura.sensor.php?";
char body[] = "id1=1";

/*
char HOST[] = "pruebas.libelium.com";
char URL[] = "GET$/getpost_frame_parser.php?";
char body[] = "counter=1";
*/
/////////////////////////////////


I have probe it with different servers:
But only the libelium server answer with the HTTP 200 OK.

I have two WiFi Modules and both have the same problem.

What would you recomend me?

Thanks.

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Problem HTTP query with WIFI v12

Post by libelium-dev » Mon Jun 26, 2017 10:36 am

Hi,

Sorry for our delay answering. Part of our team was on holidays.

What HTTP error do you get?

Could you try with the modules connected to other WiFi network?

Regards

jotabeles
Posts: 30
Joined: Thu Mar 09, 2017 1:07 am

Re: Problem HTTP query with WIFI v12

Post by jotabeles » Tue Jun 27, 2017 2:21 am

Hi,
I have probe with three different WiFi Networks, one of the normal router, a 3G/4G router, and finally a network of the WiFi of my movile Phone. But I had the same problem.

The Program only say Query error and print CMD or *OPEN*CMD.

I have tried with google server, arduino server, and my own server, i always have the same answer, but when i try with the libelium server it works without problems. Also i made the test with my two modules WiFi, both have been working well until the last month, i think was when i update my waspmote IDE because i have the new waspmote v1.5.

I don't know what more try, and i have to finish the prototype. I have change one line of WIFI library to make a test, I put USB.println(answer); before the next instruction
memcpy(aux, answer, sizeof(answer));
this on the function getURL(); and it show me the error HTTP 400 Bad request.

Thanks.

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Problem HTTP query with WIFI v12

Post by libelium-dev » Wed Jun 28, 2017 8:56 am

Hi,

It is a weird issue. There were no changes into the WiFi library, so that shouldn't be the problem.

Could you try to send a HTTP request through a TCP connection?
http://www.libelium.com/v12/development ... cp-client/

Code: Select all

char data[] =
  "GET /getpost_frame_parser.php?counter=1 HTTP/1.1\r\n"\
  "Host: test.libelium.com\r\n"\
  "Content-Length: 0\r\n\r\n";
WIFI.send(data);
Regards

jotabeles
Posts: 30
Joined: Thu Mar 09, 2017 1:07 am

Re: Problem HTTP query with WIFI v12

Post by jotabeles » Tue Jul 25, 2017 2:05 am

Hi,

Send an HTTP request over a TCP connection with IP_ADDRESS = 45.55.150.245, REMOTE_PORT = 80 and LOCAL_PORT = 80 and this is the following result:

H#
Wifi switched ON
Joined AP
TCP client set
Listen to TCP socket:
HTTP/1.1 400 Bad Request
Date: Mon, 24 Jul 2017 23:47:26 GMT
Server: Apache/2.4.7 (Ubuntu)
Content-Length: 300
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
<hr>
<address>Apache/2.4.7 (Ubuntu) Server at localhost Port 80</address>
</body></html>
*CLOS*
Close TCP socket

libelium-dev
Posts: 27967
Joined: Mon Sep 28, 2009 1:06 pm

Re: Problem HTTP query with WIFI v12

Post by libelium-dev » Tue Jul 25, 2017 11:28 am

Hi,

How are you perform the request? We mean this part

Code: Select all

char data[] =
  "GET /getpost_frame_parser.php?counter=1 HTTP/1.1\r\n"\
  "Host: test.libelium.com\r\n"\
  "Content-Length: 0\r\n\r\n";
Regards

jotabeles
Posts: 30
Joined: Thu Mar 09, 2017 1:07 am

Re: Problem HTTP query with WIFI v12

Post by jotabeles » Thu Aug 03, 2017 12:28 am

Hi
Send an HTTP request over a TCP connection with IP_ADDRESS = 52.16.186.190, REMOTE_PORT = 80 and LOCAL_PORT = 80 and this is the following result:

H#
Wifi switched ON
Joined AP
TCP client set
Listen to TCP socket:
HTTP/1.1 403 Forbidden
Date: Wed, 02 Aug 2017 22:25:06 GMT
Server: Apache/2.4.7 (Ubuntu)
Content-Length: 308
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /getpost_frame_parser.php
on this server.</p>
<hr>
<address>Apache/2.4.7 (Ubuntu) Server at test.libelium.com Port 80</address>
</body></html>

HTTP/1.1 400 Bad Request
Date: Wed, 02 Aug 2017 22:25:09 GMT
Server: Apache/2.4.7 (Ubuntu)
Content-Length: 300
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
<hr>
<address>Apache/2.4.7 (Ubuntu) Server at localhost Port 80</address>
</body></html>
*CLOS*
Close TCP socket

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest