I know there is a limit on how many functions and variables a spark core can have, but is there a limit on how many subscriptions or published events? I don’t seem to see any reference in the docs that there is a limit. I also don’t see any limits on how long your topic (or event) can be in a subscription or publish command.
Does this mean that you can call that function 4 times meaning if I have to read data or get data from my publisher I can get the data 4 times and after that I wan’t be able to get any data from that publisher.
Its because that my handler function is not being accessed.
Thanks Meth
No, this means that you can only register four different event handlers, but each of these event handlers can be called/triggerd an unlimited number of times. Spark.subscribe does not retrieve event data from the cloud, but only registers the handlers that will thereafter do the “event reception” stuff.
Hi Thanks for the quick reply and for the explanation. I thought that this was the issue but it seems to be something else. What about the Spark server how does it respond on the events that are being called and or which function does retrieve event data ?
Thanks again for the help
To answer this profoundly I’d tag @Dave, but as I see it the cloud server does not actually do anything directly.
I’d rather think that the publishing Core pushes its event data into the cloud where it gets stored for some time (max. time to live TTL) or till another event of the same Core and type gets published.
The subscribing Core in turn just checks regularly if there are any pending events of the expected type and requests the data and feeds it to the event handler fn.
A device that’s publishing is limited to a maximum rate of 1 event per second, or an average of 60/minute. The firmware will let you do a burst of up to 4/second, but then it’ll harshly rate limit the messages until your firmware stops publishing for some time.
The cloud doesn’t limit how many subscriptions you can make, or how many events are sent to your devices, but I think the firmware can only register 4 subscription handlers at the moment. There is a bug right now where the core firmware doesn’t re-send subscription requests if its connection was lost and re-connected, but I’m hoping the firmware team will have a chance to fix that soon. One workaround might be listening for a heartbeat event, and resetting your core if it’s missing. I wrote an example of that here: https://community.spark.io/t/spurious-subscribe-failures/7243/4?u=dave
Hi @Dave, We haven’t been waiting nearly 900 days for this bug fix, surely? Is there an issue with the time stamps of these posts OR how I’m reading the time stamps? The reason I ask is your post mentioning how you hope the firmware team will fix the bug (providing it’s the same bug) seems to be dated to January 2013. I didn’t even think the original Core was that old?!
Hello @Dave,
I am trying to understand where does the limit for the subscription handlers come from. Can you point me to the part of the code where this limitation is set? What should be done to increase the number of allowable subscription handlers?
More interestingly perhaps, what would you need more handlers for? They work as prefixes, so if you subscribe to “pancake”, you’re also going to get “pancake1, pancake2, pancake_what_ever_you_like”. Using the event name, you can filter out which ones are relevant for you, and act accordingly Just throwing it out there.