# register device

**URL:** <https://community.cumulocity.com/t/register-device/4860>\
**Category:** Forum\
**Tags:** cumulocity\
**Created:** [November 8, 2019, 8:16am UTC](https://community.cumulocity.com/t/register-device/4860 "2019-11-08T08:16:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Patrick\_Regina1](https://avatars.discourse-cdn.com/v4/letter/p/41988e/32.png) [@Patrick\_Regina1](https://community.cumulocity.com/u/Patrick_Regina1)\
**Post date:** [November 8, 2019, 8:16am UTC](https://community.cumulocity.com/t/register-device/4860/1 "2019-11-08T08:16:21Z")

</div>

In the documentation it was mentionned i have to use a tenantid.  
But where can i found my tenantID ?

this is my domain name : [https://edf.cumulocity.com](https://edf.cumulocity.com)

here the code i use to obtain the credential for my device. is it OK ?

final String serverUrl = “tcp://mqtt.cumulocity.com:1883”; /\* ssl://mqtt.cumulocity.com:8883 for a secure connection \*/  
final String clientId = “my\_mqtt\_java\_client2”;  
final String device\_name = “14455866”;  
final String tenant = “???”;  
final String username = “xxxxxx”;  
final String password = “xxxxx”;

final MqttConnectOptions options = new MqttConnectOptions();  
options.setUserName(tenant + “/” + username);  
options.setPassword(password.toCharArray());

```
    // connect the client to Cumulocity
    final MqttClient client = new MqttClient(serverUrl, clientId, null);
    client.connect(options);

```

client.subscribe(“s/dcr”, new IMqttMessageListener() {  
public void messageArrived (final String topic, final MqttMessage message) throws Exception {  
final String payload = new String(message.getPayload());

```
            System.out.println("Received operation " + payload);
            if (payload.startsWith("70")) {
                // execute the operation in another thread to allow the MQTT client to
                // finish processing this message and acknowledge receipt to the server
            	System.out.println("credential reçue ..."+payload);
               
            }
        }
    });
    
    Executors.newSingleThreadScheduledExecutor().scheduleWithFixedDelay(new Runnable() {
        public void run () {
            try {
            	client.publish("s/ucr", new MqttMessage(("").getBytes()));
            	System.out.println("publish empty message");
            } catch (MqttException e) {
                e.printStackTrace();
            }
        }
    }, 1, 7, TimeUnit.SECONDS);

```

Best Regards,  
Patrick REGINA

---

<div class="post-metadata">

**Author:** ![Michael\_Welsing](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@Michael\_Welsing](https://community.cumulocity.com/u/Michael_Welsing)\
**Post date:** [November 14, 2019, 2:55pm UTC](https://community.cumulocity.com/t/register-device/4860/2 "2019-11-14T14:55:20Z")

</div>

Hi Patrick,

sorry for my late reply. Please try edf as tenant ID.

best regards  
Michael

---

<div class="post-metadata">

**Author:** ![Akash\_Goswami](https://avatars.discourse-cdn.com/v4/letter/a/a88e57/32.png) [@Akash\_Goswami](https://community.cumulocity.com/u/Akash_Goswami)\
**Post date:** [December 2, 2019, 12:29pm UTC](https://community.cumulocity.com/t/register-device/4860/3 "2019-12-02T12:29:27Z")

</div>

Dear Michael,

How should we get static username/password for device provisioning?

I tried the username/password you mentioned in other forum ([Cumulocity MQTT bootstrap credentials - IoT - Software AG Tech Community & Forums](http://tech.forums.softwareag.com/techjforum/posts/list/69067.page)).

That helps in connecting the device to the MQTT broker but I never receive new credentials in s/crd topic.

---

<div class="post-metadata">

**Author:** ![Michael\_Welsing](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@Michael\_Welsing](https://community.cumulocity.com/u/Michael_Welsing)\
**Post date:** [April 21, 2020, 2:10pm UTC](https://community.cumulocity.com/t/register-device/4860/4 "2020-04-21T14:10:33Z")

</div>

Hi Akash,

those credentials should work there as well.

best regards  
Michael

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/system/32/31990_2.png) [@system](https://community.cumulocity.com/u/system)\
**Post date:** [April 2, 2021, 3:43pm UTC](https://community.cumulocity.com/t/register-device/4860/5 "2021-04-02T15:43:46Z")

</div>

Closed on April 2, 2021, 3:43pm UTC


