Closed kpdsquare closed 5 years ago
If you use a normal Publication on the same media driver, then 2 clients will share that Publication *(same channel and streamId). For the same media driver, try using ExclusivePublication to avoid sharing.
Note: session IDs are not guaranteed unique. They are only 32-bits. So, they serve your purpose very poorly. If/when they collide, the additional term id serves to have one session win over another on the receiver. You will want to have the server (in a request/response scenario) assign a unique ID instead.
Ah yes, I forgot about the ExclusivePublication. I actually started building the unique ID creation on the server side and independent of the Aeron protocol specification after coming across this issue. It appeared to be a more robust solution. I was trying to take an unnecessary shortcut. Thanks for clarity.
Sorry to reopen this issue, but I was just considering another related scenario. If I have a server on host_1, and a two clients on two different hosts, host_2 and host_3, the server and client applications would need their own media drivers on each host. Am I right to say, it's possible that the publications created on the client applications could have the same session ID even if I use ExclusivePublication?
Yes. It is possible. But very unlikely. However, clashing session Ids (which is, again, very unlikely - 1 in 2^32 roughly) resolve via term ID. One will be ignored over the other. If perhaps termIds are within 1 of each, you should play the lottery. That is 64 bits of entropy (2^64) you just aligned.
Note: many protocols use these techniques. Very little is totally guaranteed.
Understood. So, from what I understand and looking at the code base, in the highly unlikely case that there is a clashing session ID, the AvailableImageHandler on the server side would only be called once when there is a duplicate session ID. Is that correct?
A duplicate session would not generate a new image and thus the handler will not be called.
Thanks for confirming.
Hi,
I think this might be down to my misunderstanding, but after reading the protocol specification and reading this comment https://github.com/real-logic/aeron/issues/537#issuecomment-411745995, I don't understand why I'm seeing a duplicate session ID in the following scenario.
Using Aeron 1.15.2, I have a gateway application on host_1 and two client applications on host_2. Client applications, client_app_1 and client_app_2, both share the same media driver on host_2. Both client applications need to setup a publication to the gateway. Each client creates the publication with channel aeron:udp?endpoint=10.50.30.10:50061 and stream ID -1. What I found was that the two session IDs created for the publications on client_app_1 and client_app_2 are the same. I was expecting the session IDs to be unique. Am I mistaken and not understanding the protocol specification correctly?
I was hoping to use the session ID in a protocol to create necessary request/response publications and subscriptions.