Connectivity Software User's Guide and Reference
ClientId Property (SparkplugConnectionStateChangedEventArgs)



OpcLabs.EasySparkplug Assembly > OpcLabs.EasySparkplug.OperationModel Namespace > SparkplugConnectionStateChangedEventArgs Class : ClientId Property
The client ID associated with this event.
Syntax
'Declaration
 
<JetBrains.Annotations.NotNullAttribute()>
Public Property ClientId As String
'Usage
 
Dim instance As SparkplugConnectionStateChangedEventArgs
Dim value As String
 
instance.ClientId = value
 
value = instance.ClientId
[JetBrains.Annotations.NotNull()]
public string ClientId {get; set;}
[JetBrains.Annotations.NotNull()]
public:
property String^ ClientId {
   String^ get();
   void set (    String^ value);
}

Property Value

The value of this property cannot be null (Nothing in Visual Basic).

The default value of this property is "" (String.Empty).

Exceptions
ExceptionDescription

A null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.

This is a usage error, i.e. it will never occur (the exception will not be thrown) in a correctly written program. Your code should not catch this exception.

Remarks

This is the effective client ID (i.e. it contains the auto-generated client ID if no client ID was specified).

There are limitations to the MQTT client ID as defined by the MQTT protocol specification. These limitations ensure that the client ID is valid and can be used effectively by the MQTT broker. Here are the key constraints:

  1. Length
    • MQTT 3.1.1: The client ID must be between 1 and 23 characters in length. If the client ID exceeds this length, the broker will reject the connection.
    • MQTT 5.0: The client ID can be up to 65535 characters in length. However, brokers may impose their own limits, so it's best to keep the client ID reasonably short.
  2. Uniqueness
    • The client ID must be unique across all clients connected to the same broker. If two clients use the same client ID, the broker will disconnect the existing client when the new one connects.
  3. Allowed Characters
    • In MQTT 5.0, the client ID can include any UTF-8 encoded characters. However, it is recommended to use alphanumeric characters and avoid special characters to ensure compatibility with all brokers. In MQTT 3.1.1, only the characters "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" can be used.

 

Sparkplug is a trademark of Eclipse Foundation, Inc. "MQTT" is a trademark of the OASIS Open standards consortium. Other related terms are trademarks of their respective owners. Any use of these terms on this site is for descriptive purposes only and does not imply any sponsorship, endorsement or affiliation.

Requirements

Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2016, Windows Server 2022; .NET: Linux, macOS, Microsoft Windows

See Also