-->
Page 1 of 1

client.print(buf) or client.write(buf,sizeofbuf) return zero

PostPosted: Mon Mar 20, 2017 5:33 am
by Paul555
Hello,

I have Wemos D1 R2 board. Trying to make a server, controlling other equipment. The program is simple web page with Led On/Off and submit button, the example of with is everywhere on the net (modified a little). The main problem is that the work of the module is very unstable. It is not crashing, by "unstable" I mean the work of the server is inconsistent. When I send a request from browser, often nothing happens (I watch processing progress on serial monitor, Arduino IDE); after second request the server serves it and then I see another "client connected" with empty request and port of witch is one less (I assume it is the previous request that has not beet served). Another "inconsistency" is that when I want to send answer to client, client.print(buf) or client.write(buf,sizeofbuf) (does not matter which I use) often returns zero, which means no bytes sent. Of course this situation ends with time out in browser. I added "while(BytesSent==0)" to repeat sending, and after 10 times without success restart server.

Example:

Client connected.
158.129.7.29:58524

GET /LED=OFF HTTP/1.1

Request processed. Finishing build of html ...
Connected to: WN_MI253
Channel: 9
Signal strength: -57 dBm
Number of bytes written to client: 0
Number of bytes written to client: 0
Number of bytes written to client: 0
Number of bytes written to client: 0
Number of bytes written to client: 0
Number of bytes written to client: 0
Number of bytes written to client: 0
Number of bytes written to client: 0
Number of bytes written to client: 0
Number of bytes written to client: 0
Server restarted.