mqtt 2.18.9 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/CONTRIBUTING.md +27 -27
  2. package/LICENSE.md +15 -15
  3. package/README.md +689 -612
  4. package/bin/pub.js +146 -146
  5. package/bin/sub.js +123 -123
  6. package/dist/mqtt.js +11916 -14116
  7. package/dist/mqtt.min.js +1 -1
  8. package/doc/help.txt +8 -8
  9. package/doc/publish.txt +26 -26
  10. package/doc/subscribe.txt +26 -26
  11. package/examples/client/secure-client.js +24 -24
  12. package/examples/client/simple-both.js +13 -13
  13. package/examples/client/simple-publish.js +7 -7
  14. package/examples/client/simple-subscribe.js +9 -9
  15. package/examples/tls client/crt.ca.cg.pem +34 -34
  16. package/examples/tls client/mqttclient.js +48 -48
  17. package/examples/tls client/tls-cert.pem +13 -13
  18. package/examples/tls client/tls-key.pem +15 -15
  19. package/examples/wss/client.js +49 -49
  20. package/examples/wss/client_with_proxy.js +58 -58
  21. package/lib/client.js +1460 -1129
  22. package/lib/connect/ali.js +130 -0
  23. package/lib/connect/index.js +157 -149
  24. package/lib/connect/tcp.js +19 -19
  25. package/lib/connect/tls.js +41 -41
  26. package/lib/connect/ws.js +92 -92
  27. package/lib/connect/wx.js +134 -110
  28. package/lib/store.js +140 -140
  29. package/lib/validations.js +52 -52
  30. package/mqtt.js +41 -41
  31. package/package.json +112 -107
  32. package/test/abstract_client.js +3084 -2667
  33. package/test/abstract_store.js +135 -135
  34. package/test/browser/server.js +132 -132
  35. package/test/browser/test.js +92 -92
  36. package/test/client.js +1129 -544
  37. package/test/helpers/private-csr.pem +16 -16
  38. package/test/helpers/private-key.pem +27 -27
  39. package/test/helpers/public-cert.pem +19 -19
  40. package/test/helpers/public-key.pem +9 -9
  41. package/test/helpers/server.js +52 -52
  42. package/test/helpers/server_process.js +9 -9
  43. package/test/helpers/tls-cert.pem +14 -14
  44. package/test/helpers/tls-csr.pem +11 -11
  45. package/test/helpers/tls-key.pem +15 -15
  46. package/test/helpers/wrong-cert.pem +13 -13
  47. package/test/helpers/wrong-csr.pem +11 -11
  48. package/test/helpers/wrong-key.pem +15 -15
  49. package/test/mocha.opts +4 -4
  50. package/test/mqtt.js +230 -230
  51. package/test/mqtt_store.js +9 -9
  52. package/test/secure_client.js +157 -157
  53. package/test/server.js +93 -65
  54. package/test/store.js +10 -10
  55. package/test/typescript/broker-connect-subscribe-and-publish.js +24 -0
  56. package/test/typescript/broker-connect-subscribe-and-publish.js.map +1 -0
  57. package/test/typescript/broker-connect-subscribe-and-publish.ts +22 -22
  58. package/test/typescript/tsconfig.json +14 -14
  59. package/test/util.js +13 -13
  60. package/test/websocket_client.js +144 -144
  61. package/types/index.d.ts +27 -27
  62. package/types/lib/client-options.d.ts +178 -137
  63. package/types/lib/client.d.ts +231 -196
  64. package/types/lib/connect/index.d.ts +10 -10
  65. package/types/lib/store-options.d.ts +6 -6
  66. package/types/lib/store.d.ts +46 -46
  67. package/test/browser/wx.js +0 -93
