Private Event Publishing

I’m trying to get two cores to publish events to each other. If I subscribe to an event from ‘MY_DEVICES’ on one and publish that event PUBLICLY on the other then it works ok and I can see some lights flash for confirmation.
Spark.publish(“temperature”, “data”);

If I try and publish a PRIVATE event in the same scenario then nothing happens and the second core doesn’t pick it up.
Spark.publish(“temperature”, “data”, 60, PRIVATE);

The subscribe portion works ok filtering by my devices (i.e. I don’t see a thousand’s people temperature events being received).

Anyone got any ideas why?

I think this is a good question for @Dave at Spark.

You could also try the subscribe that takes a deviceID string so you would be looking for the exact core that is publishing.

Spark.subscribe("temperature", handler, "5ffffffabcdef01234");


The subscribe part filters ok for all my devices which means it does work for now but all my events that I would keep private are published publicly.

Both cores would need to be registered to the same user-account to see private events published by one on the other. I guess I don’t totally understand, it sounds like you said the subscribe part is filtering for messages from your devices.

Your private events appear public only to you, if you were to login as another user, and view the firehose, or query for your event names, they would not appear if they were published privately.


1 Like

Hi Dave,

To clarify, I subscribe to the temperature event for my devices in the app setup:
Spark.subscribe(“temperature”, myHandler, MY_DEVICES);

If I have the following in my app (public message) it works ok:
Spark.publish(“temperature”, “test”);

If I try and publish privately it doesn’t, the app carries on running fine but the subscribing core never sees the message:
Spark.publish(“temperature”, “test”, 60, PRIVATE);

Both cores are on the same account.


@pchilton Did you get the private events to work? I’m having the same problem you had.

Hi, no I never managed to get it to work.

It definitely looks like a bug in the spark api.

Public messages work fine, private subscribing works fine, private publishing does not. At least you can subscribe to only your events so that your core will only respond to a message from you, but your messages are published publicly to the firehose.

I found this in the Spark.publish() description:

Only the owner of the Core will be able to subscribe to private events.

Which must be why other Cores owned by the same owner cannot see the private events.

Yes I came across that too.

In my tests I tried both testing on the same core and on two cores that were owned by the same user (me) and on the same account (mine). Neither worked…