pahoMqttExt icon

pahoMqttExt

Paho MQTT Connector Extension
pahoMqttExtForum
< All topics

Registered StackHub users may elect to receive email notifications whenever a new package version is released or a comment is posted on the forum.

There are 11 watchers.


pahoMqttWrite error - missing tag on the connector
Matteo Sola14th Oct 2022

If I configure the writable point with pahoMqttConnRef and pahoMqttWrite, I receive the following error log:

<pahoMqtt.mqtt> {connRef:@p:mqtt:r:2adc35d6-3501ab87 "PahoMqtt Conn"} [err] 
Error onWrite
sys::NullErr: java.lang.NullPointerException
  pahoMqttExt::PahoMqttConn.constructMessage (PahoMqttConn.fan:394)
  pahoMqttExt::PahoMqttConn.onWrite (PahoMqttConn.fan:341)
  connExt::Conn.onWrite2 (Conn.fan:864)
  connExt::Conn.doWrite (Conn.fan:853)
  connExt::Conn.receive (Conn.fan:320)
  pahoMqttExt::PahoMqttConn.receive (PahoMqttConn.fan:62)
  connExt::ConnActor.receive (ConnActor.fan:181)
  concurrent::Actor._dispatch (Actor.java:274)
  concurrent::Actor._work (Actor.java:229)
  concurrent::ThreadPool$Worker.run (ThreadPool.java:273)

Looking at the code, it seems that the pahoMqttQos tag is missing on the connector. If I add it, the write works. I assigned to the tag the value 1. Is it correct or is there a specific value to use?

Anyway, trying to add on the same point the pahoMqttCur and the pahoMqttWrite tags, or configuring two different points (one for reading and one for writing), it doesn't work anymore. I should be able to implement publish and subscribe functionality in the same MQTT client, right?

Versions:

  • pahoMqttext v1.0.14
  • SkySpark v3.0
  • pahoMqtt v1.2.1

Thanks

Matteo Sola19th Oct 2022

Hello, any news about my question? Is it something that you can investigate? Thank you

John MacEnri19th Oct 2022

Hi Matteo, I will look at it.

In the meantime, it would be great if you could migrate to the cpMqttExt connector I released earlier this year, as I'd rather keep all developments on that one and try to remove the dependency on the Paho Java MQTT client in favour of the SkyFoundry built native Fantom MQTT client that cpMqttExt uses.

Matteo Sola24th Oct 2022

Hello John, any news? Thank you

John MacEnri24th Oct 2022

I've not had time yet to look into this, but as mentioned, if you can migrate to cpMqttExt and test out using that it would be great, as that's the one I'll be maintaining going forward.

Matteo Sola17th Nov 2022

Hello John, I cannot update to the new SkySpark version right now. Anyway I think that the issue is the same. Did you have time to take a look for this ext or the other one? Thanks

Ricky Villa Valle18th Nov 2022

Hey John, can you reach out to me at rickyv@j2inn.com please? We would like to discuss this a little further offline if you don't mind.

John MacEnri24th Nov 2022

Just to close this out. What Matteo outlined at the top of the thread does work but needed a little bit more configuration than was not clear from the docs.

There is a bug when publishing (when point write is used) which means you must have the pahoMqttQos tag configured on the Connector record or you'll get the NPE Matteo showed.

Second issue is that the default payload structure when publishing was a poor choice on my part. It is actually a JSON structure with writeVal and writeLevel tags. In order to force the publishing to be a simple non JSON message with just the value, you must also configure the pahoMqttConstructor tag on the connector the value of which is a function name that will do the message construction. An example of which would be:

(pt, val) => do
  if (val != null) do
    if (val.isDict) return val->writeVal.toStr
    else return val.toStr
  end
  return  "NULL"
end

With this in place, Matteo was able to write to one point and have that value appear as the curVal on another point.


Log in or Sign up to post a reply.