@@ -1,196 +1,231 @@
1
- /// <reference types="node" />
2
-
3
- import * as events from 'events'
4
- import {
5
- IClientOptions,
6
- IClientPublishOptions,
7
- IClientSubscribeOptions,
8
- IClientReconnectOptions
9
- } from './client-options'
10
- import { Store } from './store'
11
- import { Packet, QoS } from 'mqtt-packet'
12
-
13
- export interface ISubscriptionGrant {
14
- /**
15
- * is a subscribed to topic
16
- */
17
- topic: string
18
- /**
19
- * is the granted qos level on it, may return 128 on error
20
- */
21
- qos: QoS | number
22
- }
23
- export interface ISubscriptionRequest {
24
- /**
25
- * is a subscribed to topic
26
- */
27
- topic: string
28
- /**
29
- * is the granted qos level on it
30
- */
31
- qos: QoS
32
- }
33
- export interface ISubscriptionMap {
34
- /**
35
- * object which has topic names as object keys and as value the QoS, like {'test1': 0, 'test2': 1}.
36
- */
37
- [topic: string]: QoS
38
- }
39
-
40
- export declare type ClientSubscribeCallback = (err: Error, granted: ISubscriptionGrant[]) => void
41
- export declare type OnMessageCallback = (topic: string, payload: Buffer, packet: Packet) => void
42
- export declare type OnPacketCallback = (packet: Packet) => void
43
- export declare type OnErrorCallback = (error: Error) => void
44
- export declare type PacketCallback = (error?: Error, packet?: Packet) => any
45
- export declare type CloseCallback = () => void
46
-
47
- export interface IStream extends events.EventEmitter {
48
- pipe (to: any): any
49
- destroy (): any
50
- end (): any
51
- }
52
- /**
53
- * MqttClient constructor
54
- *
55
- * @param {Stream} stream - stream
56
- * @param {Object} [options] - connection options
57
- * (see Connection#connect)
58
- */
59
- export declare class MqttClient extends events.EventEmitter {
60
- public connected: boolean
61
- public disconnecting: boolean
62
- public disconnected: boolean
63
- public reconnecting: boolean
64
- public incomingStore: Store
65
- public outgoingStore: Store
66
- public options: IClientOptions
67
- public queueQoSZero: boolean
68
-
69
- constructor (streamBuilder: (client: MqttClient) => IStream, options: IClientOptions)
70
-
71
- public on (event: 'message', cb: OnMessageCallback): this
72
- public on (event: 'packetsend' | 'packetreceive', cb: OnPacketCallback): this
73
- public on (event: 'error', cb: OnErrorCallback): this
74
- public on (event: string, cb: Function): this
75
-
76
- public once (event: 'message', cb: OnMessageCallback): this
77
- public once (event:
78
- 'packetsend'
79
- | 'packetreceive', cb: OnPacketCallback): this
80
- public once (event: 'error', cb: OnErrorCallback): this
81
- public once (event: string, cb: Function): this
82
-
83
- /**
84
- * publish - publish <message> to <topic>
85
- *
86
- * @param {String} topic - topic to publish to
87
- * @param {(String|Buffer)} message - message to publish
88
- *
89
- * @param {Object} [opts] - publish options, includes:
90
- * @param {Number} [opts.qos] - qos level to publish on
91
- * @param {Boolean} [opts.retain] - whether or not to retain the message
92
- *
93
- * @param {Function} [callback] - function(err){}
94
- * called when publish succeeds or fails
95
- * @returns {Client} this - for chaining
96
- * @api public
97
- *
98
- * @example client.publish('topic', 'message')
99
- * @example
100
- * client.publish('topic', 'message', {qos: 1, retain: true})
101
- * @example client.publish('topic', 'message', console.log)
102
- */
103
- public publish (topic: string, message: string | Buffer,
104
- opts: IClientPublishOptions, callback?: PacketCallback): this
105
- public publish (topic: string, message: string | Buffer,
106
- callback?: PacketCallback): this
107
-
108
- /**
109
- * subscribe - subscribe to <topic>
110
- *
111
- * @param {String, Array, Object} topic - topic(s) to subscribe to, supports objects in the form {'topic': qos}
112
- * @param {Object} [opts] - optional subscription options, includes:
113
- * @param {Number} [opts.qos] - subscribe qos level
114
- * @param {Function} [callback] - function(err, granted){} where:
115
- * {Error} err - subscription error (none at the moment!)
116
- * {Array} granted - array of {topic: 't', qos: 0}
117
- * @returns {MqttClient} this - for chaining
118
- * @api public
119
- * @example client.subscribe('topic')
120
- * @example client.subscribe('topic', {qos: 1})
121
- * @example client.subscribe({'topic': 0, 'topic2': 1}, console.log)
122
- * @example client.subscribe('topic', console.log)
123
- */
124
- public subscribe (topic:
125
- string
126
- | string[], opts: IClientSubscribeOptions, callback?: ClientSubscribeCallback): this
127
- public subscribe (topic:
128
- string
129
- | string[]
130
- | ISubscriptionMap, callback?: ClientSubscribeCallback): this
131
-
132
- /**
133
- * unsubscribe - unsubscribe from topic(s)
134
- *
135
- * @param {String, Array} topic - topics to unsubscribe from
136
- * @param {Function} [callback] - callback fired on unsuback
137
- * @returns {MqttClient} this - for chaining
138
- * @api public
139
- * @example client.unsubscribe('topic')
140
- * @example client.unsubscribe('topic', console.log)
141
- */
142
- public unsubscribe (topic: string | string[], callback?: PacketCallback): this
143
-
144
- /**
145
- * end - close connection
146
- *
147
- * @returns {MqttClient} this - for chaining
148
- * @param {Boolean} force - do not wait for all in-flight messages to be acked
149
- * @param {Function} cb - called when the client has been closed
150
- *
151
- * @api public
152
- */
153
- public end (force?: boolean, cb?: CloseCallback): this
154
-
155
- /**
156
- * removeOutgoingMessage - remove a message in outgoing store
157
- * the outgoing callback will be called withe Error('Message removed') if the message is removed
158
- *
159
- * @param {Number} mid - messageId to remove message
160
- * @returns {MqttClient} this - for chaining
161
- * @api public
162
- *
163
- * @example client.removeOutgoingMessage(client.getLastMessageId());
164
- */
165
- public removeOutgoingMessage (mid: number): this
166
-
167
- /**
168
- * reconnect - connect again using the same options as connect()
169
- *
170
- * @param {Object} [opts] - optional reconnect options, includes:
171
- * {Store} incomingStore - a store for the incoming packets
172
- * {Store} outgoingStore - a store for the outgoing packets
173
- * if opts is not given, current stores are used
174
- *
175
- * @returns {MqttClient} this - for chaining
176
- *
177
- * @api public
178
- */
179
- public reconnect (opts?: IClientReconnectOptions): this
180
-
181
- /**
182
- * Handle messages with backpressure support, one at a time.
183
- * Override at will.
184
- *
185
- * @param packet packet the packet
186
- * @param callback callback call when finished
187
- * @api public
188
- */
189
- public handleMessage (packet: Packet, callback: PacketCallback): void
190
-
191
- /**
192
- * getLastMessageId
193
- */
194
- public getLastMessageId (): number
195
- }
196
- export { IClientOptions }
1
+ /// <reference types="node" />
2
+
3
+ import * as events from 'events'
4
+ import {
5
+ IClientOptions,
6
+ IClientPublishOptions,
7
+ IClientSubscribeOptions,
8
+ IClientReconnectOptions
9
+ } from './client-options'
10
+ import { Store } from './store'
11
+ import { Packet, QoS } from 'mqtt-packet'
12
+
13
+ export interface ISubscriptionGrant {
14
+ /**
15
+ * is a subscribed to topic
16
+ */
17
+ topic: string
18
+ /**
19
+ * is the granted qos level on it, may return 128 on error
20
+ */
21
+ qos: QoS | number
22
+ /*
23
+ * no local flag
24
+ * */
25
+ nl?: boolean,
26
+ /*
27
+ * Retain As Published flag
28
+ * */
29
+ rap?: boolean,
30
+ /*
31
+ * Retain Handling option
32
+ * */
33
+ rh?: number
34
+ }
35
+ export interface ISubscriptionRequest {
36
+ /**
37
+ * is a subscribed to topic
38
+ */
39
+ topic: string
40
+ /**
41
+ * is the granted qos level on it
42
+ */
43
+ qos: QoS
44
+ /*
45
+ * no local flag
46
+ * */
47
+ nl?: boolean,
48
+ /*
49
+ * Retain As Published flag
50
+ * */
51
+ rap?: boolean,
52
+ /*
53
+ * Retain Handling option
54
+ * */
55
+ rh?: number
56
+ }
57
+ export interface ISubscriptionMap {
58
+ /**
59
+ * object which has topic names as object keys and as value the options, like {'test1': {qos: 0}, 'test2': {qos: 2}}.
60
+ */
61
+ [topic: string]: {
62
+ qos: QoS,
63
+ nl?: boolean,
64
+ rap?: boolean,
65
+ rh?: number
66
+ }
67
+ }
68
+
69
+ export declare type ClientSubscribeCallback = (err: Error, granted: ISubscriptionGrant[]) => void
70
+ export declare type OnMessageCallback = (topic: string, payload: Buffer, packet: Packet) => void
71
+ export declare type OnPacketCallback = (packet: Packet) => void
72
+ export declare type OnErrorCallback = (error: Error) => void
73
+ export declare type PacketCallback = (error?: Error, packet?: Packet) => any
74
+ export declare type CloseCallback = () => void
75
+
76
+ export interface IStream extends events.EventEmitter {
77
+ pipe (to: any): any
78
+ destroy (): any
79
+ end (): any
80
+ }
81
+ /**
82
+ * MqttClient constructor
83
+ *
84
+ * @param {Stream} stream - stream
85
+ * @param {Object} [options] - connection options
86
+ * (see Connection#connect)
87
+ */
88
+ export declare class MqttClient extends events.EventEmitter {
89
+ public connected: boolean
90
+ public disconnecting: boolean
91
+ public disconnected: boolean
92
+ public reconnecting: boolean
93
+ public incomingStore: Store
94
+ public outgoingStore: Store
95
+ public options: IClientOptions
96
+ public queueQoSZero: boolean
97
+
98
+ constructor (streamBuilder: (client: MqttClient) => IStream, options: IClientOptions)
99
+
100
+ public on (event: 'message', cb: OnMessageCallback): this
101
+ public on (event: 'packetsend' | 'packetreceive', cb: OnPacketCallback): this
102
+ public on (event: 'error', cb: OnErrorCallback): this
103
+ public on (event: string, cb: Function): this
104
+
105
+ public once (event: 'message', cb: OnMessageCallback): this
106
+ public once (event:
107
+ 'packetsend'
108
+ | 'packetreceive', cb: OnPacketCallback): this
109
+ public once (event: 'error', cb: OnErrorCallback): this
110
+ public once (event: string, cb: Function): this
111
+
112
+ /**
113
+ * publish - publish <message> to <topic>
114
+ *
115
+ * @param {String} topic - topic to publish to
116
+ * @param {(String|Buffer)} message - message to publish
117
+ *
118
+ * @param {Object} [opts] - publish options, includes:
119
+ * @param {Number} [opts.qos] - qos level to publish on
120
+ * @param {Boolean} [opts.retain] - whether or not to retain the message
121
+ * @param {Function}[opts.cbStorePut] - function(){}
122
+ * called when message is put into `outgoingStore`
123
+ *
124
+ * @param {Function} [callback] - function(err){}
125
+ * called when publish succeeds or fails
126
+ *
127
+ * @returns {Client} this - for chaining
128
+ * @api public
129
+ *
130
+ * @example client.publish('topic', 'message')
131
+ * @example
132
+ * client.publish('topic', 'message', {qos: 1, retain: true})
133
+ * @example client.publish('topic', 'message', console.log)
134
+ */
135
+ public publish (topic: string, message: string | Buffer,
136
+ opts: IClientPublishOptions, callback?: PacketCallback): this
137
+ public publish (topic: string, message: string | Buffer,
138
+ callback?: PacketCallback): this
139
+
140
+ /**
141
+ * subscribe - subscribe to <topic>
142
+ *
143
+ * @param {String, Array, Object} topic - topic(s) to subscribe to, supports objects in the form {'topic': qos}
144
+ * @param {Object} [opts] - optional subscription options, includes:
145
+ * @param {Number} [opts.qos] - subscribe qos level
146
+ * @param {Function} [callback] - function(err, granted){} where:
147
+ * {Error} err - subscription error (none at the moment!)
148
+ * {Array} granted - array of {topic: 't', qos: 0}
149
+ * @returns {MqttClient} this - for chaining
150
+ * @api public
151
+ * @example client.subscribe('topic')
152
+ * @example client.subscribe('topic', {qos: 1})
153
+ * @example client.subscribe({'topic': 0, 'topic2': 1}, console.log)
154
+ * @example client.subscribe('topic', console.log)
155
+ */
156
+ public subscribe (topic:
157
+ string
158
+ | string[], opts: IClientSubscribeOptions, callback?: ClientSubscribeCallback): this
159
+ public subscribe (topic:
160
+ string
161
+ | string[]
162
+ | ISubscriptionMap, callback?: ClientSubscribeCallback): this
163
+
164
+ /**
165
+ * unsubscribe - unsubscribe from topic(s)
166
+ *
167
+ * @param {String, Array} topic - topics to unsubscribe from
168
+ * @param {Object} opts - opts of unsubscribe
169
+ * @param {Function} [callback] - callback fired on unsuback
170
+ * @returns {MqttClient} this - for chaining
171
+ * @api public
172
+ * @example client.unsubscribe('topic')
173
+ * @example client.unsubscribe('topic', console.log)
174
+ * @example client.unsubscribe('topic', opts, console.log)
175
+ */
176
+ public unsubscribe (topic: string | string[], opts?: Object, callback?: PacketCallback): this
177
+
178
+ /**
179
+ * end - close connection
180
+ *
181
+ * @returns {MqttClient} this - for chaining
182
+ * @param {Boolean} force - do not wait for all in-flight messages to be acked
183
+ * @param {Object} opts - opts disconnect
184
+ * @param {Function} cb - called when the client has been closed
185
+ *
186
+ * @api public
187
+ */
188
+ public end (force?: boolean, opts?: Object, cb?: CloseCallback): this
189
+
190
+ /**
191
+ * removeOutgoingMessage - remove a message in outgoing store
192
+ * the outgoing callback will be called withe Error('Message removed') if the message is removed
193
+ *
194
+ * @param {Number} mid - messageId to remove message
195
+ * @returns {MqttClient} this - for chaining
196
+ * @api public
197
+ *
198
+ * @example client.removeOutgoingMessage(client.getLastMessageId());
199
+ */
200
+ public removeOutgoingMessage (mid: number): this
201
+
202
+ /**
203
+ * reconnect - connect again using the same options as connect()
204
+ *
205
+ * @param {Object} [opts] - optional reconnect options, includes:
206
+ * {Store} incomingStore - a store for the incoming packets
207
+ * {Store} outgoingStore - a store for the outgoing packets
208
+ * if opts is not given, current stores are used
209
+ *
210
+ * @returns {MqttClient} this - for chaining
211
+ *
212
+ * @api public
213
+ */
214
+ public reconnect (opts?: IClientReconnectOptions): this
215
+
216
+ /**
217
+ * Handle messages with backpressure support, one at a time.
218
+ * Override at will.
219
+ *
220
+ * @param packet packet the packet
221
+ * @param callback callback call when finished
222
+ * @api public
223
+ */
224
+ public handleMessage (packet: Packet, callback: PacketCallback): void
225
+
226
+ /**
227
+ * getLastMessageId
228
+ */
229
+ public getLastMessageId (): number
230
+ }
231
+ export { IClientOptions }
@@ -1,10 +1,10 @@
1
- import { IClientOptions, MqttClient } from '../client'
2
- /**
3
- * connect - connect to an MQTT broker.
4
- *
5
- * @param {String} [brokerUrl] - url of the broker, optional
6
- * @param {Object} opts - see MqttClient#constructor
7
- */
8
- declare function connect (brokerUrl?: string | any, opts?: IClientOptions): MqttClient
9
- export { connect }
10
- export { MqttClient }
1
+ import { IClientOptions, MqttClient } from '../client'
2
+ /**
3
+ * connect - connect to an MQTT broker.
4
+ *
5
+ * @param {String} [brokerUrl] - url of the broker, optional
6
+ * @param {Object} opts - see MqttClient#constructor
7
+ */
8
+ declare function connect (brokerUrl?: string | any, opts?: IClientOptions): MqttClient
9
+ export { connect }
10
+ export { MqttClient }
@@ -1,6 +1,6 @@
1
- export interface IStoreOptions {
2
- /**
3
- * true, clear _inflights at close
4
- */
5
- clean?: boolean
6
- }
1
+ export interface IStoreOptions {
2
+ /**
3
+ * true, clear _inflights at close
4
+ */
5
+ clean?: boolean
6
+ }
@@ -1,46 +1,46 @@
1
- import {
2
- IStoreOptions
3
- } from './store-options'
4
-
5
- /**
6
- * In-memory implementation of the message store
7
- * This can actually be saved into files.
8
- *
9
- */
10
- declare class Store {
11
- /**
12
- * Store constructor
13
- *
14
- * @param {Object} [options] - store options
15
- */
16
- constructor (options: IStoreOptions)
17
-
18
- /**
19
- * Adds a packet to the store, a packet is
20
- * anything that has a messageId property.
21
- *
22
- */
23
- public put (packet: any, cb?: Function): this
24
-
25
- /**
26
- * Creates a stream with all the packets in the store
27
- *
28
- */
29
- public createStream (): any
30
-
31
- /**
32
- * deletes a packet from the store.
33
- */
34
- public del (packet: any, cb: Function): this
35
-
36
- /**
37
- * get a packet from the store.
38
- */
39
- public get (packet: any, cb: Function): this
40
-
41
- /**
42
- * Close the store
43
- */
44
- public close (cb: Function): void
45
- }
46
- export { Store }
1
+ import {
2
+ IStoreOptions
3
+ } from './store-options'
4
+
5
+ /**
6
+ * In-memory implementation of the message store
7
+ * This can actually be saved into files.
8
+ *
9
+ */
10
+ declare class Store {
11
+ /**
12
+ * Store constructor
13
+ *
14
+ * @param {Object} [options] - store options
15
+ */
16
+ constructor (options: IStoreOptions)
17
+
18
+ /**
19
+ * Adds a packet to the store, a packet is
20
+ * anything that has a messageId property.
21
+ *
22
+ */
23
+ public put (packet: any, cb?: Function): this
24
+
25
+ /**
26
+ * Creates a stream with all the packets in the store
27
+ *
28
+ */
29
+ public createStream (): any
30
+
31
+ /**
32
+ * deletes a packet from the store.
33
+ */
34
+ public del (packet: any, cb: Function): this
35
+
36
+ /**
37
+ * get a packet from the store.
38
+ */
39
+ public get (packet: any, cb: Function): this
40
+
41
+ /**
42
+ * Close the store
43
+ */
44
+ public close (cb: Function): void
45
+ }
46
+ export { Store }
@@ -1,93 +0,0 @@
1
- 'use strict'
2
-
3
- var mqtt = require('../../lib/connect')
4
- var _URL = require('url')
5
- var xtend = require('xtend')
6
- var parsed = _URL.parse(document.URL)
7
- var isHttps = parsed.protocol === 'https:'
8
- var port = parsed.port || (isHttps ? 443 : 80)
9
- var host = parsed.hostname
10
- var protocol = isHttps ? 'wxs' : 'wx'
11
- require('../helpers/wx')
12
-
13
- function clientTests (buildClient) {
14
- var client
15
-
16
- beforeEach(function () {
17
- client = buildClient()
18
- client.on('offline', function () {
19
- console.log('client offline')
20
- })
21
- client.on('connect', function () {
22
- console.log('client connect')
23
- })
24
- client.on('reconnect', function () {
25
- console.log('client reconnect')
26
- })
27
- })
28
-
29
- afterEach(function (done) {
30
- client.once('close', function () {
31
- done()
32
- })
33
- client.end()
34
- })
35
-
36
- it('should connect', function (done) {
37
- client.on('connect', function () {
38
- done()
39
- })
40
- })
41
-
42
- it('should publish and subscribe', function (done) {
43
- client.subscribe('hello', function () {
44
- done()
45
- }).publish('hello', 'world')
46
- })
47
- }
48
-
49
- function suiteFactory (configName, opts) {
50
- function setVersion (base) {
51
- return xtend(base || {}, opts)
52
- }
53
-
54
- var suiteName = 'MqttClient(' + configName + '=' + JSON.stringify(opts) + ')'
55
- describe(suiteName, function () {
56
- this.timeout(10000)
57
-
58
- describe('specifying nothing', function () {
59
- clientTests(function () {
60
- return mqtt.connect(setVersion())
61
- })
62
- })
63
-
64
- if (parsed.hostname === 'localhost') {
65
- describe('specifying a port', function () {
66
- clientTests(function () {
67
- return mqtt.connect(setVersion({ protocol: protocol, port: port }))
68
- })
69
- })
70
- }
71
-
72
- describe('specifying a port and host', function () {
73
- clientTests(function () {
74
- return mqtt.connect(setVersion({ protocol: protocol, port: port, host: host }))
75
- })
76
- })
77
-
78
- describe('specifying a URL', function () {
79
- clientTests(function () {
80
- return mqtt.connect(protocol + '://' + host + ':' + port, setVersion())
81
- })
82
- })
83
-
84
- describe('specifying a URL with a path', function () {
85
- clientTests(function () {
86
- return mqtt.connect(protocol + '://' + host + ':' + port + '/mqtt', setVersion())
87
- })
88
- })
89
- })
90
- }
91
-
92
- suiteFactory('v3', {protocolId: 'MQIsdp', protocolVersion: 3})
93
- suiteFactory('default', {})