Skip to content
This repository has been archived by the owner on Feb 11, 2020. It is now read-only.
This repository has been archived by the owner on Feb 11, 2020. It is now read-only.

mqtt.js client does not detect that it was served from https #587

Closed
btsimonh opened this issue Jan 6, 2017 · 4 comments
Closed

mqtt.js client does not detect that it was served from https #587

btsimonh opened this issue Jan 6, 2017 · 4 comments

Comments

@btsimonh
Copy link
Contributor

btsimonh commented Jan 6, 2017

hi, just close this if it's already been asked....

Was just setting up mosca on HTTPS, and using the demo html with:
var client = mqtt.connect();
it tries to connect via ws: (as indicated by the chrome console, with denied because unsecure content).
with:
var client = mqtt.connect('wss://{ip:port}');
it works fine.

Maybe the mqtt client lib could detect if on an https page, and if so default to wss: rather than ws:?

not urgent, as easy workaround...

@mcollina
Copy link
Collaborator

mcollina commented Jan 7, 2017

It should be fixed in mqttjs/MQTT.js#518.

@btsimonh
Copy link
Contributor Author

btsimonh commented Jan 9, 2017

looking at the package.json of the installed mqtt.js, it seems mosca's dependency on ^1.6.3 results in a maximum version of mqtt of <2.0.0. mqtt.js is on 2.2.1, and we get 1.14.1 from npm. (my mosca is 2.2.0).
is this expected behavior?

the part of the (npm installed) package.json i'm looking at is:
"_requested": {
"raw": "mqtt@^1.6.3",
"scope": null,
"escapedName": "mqtt",
"name": "mqtt",
"rawSpec": "^1.6.3",
"spec": ">=1.6.3 <2.0.0",
"type": "range"
},

If i change the dependency in mosca's package.json to ^2.0.0, the npm update happily updates mqtt.js to 2.2.1

@btsimonh
Copy link
Contributor Author

btsimonh commented Jan 9, 2017

Note to anyone who does upgrade mqtt.js -
before it will be served by mosca, you must run:
npm run-script bundle
to get the served mqtt.js in the right place.
@mcollina - I still get the same error though.
Anything I'm missing?

@mcollina
Copy link
Collaborator

mcollina commented Jan 9, 2017

Maybe I didn't understand the problem. It's probably worth opening an issue up on MQTT.js. It should pick it up automatically.

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

No branches or pull requests

2 participants