java - azure iothub device status -
getconnectionstate() connected /disconnected depending on device .if sending message should see connected , if not sending should disconnected .but each time run below java program getting status disconnected irrespective of device sending messages or not
registrymanager registrymanager = registrymanager.createfromconnectionstring(connectionstring); system.out.println(registrymanager.getdevices(new integer(1000))); while(true){ arraylist<device> deviceslist=registrymanager.getdevices(new integer(1000)); for(device device:deviceslist) { /*system.out.println(device.getdeviceid()); system.out.println(device.getprimarykey()); system.out.println(device.getsecondarykey());*/ system.out.println(device.getdeviceid()); system.out.println(device.getconnectionstate()); /*system.out.println(device.getconnectionstateupdatedtime()); system.out.println(device.getlastactivitytime()); system.out.println(device.getstatusreason()); system.out.println(device.getstatusupdatedtime()); system.out.println(device.getsymmetrickey()); system.out.println(device.getetag()); */ } }
i seeing otherwise.
i'm creating simple c# console application using code below,
static async void querydevices() { registrymanager manager = registrymanager.createfromconnectionstring(connectionstring); while (true) { var devices = await manager.getdevicesasync(100); { foreach (var item in devices) { console.writeline(datetime.now + ": " + item.id + ", " + item.connectionstate); system.threading.thread.sleep(100); } } } }
the git here query whole device list, because connectionstate property somehow looks "static" memebers of single device client instance, not apt-to change when actual state changes.
and output below, "connected" state when i'm using java client sample send message iot hub.
Comments
Post a Comment