Avatar

Please consider registering
guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
PubSub connection to Google Cloud Platform
April 1, 2022
12:29, EEST
Avatar
HenrikK
New Member
Members
Forum Posts: 1
Member Since:
April 1, 2022
sp_UserOfflineSmall Offline

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?

April 1, 2022
15:25, EEST
Avatar
Bjarne Boström
Moderator
Moderators
Forum Posts: 982
Member Since:
April 3, 2012
sp_UserOfflineSmall Offline

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.

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
11 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 135

pramanj: 86

Francesco Zambon: 81

rocket science: 75

ibrahim: 75

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

fred: 41

Member Stats:

Guest Posters: 0

Members: 707

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1466

Posts: 6253

Newest Members:

christi10l, ahamad1, Flores Frederick, ellenmoss, harriettscherer, shanonhumphreys, KupimotoblokfuB, tamhollander5, paulinafcf, bridgette18l

Moderators: Jouni Aro: 1009, Otso Palonen: 32, Tuomas Hiltunen: 5, Pyry: 1, Petri: 0, Bjarne Boström: 982, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 26, Teppo Uimonen: 21, Markus Johansson: 42, Niklas Nurminen: 0, Matti Siponen: 319, Lusetti: 0, Ari-Pekka Soikkeli: 5

Administrators: admin: 1