washo4evr / Socket.io-v1.x-Library

Socket.io Library for Arduino
108 stars 58 forks source link

Problem: io.emit after socket.on | ESP8266 & nodejs #28

Open sterngefeuert opened 7 years ago

sterngefeuert commented 7 years ago

Hi,

thank you very much for providing your library. Everything I'm doing works just fine expect one problem:

I send a JSON every 500ms. I'm receiving the data on my nodejs server but as soon as I want to emit the data instantly it suddenly stops. (it works 4 to 6 times before it freezes).

Arduino:

void sendJSONdata() {
  StaticJsonBuffer<200> jsonBuffer;
  String JSON;
  JsonObject& root = jsonBuffer.createObject();
  root["id"] = sensorId;
  root["name"] = sensorName;
  JsonObject& data = root.createNestedObject("data");
  data.set("timestamp", millis());
  data.set("pleth", ESP8266TrueRandom.random(0, 100));
  data.set("peakToPeak", ESP8266TrueRandom.random(300, 600));
  data.set("bpm", ESP8266TrueRandom.random(80, 120));
  data.set("spo2", ESP8266TrueRandom.random(96, 100));
  root.printTo(JSON);
  Serial.println(JSON);
  client.sendJSON("JSON", JSON);
}

JavaScript

  socket.on('JSON', function (data) {
       var jsonStr = JSON.stringify(data);
       //var parsed = ParseJson(jsonStr);
     io.emit("test", data);
 });

I would be very grateful if you have an idea to this issue. I reached my limits.

jpeskar commented 7 years ago

If you can send several times before it freezes I would suspect a memory overflow. If you don't need the large buffer i would make it smaller.

washo4evr commented 7 years ago

Hi, it could very well be a memory issue When you compile / transfer to the ESP, how much flash and RAM is in use?

have you tried increasing the delay from 500 to maybe 5000 how soon does it crash?

sterngefeuert commented 7 years ago

Thank you for your quick response and your ideas. I tried what you mentioned but it could not solve my problem. For now I found my solution in using websocket rooms. Overall your library is helping me a lot! :D graze mille.

Am 30.09.2016 um 05:57 schrieb washo4evr <notifications@github.com mailto:notifications@github.com>:

Hi, it could very well be a memory issue When you compile / transfer to the ESP, how much flash and RAM is in use?

have you tried increasing the delay from 500 to maybe 5000 how soon does it crash?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/washo4evr/Socket.io-v1.x-Library/issues/28#issuecomment-250653007, or mute the thread https://github.com/notifications/unsubscribe-auth/AHQeMktkVJQTwilN0vO3eAK1GK5SEfbvks5qvIirgaJpZM4KKd4l.

washo4evr commented 7 years ago

Hi, sorry it didnt work but im glad you found a workaround another question, which exact board are you using?

where are you emitting the data? back to the ESP8266?

sterngefeuert commented 7 years ago

I’m using a WeMos D1 mini. But everything works just fine now.

I’m emitting data from various ESPs to a web application which joins its own room.

From: washo4evr [mailto:notifications@github.com] Sent: 08 October 2016 07:51 To: washo4evr/Socket.io-v1.x-Library Socket.io-v1.x-Library@noreply.github.com Cc: psega sprich@markuspassecker.at; Author author@noreply.github.com Subject: Re: [washo4evr/Socket.io-v1.x-Library] Problem: io.emit after socket.on | ESP8266 & nodejs (#28)

Hi, sorry it didnt work but im glad you found a workaround another question, which exact board are you using?

where are you emitting the data? back to the ESP8266?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/washo4evr/Socket.io-v1.x-Library/issues/28#issuecomment-252405019 , or mute the thread https://github.com/notifications/unsubscribe-auth/AHQeMtYGlqjV1wqWRL4XDPvoXyJ9SssCks5qxy8vgaJpZM4KKd4l .