mqtt 4.0.0 → 4.2.1

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 (59) hide show
  1. package/README.md +58 -24
  2. package/bin/mqtt.js +27 -0
  3. package/bin/pub.js +0 -0
  4. package/bin/sub.js +0 -0
  5. package/dist/mqtt.js +2794 -2512
  6. package/dist/mqtt.min.js +1 -1
  7. package/lib/client.js +72 -59
  8. package/lib/connect/index.js +7 -2
  9. package/lib/connect/tcp.js +2 -0
  10. package/lib/connect/tls.js +3 -0
  11. package/lib/connect/ws.js +194 -34
  12. package/lib/connect/wx.js +3 -3
  13. package/lib/store.js +2 -2
  14. package/mqtt.js +0 -24
  15. package/package.json +9 -10
  16. package/types/lib/client-options.d.ts +14 -1
  17. package/types/lib/client.d.ts +4 -3
  18. package/examples/client/secure-client.js +0 -24
  19. package/examples/client/simple-both.js +0 -13
  20. package/examples/client/simple-publish.js +0 -7
  21. package/examples/client/simple-subscribe.js +0 -9
  22. package/examples/tls client/crt.ca.cg.pem +0 -34
  23. package/examples/tls client/mqttclient.js +0 -48
  24. package/examples/tls client/tls-cert.pem +0 -13
  25. package/examples/tls client/tls-key.pem +0 -15
  26. package/examples/wss/client.js +0 -49
  27. package/examples/wss/client_with_proxy.js +0 -58
  28. package/test/abstract_client.js +0 -3139
  29. package/test/abstract_store.js +0 -135
  30. package/test/browser/server.js +0 -132
  31. package/test/browser/test.js +0 -92
  32. package/test/client.js +0 -540
  33. package/test/client_mqtt5.js +0 -537
  34. package/test/helpers/port_list.js +0 -45
  35. package/test/helpers/private-csr.pem +0 -16
  36. package/test/helpers/private-key.pem +0 -27
  37. package/test/helpers/public-cert.pem +0 -19
  38. package/test/helpers/public-key.pem +0 -9
  39. package/test/helpers/server.js +0 -53
  40. package/test/helpers/server_process.js +0 -9
  41. package/test/helpers/tls-cert.pem +0 -14
  42. package/test/helpers/tls-csr.pem +0 -11
  43. package/test/helpers/tls-key.pem +0 -15
  44. package/test/helpers/wrong-cert.pem +0 -13
  45. package/test/helpers/wrong-csr.pem +0 -11
  46. package/test/helpers/wrong-key.pem +0 -15
  47. package/test/mocha.opts +0 -4
  48. package/test/mqtt.js +0 -230
  49. package/test/mqtt_store.js +0 -9
  50. package/test/secure_client.js +0 -188
  51. package/test/server.js +0 -94
  52. package/test/server_helpers_for_client_tests.js +0 -100
  53. package/test/store.js +0 -10
  54. package/test/typescript/broker-connect-subscribe-and-publish.js +0 -24
  55. package/test/typescript/broker-connect-subscribe-and-publish.js.map +0 -1
  56. package/test/typescript/broker-connect-subscribe-and-publish.ts +0 -25
  57. package/test/typescript/tsconfig.json +0 -14
  58. package/test/util.js +0 -13
  59. package/test/websocket_client.js +0 -146
@@ -1,49 +0,0 @@
1
- 'use strict'
2
-
3
- var mqtt = require('mqtt')
4
-
5
- var clientId = 'mqttjs_' + Math.random().toString(16).substr(2, 8)
6
-
7
- var host = 'wss://localhost:3001/Mosca'
8
-
9
- var options = {
10
- keepalive: 10,
11
- clientId: clientId,
12
- protocolId: 'MQTT',
13
- protocolVersion: 4,
14
- clean: true,
15
- reconnectPeriod: 1000,
16
- connectTimeout: 30 * 1000,
17
- will: {
18
- topic: 'WillMsg',
19
- payload: 'Connection Closed abnormally..!',
20
- qos: 0,
21
- retain: false
22
- },
23
- username: 'demo',
24
- password: 'demo',
25
- rejectUnauthorized: false
26
- }
27
-
28
- var client = mqtt.connect(host, options)
29
-
30
- client.on('error', function (err) {
31
- console.log(err)
32
- client.end()
33
- })
34
-
35
- client.on('connect', function () {
36
- console.log('client connected:' + clientId)
37
- })
38
-
39
- client.subscribe('topic', { qos: 0 })
40
-
41
- client.publish('topic', 'wss secure connection demo...!', { qos: 0, retain: false })
42
-
43
- client.on('message', function (topic, message, packet) {
44
- console.log('Received Message:= ' + message.toString() + '\nOn topic:= ' + topic)
45
- })
46
-
47
- client.on('close', function () {
48
- console.log(clientId + ' disconnected')
49
- })
@@ -1,58 +0,0 @@
1
- 'use strict'
2
-
3
- var mqtt = require('mqtt')
4
- var HttpsProxyAgent = require('https-proxy-agent')
5
- var url = require('url')
6
- /*
7
- host: host of the endpoint you want to connect e.g. my.mqqt.host.com
8
- path: path to you endpoint e.g. '/foo/bar/mqtt'
9
- */
10
- var endpoint = 'wss://<host><path>'
11
- /* create proxy agent
12
- proxy: your proxy e.g. proxy.foo.bar.com
13
- port: http proxy port e.g. 8080
14
- */
15
- var proxy = process.env.http_proxy || 'http://<proxy>:<port>'
16
- var parsed = url.parse(endpoint)
17
- var proxyOpts = url.parse(proxy)
18
- // true for wss
19
- proxyOpts.secureEndpoint = parsed.protocol ? parsed.protocol === 'wss:' : true
20
- var agent = new HttpsProxyAgent(proxyOpts)
21
- var wsOptions = {
22
- agent: agent
23
- // other wsOptions
24
- // foo:'bar'
25
- }
26
- var mqttOptions = {
27
- keepalive: 60,
28
- reschedulePings: true,
29
- protocolId: 'MQTT',
30
- protocolVersion: 4,
31
- reconnectPeriod: 1000,
32
- connectTimeout: 30 * 1000,
33
- clean: true,
34
- clientId: 'testClient',
35
- wsOptions: wsOptions
36
- }
37
-
38
- var client = mqtt.connect(parsed, mqttOptions)
39
-
40
- client.on('connect', function () {
41
- console.log('connected')
42
- })
43
-
44
- client.on('error', function (a) {
45
- console.log('error!' + a)
46
- })
47
-
48
- client.on('offline', function (a) {
49
- console.log('lost connection!' + a)
50
- })
51
-
52
- client.on('close', function (a) {
53
- console.log('connection closed!' + a)
54
- })
55
-
56
- client.on('message', function (topic, message) {
57
- console.log(message.toString())
58
- })