getResourceValue() APIs of Mbed Cloud JAVA SDK throw timeout exception always

Hi everybody,

I want to get the data value from mbed cloud and I used the getResourceValue() method from API of Mbed Cloud JAVA SDK
However, it throw timeout exception always

I have followed the examples provided here - https://github.com/ARMmbed/mbed-cloud-sdk-java/tree/master/examples/src/main/java/pelion_cloud_sdk

example:

ConnectionOptions config = ConnectionOptions.newConfiguration(“ak_1MDE2OWU2MzZiNzJiM2FmNTA2ZDA1MGU1MDAwMDAwMDA016a2fc569c2e6f31f84b37400000000eGpIsKro2aWTF0nbOOFl7AF8MPGsIdRw”);
Connect api = new Connect(config);
String deviceId = “016a4e38315600000000000100100391”;
String resourcePath = “/3336/0/5515”;
try {
Object value = api.getResourceValue(deviceId, resourcePath, new TimePeriod(10));
String data = String.valueOf(value);
System.out.println("dispaly data from mbed cloud: " + String.valueOf(value));
// Stopping potential daemons running
api.stopNotifications();
api.shutdownConnectService();
} catch (MbedCloudException e) {
e.printStackTrace();
}

Please help.

Note: I am using mbed-cloud-sdk v2.2.1 and my application runs on Android O+ devices.

Thanking you,

Regards,
Lam

Hi Lam,

Please chech the connection to the Pelion (mbed cloud). The reason might be that the TimePeriod is too short for getting answer from the Pelion or there is no connection at all. If you had connection the Pelion will answer something if you have something wrong in your query like the device does not exist or the resource does not exist.

Thanks,
Pekka

Hello @lamhv2,

Sorry for the late reply.
Could you attached the exception you are getting?
Is the API key you are using valid? You have to create one using the Pelion portal (https://portal.mbedcloud.com/)

Moreover, in the future, avoid putting your API key in public comments as this is a breach of security.