You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After generated keys with the script (/iot/api-client/generate_keys.sh), created a registry, a device (and pushed the content of the file rsa_cert.pem), and a subscription, I try to push MQTT messages with the code example given in the folder iot/api-client/manager. But I have got a Not authorized to connect error:
mvn exec:java Dexec.mainClass="com.example.cloud.iot.examples.MqttExample" \
-Dexec.args="-project_id=myproject \
-registry_id=myregistry \
-device_id=mydevice \
-private_key_file=../rsa_private_pkcs8 \
-algorithm=RS256"
...
[INFO] --- exec-maven-plugin:1.6.0:java (default-cli) @ cloudiot-manager-demo ---
An error occurred: Not authorized to connect
[WARNING]
org.eclipse.paho.client.mqttv3.MqttSecurityException: Not authorized to connect
at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException (ExceptionHelper.java:28)
at org.eclipse.paho.client.mqttv3.internal.ClientState.notifyReceivedAck (ClientState.java:988)
at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run (CommsReceiver.java:145)
at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:511)
at java.util.concurrent.FutureTask.run (FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201 (ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run (ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:624)
at java.lang.Thread.run (Thread.java:748)
It works with the Python and NodeJS example codes (with the right privacy key).
Did I do something wrong?
PS: Also tried the keys in the repository w/o success.
You're correctly using the pkcs8 key, because the Java sample is the only one that requires the pkcs8 key, this makes me guess it's the source of the issue. I just successfully tested registering a device with new keys using the Java manager and MQTT client. Maybe there's a bug with key expirations?
PS: Also tried the keys in the repository w/o success.
These keys are just used to build up the tests and should not be used for development.
You might want to try deleting your keys and then re-creating them before registering your virtual device and connecting to the MQTT bridge. I'm invoking the sample as:
Hi @gguuss, thanks for your reply. As you would suggest, I tried to register the client with the code and got a region error. Bingo! That's the thing I forgot :(. With the cloud_region option, it works.
Activity
gguuss commentedon Feb 18, 2018
You're correctly using the pkcs8 key, because the Java sample is the only one that requires the pkcs8 key, this makes me guess it's the source of the issue. I just successfully tested registering a device with new keys using the Java manager and MQTT client. Maybe there's a bug with key expirations?
These keys are just used to build up the tests and should not be used for development.
You might want to try deleting your keys and then re-creating them before registering your virtual device and connecting to the MQTT bridge. I'm invoking the sample as:
It's possible that the openssl defaults are setting an expiration date and your (old) keys have expired (e.g. missing
-days xxxxxflag.gguuss commentedon Feb 18, 2018
Also, which version of Java are you using? I'm currently testing with 1.8.
sdouche commentedon Feb 19, 2018
Hi @gguuss, thanks for your reply. As you would suggest, I tried to register the client with the code and got a region error. Bingo! That's the thing I forgot :(. With the
cloud_regionoption, it works.Sorry.
gguuss commentedon Feb 20, 2018
@sdouche Feel free to file a feature request / issue to check the parameters and improve the README.
deps: update dependency com.google.cloud:google-cloud-core to v2.8.20 (…
samples: migrate code from googleapis/java-vision (#7428)
samples: migrate code from googleapis/java-vision (#7428)
chore(main): release 3.7.5 (#1025)