Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sterngefeuert opened this issue Sep 29, 2016 · 5 comments
Open

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

sterngefeuert opened this issue Sep 29, 2016 · 5 comments

Comments

@sterngefeuert
Copy link

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
Copy link

jpeskar commented Sep 29, 2016

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
Copy link
Owner

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
Copy link
Author

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 <[email protected] mailto:[email protected]>:

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 #28 (comment), or mute the thread https://github.com/notifications/unsubscribe-auth/AHQeMktkVJQTwilN0vO3eAK1GK5SEfbvks5qvIirgaJpZM4KKd4l.

@washo4evr
Copy link
Owner

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
Copy link
Author

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:[email protected]]
Sent: 08 October 2016 07:51
To: washo4evr/Socket.io-v1.x-Library [email protected]
Cc: psega [email protected]; Author [email protected]
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 #28 (comment) , or mute the thread https://github.com/notifications/unsubscribe-auth/AHQeMtYGlqjV1wqWRL4XDPvoXyJ9SssCks5qxy8vgaJpZM4KKd4l .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants