Preventing duplicate well-known name

asked 2014-05-08 12:03:13 -0700

mattpho gravatar image

Hi, I'd like to make sure that there is only one device advertising a well known name. I tried using DBUS_NAME_FLAG_REPLACE_EXISTING | DBUS_NAME_FLAG_DO_NOT_QUEUE in RequestName() and ran two instances of the same service expecting that the 2nd one gets an error from RequestName() or AdvertiseName() but it doesn't.

Is there a way to prevent devices with the same well-known name?

Strangely, the client randomly connects to one of the service twice (I am using Windows7 SDK version 14.02). Is this a known bug?

Thank you


edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2014-05-09 22:17:36 -0700

georgen gravatar image

There is no way to prevent two different devices advertising the same well known name.

The DBus flags: DBUS_NAME_FLAG_REPLACE_EXISTING and DBUS_NAME_FLAG_DO_NOT_QUEUE only apply to the the RequestName method. This prevents have two leaf nodes with the same name on a single routing node. There is no way to know if a name you want to use is already being advertised by another device. Unless you want to do a FindAdvertisedName call an check to see it the name does not exist.

Right now its recommended to add something to the name at run time to distinguish it from other devices. For example the chat sample app take a sting entered by the user when they launch the application. At run time it appends that name to the well-known name prefix.

AllJoyn contains a method that makes it easy to produce names that are unique from each other. the BusAttachment::GetGlobalGUIDString can be used to produce a well-known name that is unique.

see: well-known name

It is up to the developer to ensure the name they advertise is unique. If the name is not unique then the program will try and join the first device it finds that matches the name it is looking for.

edit flag offensive delete publish link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2014-05-08 12:03:13 -0700

Seen: 85 times

Last updated: May 09 '14