Closed AlexandreKueny closed 7 years ago
Hi @creends,
Could you please provide a sketch to reproduce this issues? As well as let us know what board you are using.
Thank's for your reply, @sandeepmistry
I'm using an Arduino MKR1000. Also, in my case, response is a JSON.
The sketch i'm using : demo.ino.txt
@creends thanks.
One more question, could you please provide more details of the server you are connecting to. Maybe a Wireshark capture of the response, or the code that is is running.
PR #7 might also help with the issues you are seeing.
I'm connecting to my Philips Hue bridge, I don't know more usefull information about the server. Here is a Wireshark capture : capture.zip I noticed that it's a chunked response, maybe the problem is here.
responseBody give me that : response.txt
Thanks!
I noticed that it's a chunked response, maybe the problem is here.
I don't think it chunk per say, they just didn't include a content length header in the response.
Did you get a chance to try the changes in PR #7?
Just tried #7, doesn't change anything.
Maybe chunked was not the appropriate word. If you look in the capture file, the response is divided into 2 lines (47 and 48), that's what I was trying to say.
I'm able to reproduce it with the master version of this library and the following Node.js code to simulate the server:
var net = require('net');
var response =
'HTTP/1.1 200 OK\r\n' +
'Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0\r\n' +
'Pragma: no-cache\r\n' +
'Expires: Mon, 1 Aug 2011 09:00:00 GMT\r\n' +
'Connection: close\r\n' +
'Access-Control-Max-Age: 3600\r\n' +
'Access-Control-Allow-Origin: *\r\n' +
'Access-Control-Allow-Credentials: true\r\n' +
'Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE, HEAD\r\n' +
'Access-Control-Allow-Headers: Content-Type\r\n' +
'Content-type: application/json\r\n' +
'\r\n' +
'{"3":{"state":{"on":true,"bri":238,"hue":988,"sat":234,"effect":"none","xy":[0.6424,0.3332],"ct":153,"alert":"select","colormode":"xy","reachable":true},"type":"Extended color light","name":"Hue color lamp plafond","modelid":"LCT007","manufacturername":"Philips","uniqueid":"00:17:88:01:10:4b:b9:61-0b","swversion":"5.50.1.19085"},"4":{"state":{"on":true,"bri":238,"hue":988,"sat":234,"effect":"none","xy":[0.6424,0.3332],"ct":153,"alert":"none","colormode":"xy","reachable":true},"type":"Extended color light","name":"Hue color lamp mur","modelid":"LCT007","manufacturername":"Philips","uniqueid":"00:17:88:01:10:5d:96:ff-0b","swversion":"5.50.1.19085"},"5":{"state":{"on":true,"bri":238,"hue":3468,"sat":221,"effect":"none","xy":[0.6414,0.3353],"alert":"none","colormode":"xy","reachable":true},"type":"Color light","name":"Hue bloom","modelid":"LLC011","manufacturername":"Philips","uniqueid":"00:17:88:01:00:c1:c6:fa-0b","swversion":"5.23.1.13452"},"6":{"state":{"on":false,"bri":126,"hue":14957,"sat":141,"effect":"none","xy":[0.4576,0.4099],"ct":366,"alert":"none","colormode":"xy","reachable":true},"type":"Extended color light","name":"Hue color lamp entree","modelid":"LCT007","manufacturername":"Philips","uniqueid":"00:17:88:01:10:5d:91:82-0b","swversion":"5.50.1.19085"}}';
net.createServer(function (socket) {
var request = new Buffer(0);
socket.on('data', function (data) {
request = Buffer.concat([request, data]);
if (request.toString().indexOf('\r\n\r\n') !== -1) {
console.log(request.toString());
socket.write(response, function() {
socket.end();
});
}
});
}).listen(5000);
So far, I think the issue actually lies in the WiFi101 library ...
Definitely caused by the WiFi101 library, https://github.com/arduino-libraries/WiFi101/issues/116 has a potential fix. @creends please try it out and provide your feedback.
So arduino-libraries/WiFi101#116 works fine for me too. No more unwanted characters at the end of the answers, and whole responses for the longer ones. Thank you for your help.
Great, there will be a new v0.11.1 release of the WiFi101 shortly that includes the fix.
It produces various results like adding parts of the header at the end of the response, or not giving the entire response.