0

The title pretty well says it. I need the microcontrollers to stay connected to the server to receive updates within a couple of seconds and I'm not quite sure how to do this. The client in this case is very limited to say the least and it seems like all the solutions I've found for polling or something like socket.io require dropping some significant JavaScript to the client. If I'm left having to reimplement one of those libraries in C on the micro I could definitely use some pointers on the leanest way to handle it.

I can't just pound the server with constant requests because this is going to increase to a fair number of connected micros.

kjs3
  • 5,758
  • 8
  • 34
  • 49

1 Answers1

1

Just use ordinary long polling: each controller initially makes an HTTP request and waits for a response, which happens when there's an update. Once the controller receives the response, it makes another request. Lather, rinse, repeat. This won't hammer the server because each controller makes only one request per update, and node's architecture is such that you can have lots of requests pending, since you aren't creating a new thread or process for each active connection.

ebohlman
  • 14,795
  • 5
  • 33
  • 35