Using the new Arduino IDE for ESP8266 and found bugs, report them here

Moderator: igrr

User avatar
By inx
#33148 When using WiFiClient to send data to a TCP-Server provided either by Max/MSP (java) or openFrameworks (cpp) it crashes after sending ~160 times.
It behaves the same on both server implementations.
Both server do not send anything back to the connected client.

here the stack:

Exception (28):
epc1=0x40206bba epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

ctx: cont
sp: 3ffeb7e0 end: 3ffeba10 offset: 01a0

>>>stack>>>
3ffeb980: 3ffe8000 3ffea6c8 3ffeba68 3ffeba3c
3ffeb990: 3ffe8000 3ffea6c8 3ffeba68 40206c3a
3ffeb9a0: 00303831 00000064 3ffeba68 40206cd6
3ffeb9b0: 3ffe92eb 3ffea6c8 3ffeba68 4020234b
3ffeb9c0: 3ffe9480 00000000 000003e8 40206d51
3ffeb9d0: 00000000 3fff3798 00000000 0000000f
3ffeb9e0: 0000000e 8bb2a8c0 00000000 00000000
3ffeb9f0: 3fffdc20 00000000 3ffeba34 4020186a
3ffeba00: 00000000 00000000 3ffea9f0 40100398
<<<stack<<<
User avatar
By igrr
#33229 Thanks for the report!
Could you please share the sketch and java/cpp application so that I can reproduce this issue?
User avatar
By inx
#33345 Hi

here the sketch:
Code: Select all#include <ESP8266WiFi.h>

const char* ssid     = "";
const char* password = "";

const char* host = "";

void setup() {
  Serial.begin(115200);
  delay(10);

  // We start by connecting to a WiFi network

  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);
 
  WiFi.begin(ssid, password);
 
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.println("WiFi connected"); 
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}

int value = 0;

void loop() {
  delay(100);
  ++value;

  Serial.print("connecting to ");
  Serial.println(host);
 
  // Use WiFiClient class to create TCP connections
  WiFiClient client;
  const int httpPort = 9002;
  if (!client.connect(host, httpPort)) {
    Serial.println("connection failed");
    return;
  }
 
  // We now create a URI for the request
  String url = "/input/";
  url += "&value=";
  url += value;
 
  Serial.print("Requesting URL: ");
  Serial.println(url);
 
  // This will send the request to the server
  client.println(value);
  delay(10);
 
  Serial.println();
  Serial.println("closing connection");
}


servers:

openFrameworks:
official 0.8.4 release: http://openframeworks.cc/download/
or use a nightly build: on the same page at the bottom.
the server-example is in: openFrameworks/examples/addons/networkTcpServerExample
remove line 23 in ofApp.cpp, so the server does not talk back to the clients

MaxMSP:
find a runtime (osx/win) here: https://cycling74.com/downloads/older/#.Vj3hYrexwng
the patch is attached, unzip and open with the runtime.
java has to be installed. (on osx java 1.6 must be installed due to 32bit compatibility)

thanks.
You do not have the required permissions to view the files attached to this post.
User avatar
By igrr
#33427 Ok, so far I wasn't able to set up this environment (I'm having some java issues) but the problem with this sketch is clear.
On the ESP side, you are doing active close of TCP connection (i.e. esp initiates connection close). Therefore, TCP connection enters TIME_WAIT state and resources are not released for about two minutes.
So after a few requests esp runs out of RAM.

You need to do something similar to HTTP "Connection: close" header, instructing the server to close the connection. This way ESP will do passive close, and memory used by TCP connection will be released immediately.