No images becomes available for spy subscription when MDC publication with dynamic control mode was created with control endpoint port set to 0
in order for OS to choose the port (ssc=true
was set).
Steps to reproduce:
aeron:udp?control=localhost:0|control-mode=dynamic|ssc=true
with streamId=0
localAddr
via localSocketAddresses
methodaeron-spy:aeron:udp?control=<localAddr>|control-mode=dynamic
with streamId=0
Image is expected to become available for subscription, but it does not happen.
The exact same code works if either port is set to static value instead of 0
or prefix aeron-spy:
is removed from the subscription.
The simple answer to this is that the publication and spy URIs don't actually match. Lets assume that port that gets bound is 32456
publication: aeron:udp?control=localhost:0|control-mode=dynamic|ssc=true
spy: aeron:udp?control=localhost:32456|control-mode=dynamic|ssc=true
Given the OP's code the ports happen to match for some portion of time, but this association is easily broken if the publication is closed and opened again as the port will be different.
There is a recommended approach to apply when using wildcard ports. If you want to reference another publication (e.g. from a spy) or create multiple subscriptions to the same wildcard port then using tags is the appropriate solution:
publication: aeron:udp?control=localhost:0|control-mode=dynamic|ssc=true|tags=1001
spy: aeron-spy:aeron:udp?tags=1001