ibm-watson-iot / iot-java Goto Github PK
View Code? Open in Web Editor NEWClient libraries and samples for connecting to IBM Watson IoT using Java
Home Page: https://internetofthings.ibmcloud.com
License: Eclipse Public License 1.0
Client libraries and samples for connecting to IBM Watson IoT using Java
Home Page: https://internetofthings.ibmcloud.com
License: Eclipse Public License 1.0
Hi! First of all thanks for your great work, this sdk helps a lot with integration with IBM Watson IoT Platform.
I noticed that recently when there is an MqttException or MqttSecurityException in the connect method in the AbstractClient System.exit(-1) is called, causing any application using the library to immediately terminate because of a failed connection attempt (maybe simply mistype a authenticationToken). This makes the library almost unusable for many applications. Is there any plan to modify this behaviour in the near future such as throwing the exceptions and let the consumer of the library decide how to react to failures?
Thank you very much and keep up the good work!
I have a system in which devices use REST to talk to my server which acts as an IOT gateway to register and send events on behalf of the devices. This works fine. Now I would like to add remote command/control to the device for which I am creating a DeviceClient on a simulated (java main() on laptop) client. The device uses the same api key and auth token as the gateway and I can see the device in the Devices view on of the dashboard, yet when I connect() I get a connection failure. Are devices created under a gateway allowed to connect directly to the IOT platform? If so, any suggestions. This is also available on http://stackoverflow.com/questions/43660084/i-cant-deviceclient-connect-to-a-device-created-with-a-gatewayclient-on-the-i
Looks like one or more connection parameters are wrong !!!
Apr 27, 2017 9:19:40 AM com.ibm.iotf.client.AbstractClient connect
SEVERE: main: Connecting to Watson IoT Platform failed - one or more connection parameters are wrong !!!
Not authorized to connect (5)
at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:28)
at org.eclipse.paho.client.mqttv3.internal.ClientState.notifyReceivedAck(ClientState.java:990)
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:118)
at java.lang.Thread.run(Thread.java:745)
The connection Properties are as follows:
{API-Key=a-sl0l32-rsmowsjmuj, iotp.enabled=true, type=AudioSensor, Organization-ID=sl0l32, auth-method=token, Authentication-Token=...., id=cognitiveear-gmail.com-sensor-name}
and my Device is listed in the dashboard as follows:
Device ID cognitiveear-gmail.com-sensor-name
Device Type AudioSensor
Date Added Thursday, April 27, 2017
Added By a-sl0l32-rsmowsjmuj
Connection State Registered Refresh
The Java Client Library can corrupt the data returned by API calls if the default charset is not UTF-8. For example, if a device definition contains characters that are not in Windows code page Cp1252, and ApiClient.getAllDevices() is called to retrieve the device details, and the default charset is Cp1252, the characters will be corrupted.
The system should handle all Unicode characters without corruption. The reason for the error is the use of the InputStreamReader(InputStream) constructor in APIClient.java:
private String readContent(HttpResponse response, String method)
throws IllegalStateException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
This constructor uses the default charset. The code should explicitly state the charset like this:
BufferedReader br = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), StandardCharsets.UTF_8));
There are further instances of InputStreamReader(InputStream) in AbstractClient.java that should be investigated and if necessary corrected.
whether in the future the same library for LUA?
We probably want to check the status of the DM request to ensure that action completed successfully as the requirement to pass the jUnit test.
Neither are listed as dependencies but their jars are included in lib and referenced in .classpath. Can they be removed?
w/v0.2.2 I have successfully used DeviceClient.api().publishDeviceEventOverHTTP()
.
I wanted to do likewise from a GatewayClient, for events from the GW device id as well as events from its connected devices.
GatewayClient.api().publishDeviceEventOverHTTP()
throws
Exception in thread "main" com.ibm.iotf.client.IoTFCReSTException: The authentication method is invalid or the API key used does not exist
at com.ibm.iotf.client.api.APIClient.publishMessageOverHTTP(APIClient.java:3307)
at com.ibm.iotf.client.api.APIClient.publishDeviceEventOverHTTP(APIClient.java:3338)
at org.apache.edgent.samples.connectors.iotp.IotpGWClient.publishEventOverHTTP(IotpGWClient.java:78)
My GW registration/cfg-file info is correct as the same cfg info works fine for MQTT publish events and receive cmds.
Also, how does my gateway publish connected device's events over HTTP via GatewayClient.api()?
This task tracks PhysicalInterface implementation of IM APIs in Java Client Libraries
Getting following unknown host error (log below) while using 0.2.4 version.
I am accessing my platform using this link https://7pk5lv.internetofthings.ibmcloud.com/#/ which doesn't have "messaging" after org id and it opens correctly.
Is there any quick way to test if this URL is correct or not?
ssl://7pk5lv.messaging.internetofthings.ibmcloud.com:8883
Apr 07, 2017 6:32:17 PM com.ibm.iotf.client.AbstractClient createClient
INFO: main: Org ID = 7pk5lv
Client ID = d:7pk5lv:VehicleTele:KarimVehicleTele
CONNECTING
Apr 07, 2017 6:32:17 PM com.ibm.iotf.client.AbstractClient connect
INFO: main: Connecting client d:7pk5lv:VehicleTele:KarimVehicleTele to ssl://7pk5lv.messaging.internetofthings.ibmcloud.com:8883 (attempt #1)...
Published the event successfully !
Apr 07, 2017 6:32:28 PM com.ibm.iotf.client.AbstractClient connect
SEVERE: main: Connecting to Watson IoT Platform failed
MqttException (0) - java.net.UnknownHostException: 7pk5lv.messaging.internetofthings.ibmcloud.com
at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:38)
at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:690)
at java.lang.Thread.run(Unknown Source)
Caused by: java.net.UnknownHostException: 7pk5lv.messaging.internetofthings.ibmcloud.com
at java.net.InetAddress.getAllByName0(Unknown Source)
at java.net.InetAddress.getAllByName(Unknown Source)
at java.net.InetAddress.getAllByName(Unknown Source)
at java.net.InetAddress.getByName(Unknown Source)
at org.eclipse.paho.client.mqttv3.internal.TCPNetworkModule.start(TCPNetworkModule.java:75)
Seems like the Java proxy configuration is ignored by the DeviceFactory.connect() method, which causes DeviceFactory.getDevices() (as well as other public methods) to fail:
WARNING: Connect to internetofthings.ibmcloud.com:443 [internetofthings.ibmcloud.com/158.85.136.146] failed: Connection refused: connect
Setting a RequestConfig to the request built by DeviceFactory.connect() does the trick.
Ex:
HttpGet get = new HttpGet(url);
//begin fix
HttpHost proxy = new HttpHost("myproxy.com", 3128);
RequestConfig config = RequestConfig.custom().setProxy(proxy).build();
get.setConfig(config);
//end fix
Is there any plan to introduce support of proxies?
Maybe using System properties https.proxyHost and https.proxyPort?
Thanks!
Update this project so that it can be built using maven (create a pom.xml) rather than the (temporary, but we're still using it a year later) build.xml that I knocked up at the start :)
The end goal should be that we can run "maven deploy" to build, test and publish the library to central repo, so that anyone can automatically import this dependency into their projects just by adding it as a dependency in their pom.
Hi Team
From the past 1 hour iam facing one issue, iam not able to add device using the java api, Iam facing the bellow mention problem, the same code piece is working fine earlier.
"Exception in thread "main" com.ibm.iotf.client.IoTFCReSTException: The authentication token is empty or invalid"
Can you please help me on this
In jMeter test automation, I encountered a failure where error codes 400 and 403 were returned for DM request. 403 means that pending active DM request is in progress for one or more devices. 400 means incorrect request format.
Currently, 400 and 403 are mapped to Unexpected error:
2016/09/16 20:54:06 ERROR - com.ibm.iotf.load.test.dm.GatewayDeviceActions: initiateAction Thread 10: failed to initiate device action firmware/download HTTP error code: 403 Reason: Unexpected error code
2016/09/16 21:35:12 ERROR - com.ibm.iotf.load.test.dm.GatewayDeviceActions: initiateAction Thread 5: failed to initiate device action device/factory_reset HTTP error code: 400 Reason: Unexpected error code Response: null
The clients will auto reconnect when they detect that the connection has been lost. I think this is a good feature; but I noticed that if an application wants to close down the client but remain running, this reconnect thread will keep trying forever. Should there be some association with a call to disconnect() that would break out of this loop?
The client doesn't seem to connect on Android, just keeps repeating making connection attempt with no obvious errors or stacktraces.
I see there is an iot-starter-for-android project, but wondering what the longer term plan is, a single client or two separate clients with different apis?
I was using the shaded jar with deps for a standalone deployment (not relying on Maven) and was running into runtime errors (See below).
I could fix it by modifying the shade configuration to the following (see the following to get further explanation on this below fix - https://stackoverflow.com/questions/999489/invalid-signature-file-when-attempting-to-run-a-jar):
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:347)
at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:301)
at java.util.jar.JarVerifier.processEntry(JarVerifier.java:327)
at java.util.jar.JarVerifier.update(JarVerifier.java:239)
at java.util.jar.JarFile.initializeVerifier(JarFile.java:459)
at java.util.jar.JarFile.getInputStream(JarFile.java:526)
at sun.misc.URLClassPath$JarLoader$2.getInputStream(URLClassPath.java:1083)
at sun.misc.Resource.cachedInputStream(Resource.java:106)
at sun.misc.Resource.getByteBuffer(Resource.java:189)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:692)
at java.net.URLClassLoader.access$400(URLClassLoader.java:95)
at java.net.URLClassLoader$ClassFinder.run(URLClassLoader.java:1184)
at java.security.AccessController.doPrivileged(AccessController.java:686)
at java.net.URLClassLoader.findClass(URLClassLoader.java:604)
at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:850)
at java.lang.ClassLoader.loadClass(ClassLoader.java:829)
at java.lang.ClassLoader.loadClass(ClassLoader.java:809)
at java.lang.J9VMInternals.prepareClassImpl(Native Method)
at java.lang.J9VMInternals.prepare(J9VMInternals.java:291)
at java.lang.Class.getMethods(Class.java:1347)
Issue to track the support of Client Side Certificates based authentication to connect to WIoTP through iot java library.
2 device types and 1 device were left in the organization after local build:
The links in the README to "Devices section", "Managed Device section" and "Applications section" are broken.
Example:
Intended payload
{"myNumber":201601,"Message":"Test","Interval":30}
Payload received by device:
{"d":{"myNumber":201601,"Message":"Test","Interval":30},"ts":"2016-08-18T10:15:40.108+0000"}
This is very inconvenient due to following reasons:
Please, consider changing the CommandPublish function so that it would Not Modify InputData.
I am checking how we set username for HTTP basic authentication, looking at this code : https://github.com/ibm-watson-iot/iot-java/blob/master/src/main/java/com/ibm/iotf/client/api/APIClient.java#L132 , the username will be "g/orgId/gwType/gwDevID" . Is that correct?
If there is a network issue, waitForCompletion() will not return. How about a default 10 seconds (10000)?
With 0.2.2, when the config properties use the new style Gateway-ID
key instead of the old id
GatewayClient.getDeviceId()
returns null
. getGWDeviceId()
is correct.
GatewayClient
needs to override AbstractClient.getDeviceId()
.
Apache Edgent provides a connector to Watson IoT using the iot-java client under the covers.
An Edgent user asked about support for a case where the IoT device application needs to run and accumulate publish events in the face of intermittent connectivity to the IoT platform, with the events ultimately delivered/published when the connection is reestablished. i.e., the device application essentially desires to be unaware of / isolated from actual connectivity to the IoT platform.
Itโs possible that a IoT platform connection canโt be made when the device app starts or that the connection is unintentionally intermittent (e.g., due to loss of wifi signal), or intentionally intermittent such as if the device/app desires a policy of only periodically connecting to the IoT platform to publish events that occurred while disconnected.
I donโt believe this scenario is addressed by the current QOS-1 or QOS-2 event publishing controls - i.e., I believe a successful connect() must be performed prior to calling publishEvent(), and also that publishEvent() will fail, without queueing the event, if a connection isnโt present at the time itโs called?
Comments / thoughts on this overall (common?) scenario and iot-javaโs current or anticipated capabilities?
Thanks in advance!
Issue #11 which is closed, provides a fix to apparently enable this library on Android. However, this seems to be a bit of a hassle. Or, might we get a real sample that works on Android?
The APIClient provides a generic reason for any failure when constructing Exceptions, instead of passing in a reason if available from the result itself. For example:
Creates an Exception with reason text:
"Invalid request (No body, invalid JSON, unexpected key, bad value)"
when actually the reason from the result of the API call is:
"violations": [
{
"message": "CUDRS0053E: The authToken field was not a valid password. The password must be between 8 and 36 characters long (inclusive). The password must consist only of alpha-numerical characters plus hyphen ( - ), underscore ( _ ) or period ( . ).",
"exception": {
"id": "CUDRS0053E",
"properties": [
"authToken"
],
}
}
],
"message": "CUDRS0007E: The request was not valid. Review the constraint violations provided.",
"exception": {
"id": "CUDRS0007E",
"properties": [],
}
}
The client could do a better job of surfacing the real reason for the failure instead of a generic explanation of the HTTP code.
This is with 0.2.2. While looking at the GatewayClient code to understand another issue, I noticed that reconnect() only reinstates subscriptions for the gateway device not any other subscribeToDeviceCommands()
subscriptions.
I'm encountering this with 0.2.2 and the master branch seems to be unchanged relative to this. Based on getData()'s doc I would have expected JsonObject or String.
Message's ctor does this.payload = msg.getPayload().
I'm guessing the intent was that the json processing flow below that should have a this.payload = payloadJson
but it doesn't.
Attributes defined in class com.ibm.iotf.client.app.Status do not match what is currently being returned by IoTF and it fails with a NullPointerException. Below a few sample status message that currently fail.
{
"Action": "Disconnect",
"Time": "2016-07-14T10:00:45.959Z",
"ClientAddr": "XXX.XXX.XX.XXX",
"ClientID": "d:XXXXXX:XXX:XXXXXXXX",
"Port": 8883,
"SecureConnection": true,
"Protocol": "mqtt4-tcp",
"User": "use-token-auth",
"ConnectTime": "2016-07-14T09:46:40.688Z",
"ReadBytes": 27385,
"ReadMsg": 74,
"WriteBytes": 607,
"WriteMsg": 2
}
{
"Action": "Connect",
"Time": "2016-07-29T10:08:29.322Z",
"ClientAddr": "XXX.XXX.XX.XXX",
"ClientID": "d:XXXXXX:XXXXXXX:XXXXXXXXX",
"Port": 1883,
"Secure": false,
"Protocol": "mqtt3"
}
{
"Action": "Disconnect",
"Time": "2016-07-29T10:17:31.335Z",
"ClientAddr": "XXX.XXX.XX.XXX",
"ClientID": "d:XXXXXX:XXXXXXX:XXXXXXXXX",
"Port": 1883,
"Secure": false,
"Protocol": "mqtt3",
"ConnectTime": "2016-07-29T10:08:29.300Z",
"ReadBytes": 112610,
"ReadMsg": 549,
"WriteBytes": 27,
"WriteMsg": 0
}
What are the prerequisites before running the tests? I know that I need to generate API-key and token. Do I need to create device type or device(s) in the UI prior to building the iot-java library? Please provide sample required updates to the properties files in test/resources directory.
Hi,
it seams to me there is a small problem with certificate based authentication.
If you want to use certificate based authentication with the DeviceClient you have to specify a server certificate. With the default certificate in WIoT that should not be necessary and instead the truststore should be searched for a valid certificate in the trust chain. That is currently not possible.
(see
If i missed something to make it work, please correct me. However, the sample at https://developer.ibm.com/recipes/tutorials/connect-raspberry-pi-to-ibm-watson-iot-platform-using-selfsigned-server-certificate/
is not working when "translated" to java.
Another thing is, why is the client trying to reconnect when there is no valid certificate to verify the server certificate? That's a dead end and should break the cycle immediately with a propper error message.
Sample code used:
Properties properties = new Properties();
properties.put("Organization-ID", "yourOrg");
properties.put("Authentication-Method", "token");
properties.put("Authentication-Token", "yourToken");
properties.put("Device-ID", "yourDeviceId");
properties.put("Device-Type", "yourDeviceType");
properties.put("Use-Secure-Certificate", "true");
properties.put("Server-Certificate", "/path/to/rootCA.pem"); #should not be necessary with default cert
properties.put("Client-Certificate", "/path/to/client.pem");
properties.put("Client-Key", "/path/to/client.key");
com.ibm.iotf.client.device.DeviceClient deviceClient = new DeviceClient(properties);
deviceClient.connect();
I'm trying to use the above API in iot-java 0.1.5 with quickstart. The operation fails. Apparently it isn't forming the correct URL w/port?
SEVERE: pool-1-thread-7-IotpQuickstart: HTTP Code: 307
URL: http://quickstart.internetofthings.ibmcloud.com/api/v0002/device/types/iotsamples-edgent/devices/qs29f8fc114c1443d4/events/sensors
...
Location http://quickstart.messaging.internetofthings.ibmcloud.com:1883/api/v0002/device/types/iotsamples-edgent/devices/qs29f8fc114c1443d4/events/sensors
Is there anything I can do to make it work w/0.1.5?
Same thing happens w/0.2.2 with that, now deprecated, method... though deviceClient.api().publishDeviceEventOverHTTP()
does work. Is 0.2.2 with the APIClient method the only viable option?
Is there a API support for creating message source, message schema, rules, actions and alerts? I see that the capabilities of Real time Insights are added into the Watson IoT platform. Are these capabilities going to be added in the next versions of the client library? If not, are there REST APIs to achieve the same thing?
I am debugging an issue when Watson IoT Platform does not respond to manage request. This could be a bug in Watson IoT platform because the iot-java library sometimes send empty deviceInfo.
Writing log file to: C:\ism_test\apache-jmeter\apache-jmeter-3.0\bin\jmeter.log
Aug 18, 2016 11:28:57 PM com.ibm.iotf.client.AbstractClient createClient
INFO: Test Thread Group 1-1: Org ID = 6lvecv
Client ID = g:6lvecv:DMGwType0:DMIoTDev0
Aug 18, 2016 11:28:57 PM com.ibm.iotf.client.AbstractClient connect
INFO: Test Thread Group 1-1: Connecting client g:6lvecv:DMGwType0:DMIoTDev0 to tcp://6lvecv.messaging.internetofthings.ibmcl
oud.com:1883 (attempt #1)...
Aug 18, 2016 11:28:57 PM com.ibm.iotf.client.AbstractClient createClient
INFO: Test Thread Group 1-2: Org ID = 6lvecv
Client ID = g:6lvecv:DMGwType1:DMIoTDev0
Aug 18, 2016 11:28:57 PM com.ibm.iotf.client.AbstractClient connect
INFO: Test Thread Group 1-2: Connecting client g:6lvecv:DMGwType1:DMIoTDev0 to tcp://6lvecv.messaging.internetofthings.ibmcl
oud.com:1883 (attempt #1)...
Aug 18, 2016 11:28:57 PM com.ibm.iotf.client.AbstractClient connect
INFO: Test Thread Group 1-1: Successfully connected to the IBM Watson IoT Platform
Aug 18, 2016 11:28:58 PM com.ibm.iotf.client.AbstractClient connect
INFO: Test Thread Group 1-2: Successfully connected to the IBM Watson IoT Platform
Aug 18, 2016 11:31:02 PM com.ibm.iotf.devicemgmt.gateway.ManagedGateway sendAndWait
WARNING: Test Thread Group 1-2: NO RESPONSE from Watson IoT Platform on topic iotdevice-1/type/DMGwType1/id/DMIoTDev1/mgmt/m
anage for request: {"d":{"supports":{"deviceActions":true,"firmwareActions":true},"deviceInfo":{},"lifetime":0},"reqId":"9ef
f5560-3da3-427e-a465-50092e1481b1"}
Aug 18, 2016 11:31:02 PM com.ibm.iotf.devicemgmt.gateway.ManagedGateway sendAndWait
WARNING: Test Thread Group 1-2: Connected(true)
Aug 18, 2016 11:31:02 PM com.ibm.iotf.client.AbstractClient disconnect
INFO: StandardJMeterEngine: Successfully disconnected from from the IBM Watson IoT Platform
Aug 18, 2016 11:31:03 PM com.ibm.iotf.client.AbstractClient disconnect
INFO: StandardJMeterEngine: Successfully disconnected from from the IBM Watson IoT Platform
As designed, when the device wants to update any fields in deviceInfo, it includes the field name and new value. (e.g. new firmware version) The iot-java library currently does not provide a method for device to send updated info when it becomes managed again after firmware update.
I was doing some testing of sending a command via the ApplicationClient to a device that was not currently connected. I used a "quality of service" value of 3. I was expecting that the device would receive the message once it connects; but did not. I noticed that the "qos" parameter on the publishCommand method is never used; and a value of 0 seems to be send to the mqtt api.
MqttMessage msg = new MqttMessage(payload.toString().getBytes(Charset.forName("UTF-8")));
msg.setQos(0);
msg.setRetained(false);
Why does createClient print all the authentication information to System.out?
Hi, the very same code doesn't work anymore since TSL has been removed as described here, I'm getthing this error:
INFO: main: Connecting client a:rwyrty:a2g6k39sl6r5 to ssl://rwyrty.messaging.internetofthings.ibmcloud.com:8883 (attempt #1)...
MqttException (0) - java.net.SocketException: Connection reset
at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:38)
at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:690)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:209)
This is my pom.xml
<dependency> <groupId>org.eclipse.paho</groupId> <artifactId>org.eclipse.paho.client.mqttv3</artifactId> <version>1.1.1</version> </dependency> <dependency> <groupId>com.ibm.messaging</groupId> <artifactId>watson-iot</artifactId> <version>0.2.4</version> </dependency>
I'm highly confident that the client library cannot cope with the missing TLS 1.0, can you please re-confirm?
Here my code for reference:
Properties props = new Properties();
props.load(WatsonIoTConnector.class.getResourceAsStream("/ibm_watson_iot_mqtt.properties"));
ApplicationClient myClient = new ApplicationClient(props);
myClient.connect();
And the properties:
## Mandatory fields
id = a2g6k39sl6r5
Organization-ID = rwyrty
Authentication-Method = apikey
API-Key = a-rwyrty-f95d3XXXXX
Authentication-Token = ZHd1&O)_J1&TIXXXXX
I have a web app that does
iotPlatform = new IOTPlatform(gatewayID, IOTPlatformProperties.instance().getProperties());
try {
iotPlatform.connect();
in the web app's contextInitialized() method and the following in contextDestroyed()
if (iotPlatform != null)
iotPlatform.disconnect()
yet, I'm getting this when the server is shutdown.
Apr 11, 2017 2:17:03 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
WARNING: The web application [IoT-AnomalyServer] appears to have started a thread named [MQTT Disc: g:sl0l32:CognitiveEarGW:CognitiveEar-9.76.28.149] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:201)
java.lang.Thread.join(Thread.java:722)
java.lang.Thread.join(Thread.java:683)
org.eclipse.paho.client.mqttv3.internal.CommsReceiver.stop(CommsReceiver.java:92)
org.eclipse.paho.client.mqttv3.internal.ClientComms.shutdownConnection(ClientComms.java:335)
org.eclipse.paho.client.mqttv3.internal.ClientComms$DisconnectBG.run(ClientComms.java:733)
java.lang.Thread.run(Thread.java:785)
Apr 11, 2017 2:17:03 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
WARNING: The web application [IoT-AnomalyServer] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:201)
java.util.TimerThread.mainLoop(Timer.java:563)
java.util.TimerThread.run(Timer.java:516)
Apr 11, 2017 2:17:03 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
WARNING: The web application [IoT-AnomalyServer] appears to have started a thread named [MQTT Snd: g:sl0l32:CognitiveEarGW:CognitiveEar-9.76.28.149] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.lang.Object.wait(Native Method)
java.lang.Object.wait(Object.java:172)
org.eclipse.paho.client.mqttv3.internal.ClientState.get(ClientState.java:762)
org.eclipse.paho.client.mqttv3.internal.CommsSender.run(CommsSender.java:101)
java.lang.Thread.run(Thread.java:785)
Apr 11, 2017 2:17:03 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
WARNING: The web application [IoT-AnomalyServer] appears to have started a thread named [MQTT Rec: g:sl0l32:CognitiveEarGW:CognitiveEar-9.76.28.149] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
java.net.SocketInputStream.socketRead0(Native Method)
java.net.SocketInputStream.socketRead(SocketInputStream.java:127)
java.net.SocketInputStream.read(SocketInputStream.java:181)
java.net.SocketInputStream.read(SocketInputStream.java:152)
com.ibm.jsse2.a.a(a.java:134)
com.ibm.jsse2.a.a(a.java:219)
com.ibm.jsse2.as.a(as.java:648)
com.ibm.jsse2.as.a(as.java:816)
com.ibm.jsse2.e.read(e.java:30)
com.ibm.jsse2.e.read(e.java:2)
java.io.DataInputStream.readByte(DataInputStream.java:276)
org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:92)
org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:116)
java.lang.Thread.run(Thread.java:785)
I've started using the Device- and Application Client and encountered following problem.
When I want to connect to the Watson IoT Platform from inside our corporate network with http proxy I get this error:
INFORMATION: main: Connecting client d:q39aun:iotsample-app:00testDevice00 to ssl://q39aun.messaging.internetofthings.ibmcloud.com:8883 (attempt #1)...
MqttException (0) - java.net.UnknownHostException: q39aun.messaging.internetofthings.ibmcloud.com
at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:38)
at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:664)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.UnknownHostException: q39aun.messaging.internetofthings.ibmcloud.com
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:668)
at org.eclipse.paho.client.mqttv3.internal.TCPNetworkModule.start(TCPNetworkModule.java:70)
at org.eclipse.paho.client.mqttv3.internal.SSLNetworkModule.start(SSLNetworkModule.java:86)
at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:650)
... 1 more
I've tested to set system wide proxy setting with
System.setProperty("http.proxyHost", "localhost"); System.setProperty("http.proxyPort", "xxxx");
and I also tested it with VM options -Dhttp.proxyPort=xxxx ...
The ProxySelector always returns "DIRECT" and my proxy settings were ignored.
Any ideas or suggestions?
when i cloned this project then excuted mvn clean package
got this ERROR:
[ERROR] Failed to execute goal on project watson-iot: Could not resolve dependencies for project com.ibm.messaging:watson-iot:jar:0.2.6: Failure to find org.eclipse.paho:org.eclipse.paho.client.mqttv3:jar:1.1.2-SNAPSHOT in http://maven.aliyun.com/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of nexus-aliyun has elapsed
I tried to find this jar on www.findjar.com but failed ๏ผ
No result found
So,i need help or advice
In our particular network the firewall is not currently letting me connect out to IOT. The ApplicationClient.connect() method has a loop that keeps retrying the connection. This should really be throwing an exception; or have an option/setting that will allow an exception to be thrown on a failure. Otherwise the thread seems to hang forever.
I am trying to register a device to IoT Platform using the java client library. Here is my code,
try {
client.connect();
JsonObject deviceInfo = new JsonObject();
deviceInfo.addProperty("manufacturer", "Philips");
deviceInfo.addProperty("model", "m001");
JsonObject location = new JsonObject();
deviceInfo.addProperty("longitude", 8.107910);
deviceInfo.addProperty("latitude", 8.525342);
deviceInfo.addProperty("elevation", 0);
deviceInfo.addProperty("accuracy", 0);
deviceInfo.addProperty("measuredDateTime", "2016-07-15T12:21:50.879Z");
JsonObject metadata = new JsonObject();
deviceInfo.addProperty("manufacturer", "Philips");
deviceInfo.addProperty("model", "m001");
client.api().registerDevice("LightBulb", "LB002", "&wR+6LHX_QcxwXz4Po", deviceInfo, location, metadata);
} catch (MqttException | IoTFCReSTException e) {
e.printStackTrace();
return;
} finally {
System.out.println("Closing connection to the IBM Watson IoT Platform");
// Once told to stop, cleanly disconnect from the service
client.disconnect();
}
On running this code I am getting a IoTFCReSTException saying,
2016-07-15 19:30:16.221 INFO 10236 --- [nio-8080-exec-1] com.ibm.iotf.util.LoggerUtility : http-nio-8080-exec-1: Successfully connected to the IBM Watson IoT Platform
com.ibm.iotf.client.IoTFCReSTException: Invalid request (No body, invalid JSON, unexpected key, bad value)
at com.ibm.iotf.client.api.APIClient.registerDevice(APIClient.java:1723)
at com.ibm.iotf.client.api.APIClient.registerDevice(APIClient.java:1666)
at com.mindtree.coe.iot.watson.services.AssetsService.addInternetCapableAsset(AssetsService.java:66)
at com.mindtree.coe.iot.watson.controllers.AssetsController.addNewAsset(AssetsController.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
// ... more exception stack trace
2016-07-15 19:30:17.980 INFO 10236 --- [nio-8080-exec-1] com.ibm.iotf.util.LoggerUtility : http-nio-8080-exec-1: Successfully disconnected from from the IBM Watson IoT Platform
What could possibly the issue?
P.S. - There is a device type called LightBulb created in the platform. Manual creation of the device in the IoT platform through the browser works perfectly
Hi All,
Found a issue in APIClient when getting all devices managed by a gateway
missing a / in line 853 of API Client
current:
StringBuilder sb = new StringBuilder("https://");
sb.append(orgId).
append('.').
append(BASIC_API_V0002_URL).
append("/device/types/").
append(gatewayType).
append("/devices").
append(gatewayId).append("/devices");
should be:
StringBuilder sb = new StringBuilder("https://");
sb.append(orgId).
append('.').
append(BASIC_API_V0002_URL).
append("/device/types/").
append(gatewayType).
append("/devices/").
append(gatewayId).append("/devices");
Keep up the good work!
java.lang.NullPointerException
at org.eclipse.paho.client.mqttv3.MqttTopic.validate(MqttTopic.java:147)
at org.eclipse.paho.client.mqttv3.MqttAsyncClient.unsubscribe(MqttAsyncClient.java:917)
at org.eclipse.paho.client.mqttv3.MqttAsyncClient.unsubscribe(MqttAsyncClient.java:898)
at com.ibm.iotf.devicemgmt.device.ManagedDevice.unsubscribe(ManagedDevice.java:636)
at com.ibm.iotf.devicemgmt.device.ManagedDevice$ManagedDeviceClient.unsubscribe(ManagedDevice.java:977)
at com.ibm.internal.iotf.devicemgmt.handler.DMRequestHandler.clearRequestHandlers(DMRequestHandler.java:239)
at com.ibm.iotf.devicemgmt.device.ManagedDevice.sendUnmanageRequest(ManagedDevice.java:530)
at com.ibm.iotcloud.test.jmeter.sampler.dm.FirmwareActions.deleteDevice(FirmwareActions.java:193)
at com.ibm.iotcloud.test.jmeter.sampler.dm.FirmwareActions.teardownTest(FirmwareActions.java:256)
at org.apache.jmeter.protocol.java.sampler.JavaSampler.testEnded(JavaSampler.java:292)
at org.apache.jmeter.engine.StandardJMeterEngine.notifyTestListenersOfEnd(StandardJMeterEngine.java:215)
at org.apache.jmeter.engine.StandardJMeterEngine.run(StandardJMeterEngine.java:436)
at java.lang.Thread.run(Unknown Source)
This would include implementation, sample code and unit testing for the following
Hi,
I've added the library into android studio project with compile group: 'com.ibm.messaging', name: 'watson-iot', version: '0.2.6'
in build.gradle.
The project compiles but I get the following exception when calling: res = apiClient.registerDevice("Android", dev);
ava.lang.NoSuchMethodError: No direct method (Ljava/lang/String;Ljava/nio/charset/Charset;)V in class Lorg/apache/http/entity/StringEntity; or its super classes (declaration of 'org.apache.http.entity.StringEntity' appears in /system/framework/org.apache.http.legacy.boot.jar)
at com.ibm.iotf.client.api.APIClient.connect(APIClient.java:264)
at com.ibm.iotf.client.api.APIClient.registerDevice(APIClient.java:1620)
at com.valka.simusafe_android.MainActivity.onCreate(MainActivity.java:57)
at android.app.Activity.performCreate(Activity.java:6975)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6541)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
After some investigation seems like this happens because using the generic httpclient library instead of httpclient-android.
Is android support planned to be added to the library ?
Or is there a workaround to make it run on android ?
Thanks,
Valentin.
In a Java server application I'm using the IoT library to listen to Device messages, and everything works fine.
Now I'm trying to listen to Device status messages (connection, disconnection) just using the sample code found in the samples, without any luck.
Once i enable the subscription, with or without deviceId and device name, the connection continues to connect and disconnect to the MQTT endpoint with an error like this:
INFORMAZIONI: MQTT Rec: a:fdo3mr:26a0e6cc-e092-4a11-a741-2e4068aa9231: Successfully connected to the IBM Watson IoT Platform dic 12, 2016 3:23:52 PM com.ibm.iotf.client.app.ApplicationClient connectionLost INFORMAZIONI: MQTT Rec: a:fdo3mr:26a0e6cc-e092-4a11-a741-2e4068aa9231: Resubscribing.... dic 12, 2016 3:23:52 PM com.ibm.iotf.client.app.ApplicationClient connectionLost INFORMAZIONI: MQTT Rec: a:fdo3mr:26a0e6cc-e092-4a11-a741-2e4068aa9231: iot-2/type/DellGateway/id/+/mon = 0 dic 12, 2016 3:23:52 PM com.ibm.iotf.client.app.ApplicationClient connectionLost GRAVE: MQTT Rec: a:fdo3mr:26a0e6cc-e092-4a11-a741-2e4068aa9231: Connessione persa Connessione persa (32109) - java.io.EOFException at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:146) at java.lang.Thread.run(Thread.java:745) Caused by: java.io.EOFException at java.io.DataInputStream.readByte(DataInputStream.java:267) at org.eclipse.paho.client.mqttv3.internal.wire.MqttInputStream.readMqttWireMessage(MqttInputStream.java:65) at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:107) ... 1 more
Any ideas or any potential bug in the library that may cause this kind of issues?
This task tracks activities related to implementation of IM APIs in Java Client Library.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.