What's the purpose of sub id in a DDP subscription?

I’m wondering what the purpose, under the hood, of the subscription id attached to ddp subscription request is? How unique does it need to be?

It’s mostly used so that the client can send the unsub message to tell the server to stop the subscription, I think.

Since you mentioned under the hood, if you’re interested in the specifics from the code, see the following (in particular line 615 shows the ID being used with the sub message, line 607 shows it being used with the unsub message):

https://github.com/meteor/meteor/blob/devel/packages/ddp-client/livedata_connection.js#L588-L616

2 Likes

I have to pick this up again because of a bug I found in the meteor package meteor-publish-join where I’ve found the following:

I had a user, who quite often received the same subscription-id on two different connections. It was always a connection established from the same IP address and the same user-agent. It wasn’t really reproducible for me, but I want to know this:

I’ve now proven that the subscription-id isn’t unique on the server-side :sweat_smile: but is it actually unique on the client-side - I mean, per connection?