12:29, EEST
April 1, 2022
Hi,
I am developing an OPC UA Publisher that sends data to Google Cloud Platform MQTT bridge?
Currently I am stuck in the situation where I get the “error message”:
“11:56:17.339 [main] WARN com.prosysopc.ua.pubsub.ae – Failed to connect to MQTT server ssl://mqtt.googleapis.com:8883, Cause: MqttException (MQTT reason code: 0)”
I have created the certfications and add the public one to GCP. Minor changes were done to SSLUtils.getSocketFactory to make it use certification root file. “static SSLSocketFactory getSocketFactory2(final String caCrtFile, final String crtFile, final String keyFile, final String password)”
I have followed these instructions on google cloud docs:
https://cloud.google.com/iot/docs/how-tos/credentials/jwts
https://cloud.google.com/iot/docs/how-tos/mqtt-bridge
I am also wondering is it even possible to create the communication with Google Cloud Platform, since Json Web Token has to be used in the communication?
15:25, EEST
April 3, 2012
Hi,
Hmm.. well I can say that we have not tried that ourselves, so I’m not sure.
The current implementation relies on Eclipse Paho for the MQTT client, in there I could find: https://github.com/eclipse/paho.mqtt.java/issues/869, which pointed to https://github.com/eclipse/paho.mqtt.c/issues/808.
So for the JWT itself putting it as the password might work. But the expiry of it would be a problem by itself, since the current design has not taken into account that the password could change.
But for setting the password, see the SamplePubSubConfiguration.createMqttOverrides and the
// User Authentication to the MQTT Broker builder.setAuthConfToCredentialsResolver(input -> { // If you have more than one broker connection, the input could be used to differentiate // credentials PubSubUsernamePasswordBrokerCredentials.Builder mqttCredentials = PubSubUsernamePasswordBrokerCredentials.builder(); mqttCredentials.setUsername(brokerUsername); mqttCredentials.setPassword(brokerPassword); return mqttCredentials.build(); });
part.
The input to the lamda is a com.prosysopc.ua.pubsub.PubSubBrokerAuthConf that you might have set for the connection conf with .setAuthConf(…). In short the resolver function set to the PubSubSystemOverrides basically “emulates” an https://reference.opcfoundation.org/Core/docs/Part14/5.4.4/#5.4.4.4 implementation (since we do not have one, so for the time being be just have a handle to “plug something here”). There are mentions of JWTs in https://reference.opcfoundation.org/v104/Core/docs/Part6/6.5.2/, though I think that was for the client-server sessionless service invocation service, but maybe the same concept can be used in PubSub (I’m not aware of anyone using the sessionless service calls, and I think we do not support those either). So it is possible that on some level the specification “supports JWTs”, just that our SDK does not.
If you can first check can you make the connection work for a short while (until the JWT expires) with the JWT as password then maybe we can add support for setting the password repeatedly (or make it so that the function is called at every mqtt connection attempt). And it might require that the Paho library updates (or that we look for some other mqtt client implementation).
P.S.
There seems to be a mention of Eclipse Paho in the link you sent so maybe we can test this ourselves at some point.
Most Users Ever Online: 1919
Currently Online:
24 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Heikki Tahvanainen: 402
hbrackel: 144
rocket science: 88
pramanj: 86
Francesco Zambon: 83
Ibrahim: 78
Sabari: 62
kapsl: 57
gjevremovic: 49
Xavier: 43
Member Stats:
Guest Posters: 0
Members: 735
Moderators: 7
Admins: 1
Forum Stats:
Groups: 3
Forums: 15
Topics: 1523
Posts: 6449
Newest Members:
rust, christamcdowall, redaahern07571, nigelbdhmp, travistimmons, AnnelCib, dalenegettinger, howardkennerley, Thomassnism, biancacraft16Moderators: Jouni Aro: 1026, Pyry: 1, Petri: 0, Bjarne Boström: 1026, Jimmy Ni: 26, Matti Siponen: 346, Lusetti: 0
Administrators: admin: 1