mcollina / mows

Using MQTT.js in the browser over WebSocket -- Built with browserify!
72 stars 12 forks source link

An option is not available with an url. #13

Closed ledsun closed 9 years ago

ledsun commented 10 years ago

I want set an option with an url like blow:

var mows = require('mows'),
  client = mows.createClient(
    'ws://example.com:8080/mqtt', {
      username: 'test-user',
      password: 'p@ssword'
    })  

But the option is set empty force.

mcollina commented 10 years ago

Can you please explain better?

ledsun commented 10 years ago

The option is ignore.

I guess the option is overwritten by port at : https://github.com/mcollina/mows/blob/master/params.js#L17

ledsun commented 10 years ago

I want connect to Sango mqtt server. https://sango.shiguredo.jp/

Sango require a host, a port, a path like ws://free.mqtt.shiguredo.jp:8080/mqtt and authentication. I set parameters of createClient an url and an option object include an authentication information like:

var mows = require('mows'),
  client = mows.createClient(
    'ws://free.mqtt.shiguredo.jp:8080/mqtt', {
      username: 'ledsun@github',
      password: 'XXX'
    })

But an error occurs.

Uncaught Error: Connection refused: Not authorized 

The options parameter of MqttClient constructor is an empty object asObject {} when debug print.

var MqttClient = module.exports =
function MqttClient(streamBuilder, options) {
  var that = this;

  console.log(options)
mcollina commented 10 years ago

Would you like to submit a pull request for this?

Thanks!