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

Browserifying and subscriptions #17

Open
edge0701 opened this issue Mar 26, 2017 · 2 comments
Open

Browserifying and subscriptions #17

edge0701 opened this issue Mar 26, 2017 · 2 comments

Comments

@edge0701
Copy link

I am looking to develop on your excellent work - I am looking to update the version of MQTT.js.
But I am stuck at the first hurdle whilst trying to use browserify to create the bundle. I am missing something to do with the MQEmitter. I get the error:
Error: Cannot find module 'MQEmitter' from '/home/edge/src/polymer/mqtt-wrapper/mqtt-elements'

The workaround I have found so far is to run browserify -r ./node_modules/mqtt/lib/store.js:Store -r mqtt -r ./node_modules/mqemitter/mqemitter.js > dist/mqtt-elements-bundle.js and then change the string in the bundle from ./node_modules/mqemitter/mqemitter.js to MQEmitter.

I have updated mqtt.js to the latest version and all seems to be working...except subscriptions. That is the reason I wanted to try an updated mqtt version.

Publishing works fine, but subscriptions don't seem to work. I am testing with Mosquitto and AWS IoT. Both fail to subscribe. But I do not disconnect from the server. I see the binary frames sent in Chrome browser debugger. I am using your example code "injecting-mqtt-connection". I see no messages and {{item.subscribed}} remains false.

Any help would be appreciated for A) how to browserify correctly, and B) why subscriptions don't work for me.

@edge0701
Copy link
Author

edge0701 commented Mar 26, 2017

Another "Ah!" moment just after posting this. When I publish a message, a frame appears immediately in the browser debugger. So it seems I am receiving messages to the browser...but it never gets to...wait a second...

I get the message to "last-message" in but not to [[subscriptions.items[0].messages]].
[[subscriptions.items[0].topic]] is correct.
But [[subscriptions.items[0].subscribed]] always remains false...

Sorry for my rambling!!

Edit: (I am not actually accessing the subscriptions exactly as above syntax; it's more psuedo-code to describe that the correct values in the subscription array.)

Is this an issue with the Polymer version?? I found the data in subscriptions[0].__data__ but topic is the only key available on the top level of the subscription element...

@sandro-k
Copy link
Contributor

@edge0701 sorry for the delayed response. I will see if i can make an update to the current mqtt.js version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants