No content is returned.
In Spark i use something like this:
void setup() {
client.connect(server, 9606);
}
void loop() {
if(client.connected()) {
client.flush(); //we dont need to read anything, flush it
client.println("GET /l.php?ping"+(String)millis()+" HTTP/1.0");//this is received by server only once :frowning:
client.println();
}
//do stuff, at least for 0.1 seconds
}
Currently similar code has hang my core to factory reset state. I decided that at this point I need an advice how to proceess further.
Parameters of server/port are verified and correct.
Do I need to tcp.connect tcp.print tcp.flush tcp.stop every request? First request goes fine without host, IP+port is enough. So issue about constant repeated requests.
Code below in loop works mostly fine, but produces up to 40 seconds gaps http://screenshots.ryotsuke.ru/scr_eac2d6c02184.png
How can I get rid of delay(magicValue)? How can I make “connect” timeout much lower - 1 sec max
Thicker area is area where data was received. X axis is seconds from core start. Thin line is when no data was coming.
It doesn’t matter what I am logging at all.
Question is what is correct way of repeated frequent sending GET requests. Using magic delay value does not seem to be right.
Make sure you’re making a normal full HTTP request, and also cleaning up your socket when done. You also probably want a delay between when you open a connection to the server, otherwise you’ll be creating and destroying sockets (an expensive operation) very frequently. I had an example function here that also included basic http auth: https://community.spark.io/t/doorbell-to-send-jsonrpc/2805/2?u=dave
40 seconds gaps are when spark is sending requests. When I send from other PC in a loop I’m able to get over 100 log entries per sec.
Please, I want to know internal firmware difference between client.flush and while(client.available) { client.read } and only guys understanding firmware code can answer this.
One more question - is timeouts for connect function are configurable?
As if not I feed it would be more reasonable to use a TCPServer and wait for requests instead of sending to server. I don’t want to have long blocks if WiFi connection drops.
Hmm. I am not sure about the connection timeout for TCPClient. I’m asking our firmware guys about it, but it looks like it’s not easily exposed at the moment.
Hmm, interesting. It appears Spark is breaking connection too early. So actually requests are ~500 micros
Apparently when sending from other PC i am waiting till request works, and in spark not. I guess PC can do multiple socket requests and because of that it is working much faster.
Addining a delay(50) before client.flush, client.stop makes things much more reliable. I still don’t like idea of using magic delay values. I would like to have a method to actually wait for server to completely respond.
I have one idea to test… Will report in a while