Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When creating a mqtt-connection with an auto mqtt-publish the message should be send when the connection is established #13

Closed
sandro-k opened this issue Oct 15, 2015 · 2 comments

Comments

@sandro-k
Copy link
Contributor

<mqtt-connection
    url="ws://iot.eclipse.org:80/ws"
    auto>
  <mqtt-publish topic="foo/bar" payload="this is easy" auto></mqtt-publish>
</mqtt-connection>

Minimal working example dose not automatically publish to "foo/bar" when the the connection is established. Probably _propertiesChanged is not run when this._parentConnection is set via its parent.

@mcollina
Copy link
Member

You can just call client.publish() even before a 'connect' event in MQTT.js, the publish will be queued up and sent as the connection is established (for the first time).

@sandro-k
Copy link
Contributor Author

I know.. but the mqtt-publish element will not have any knowledge about which client it belongs too until set by the parent mqtt-connection . Even the mqtt-connection might get the client injected via its mqtt-connection#client property and then will delegate it down to the mqtt-publish element. Anyway just wanted to document this and create a fix and test for it.

sandro-k added a commit that referenced this issue Oct 16, 2015
* exposing MqttElement with scope to stub prototype methods of MqttConnection, MqttPublish and MqttSubscription
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants