@hyperwatch/hyperwatch 4.2.0 → 4.3.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.
@@ -0,0 +1,228 @@
1
+ [
2
+ "104.210.139.192/28",
3
+ "104.210.139.224/28",
4
+ "13.65.138.112/28",
5
+ "13.65.138.96/28",
6
+ "13.67.46.240/28",
7
+ "13.67.72.16/28",
8
+ "13.70.107.160/28",
9
+ "13.71.2.208/28",
10
+ "13.76.115.224/28",
11
+ "13.76.115.240/28",
12
+ "13.76.116.80/28",
13
+ "13.76.223.48/28",
14
+ "13.76.32.208/28",
15
+ "13.79.43.0/28",
16
+ "13.83.167.128/28",
17
+ "13.83.237.176/28",
18
+ "132.196.82.48/28",
19
+ "135.119.134.128/28",
20
+ "135.119.134.192/28",
21
+ "135.220.73.208/28",
22
+ "135.220.73.240/28",
23
+ "135.237.131.208/28",
24
+ "135.237.133.112/28",
25
+ "135.237.133.48/28",
26
+ "137.135.183.96/28",
27
+ "137.135.190.240/28",
28
+ "137.135.191.176/28",
29
+ "137.135.191.32/28",
30
+ "138.91.30.48/28",
31
+ "138.91.46.96/28",
32
+ "168.63.252.240/28",
33
+ "172.178.140.144/28",
34
+ "172.178.141.112/28",
35
+ "172.178.141.128/28",
36
+ "172.183.143.224/28",
37
+ "172.183.222.128/28",
38
+ "172.204.16.64/28",
39
+ "172.212.159.64/28",
40
+ "172.213.11.144/28",
41
+ "172.213.12.112/28",
42
+ "172.213.21.112/28",
43
+ "172.213.21.144/28",
44
+ "172.213.21.16/28",
45
+ "191.233.1.112/28",
46
+ "191.233.1.128/28",
47
+ "191.233.1.224/28",
48
+ "191.233.194.32/28",
49
+ "191.233.196.112/28",
50
+ "191.233.199.160/28",
51
+ "191.233.2.0/28",
52
+ "191.234.167.128/28",
53
+ "191.235.66.16/28",
54
+ "191.235.98.144/28",
55
+ "191.235.99.80/28",
56
+ "191.237.249.64/28",
57
+ "191.239.245.16/28",
58
+ "20.0.53.96/28",
59
+ "20.102.212.144/28",
60
+ "20.117.22.224/28",
61
+ "20.125.112.224/28",
62
+ "20.125.144.144/28",
63
+ "20.161.75.208/28",
64
+ "20.168.7.192/28",
65
+ "20.168.7.240/28",
66
+ "20.169.72.112/28",
67
+ "20.169.72.96/28",
68
+ "20.169.73.176/28",
69
+ "20.169.73.32/28",
70
+ "20.169.73.64/28",
71
+ "20.169.78.112/28",
72
+ "20.169.78.128/28",
73
+ "20.169.78.144/28",
74
+ "20.169.78.160/28",
75
+ "20.169.78.176/28",
76
+ "20.169.78.192/28",
77
+ "20.169.78.48/28",
78
+ "20.169.78.64/28",
79
+ "20.169.78.80/28",
80
+ "20.169.78.96/28",
81
+ "20.172.29.32/28",
82
+ "20.193.233.240/28",
83
+ "20.193.50.32/28",
84
+ "20.194.0.208/28",
85
+ "20.194.1.0/28",
86
+ "20.194.157.176/28",
87
+ "20.198.67.96/28",
88
+ "20.203.245.32/28",
89
+ "20.204.24.240/28",
90
+ "20.210.154.128/28",
91
+ "20.210.174.208/28",
92
+ "20.210.211.192/28",
93
+ "20.215.187.208/28",
94
+ "20.215.188.192/28",
95
+ "20.215.214.16/28",
96
+ "20.215.219.128/28",
97
+ "20.215.219.160/28",
98
+ "20.215.219.208/28",
99
+ "20.215.220.112/28",
100
+ "20.215.220.128/28",
101
+ "20.215.220.144/28",
102
+ "20.215.220.160/28",
103
+ "20.215.220.176/28",
104
+ "20.215.220.192/28",
105
+ "20.215.220.208/28",
106
+ "20.215.220.64/28",
107
+ "20.215.220.80/28",
108
+ "20.215.220.96/28",
109
+ "20.227.140.32/28",
110
+ "20.228.106.176/28",
111
+ "20.235.75.208/28",
112
+ "20.235.87.224/28",
113
+ "20.249.63.208/28",
114
+ "20.27.94.128/28",
115
+ "20.45.178.144/28",
116
+ "20.55.229.144/28",
117
+ "20.63.221.64/28",
118
+ "20.90.7.144/28",
119
+ "20.97.189.96/28",
120
+ "23.102.140.144/28",
121
+ "23.102.141.32/28",
122
+ "23.97.109.224/28",
123
+ "23.98.142.176/28",
124
+ "23.98.179.16/28",
125
+ "23.98.186.176/28",
126
+ "23.98.186.192/28",
127
+ "23.98.186.64/28",
128
+ "23.98.186.96/28",
129
+ "4.151.119.48/28",
130
+ "4.151.241.240/28",
131
+ "4.151.71.176/28",
132
+ "4.189.118.208/28",
133
+ "4.189.119.48/28",
134
+ "4.196.118.112/28",
135
+ "4.196.198.80/28",
136
+ "4.197.115.112/28",
137
+ "4.197.19.176/28",
138
+ "4.197.22.112/28",
139
+ "4.197.64.0/28",
140
+ "4.197.64.16/28",
141
+ "4.197.64.48/28",
142
+ "4.197.64.64/28",
143
+ "4.205.128.176/28",
144
+ "40.116.73.208/28",
145
+ "40.67.183.160/28",
146
+ "40.67.183.176/28",
147
+ "40.75.14.224/28",
148
+ "40.81.134.128/28",
149
+ "40.81.134.144/28",
150
+ "40.81.234.144/28",
151
+ "40.84.181.32/28",
152
+ "40.84.221.208/28",
153
+ "40.84.221.224/28",
154
+ "51.107.70.192/28",
155
+ "51.8.155.112/28",
156
+ "51.8.155.48/28",
157
+ "51.8.155.64/28",
158
+ "51.8.155.80/28",
159
+ "52.148.129.32/28",
160
+ "52.154.22.48/28",
161
+ "52.156.77.144/28",
162
+ "52.159.227.32/28",
163
+ "52.159.249.96/28",
164
+ "52.165.212.16/28",
165
+ "52.165.212.32/28",
166
+ "52.165.212.48/28",
167
+ "52.172.129.160/28",
168
+ "52.172.251.112/28",
169
+ "52.173.123.0/28",
170
+ "52.173.219.112/28",
171
+ "52.173.219.96/28",
172
+ "52.173.221.16/28",
173
+ "52.173.221.176/28",
174
+ "52.173.221.208/28",
175
+ "52.173.234.16/28",
176
+ "52.173.234.80/28",
177
+ "52.173.235.80/28",
178
+ "52.176.139.176/28",
179
+ "52.187.246.128/28",
180
+ "52.190.137.144/28",
181
+ "52.190.137.16/28",
182
+ "52.190.139.48/28",
183
+ "52.190.142.64/28",
184
+ "52.190.190.16/28",
185
+ "52.225.75.208/28",
186
+ "52.230.163.32/28",
187
+ "52.230.164.176/28",
188
+ "52.231.30.48/28",
189
+ "52.231.34.176/28",
190
+ "52.231.39.144/28",
191
+ "52.231.39.192/28",
192
+ "52.231.49.48/28",
193
+ "52.231.50.64/28",
194
+ "52.236.94.144/28",
195
+ "52.242.132.224/28",
196
+ "52.242.132.240/28",
197
+ "52.242.245.208/28",
198
+ "52.252.113.240/28",
199
+ "52.255.109.112/28",
200
+ "52.255.109.128/28",
201
+ "52.255.109.144/28",
202
+ "52.255.109.80/28",
203
+ "52.255.109.96/28",
204
+ "52.255.111.0/28",
205
+ "52.255.111.112/28",
206
+ "52.255.111.16/28",
207
+ "52.255.111.32/28",
208
+ "52.255.111.48/28",
209
+ "52.255.111.80/28",
210
+ "57.154.174.112/28",
211
+ "57.154.175.0/28",
212
+ "57.154.187.32/28",
213
+ "68.154.28.96/28",
214
+ "68.218.30.112/28",
215
+ "68.220.57.64/28",
216
+ "68.221.67.160/28",
217
+ "68.221.67.192/28",
218
+ "68.221.67.224/28",
219
+ "68.221.67.240/28",
220
+ "68.221.75.16/28",
221
+ "74.226.253.160/28",
222
+ "74.249.86.176/28",
223
+ "74.7.35.112/28",
224
+ "74.7.35.48/28",
225
+ "74.7.36.64/28",
226
+ "74.7.36.80/28",
227
+ "74.7.36.96/28"
228
+ ]
@@ -0,0 +1,24 @@
1
+ [
2
+ "173.245.48.0/20",
3
+ "103.21.244.0/22",
4
+ "103.22.200.0/22",
5
+ "103.31.4.0/22",
6
+ "141.101.64.0/18",
7
+ "108.162.192.0/18",
8
+ "190.93.240.0/20",
9
+ "188.114.96.0/20",
10
+ "197.234.240.0/22",
11
+ "198.41.128.0/17",
12
+ "162.158.0.0/15",
13
+ "104.16.0.0/13",
14
+ "104.24.0.0/14",
15
+ "172.64.0.0/13",
16
+ "131.0.72.0/22",
17
+ "2400:cb00::/32",
18
+ "2606:4700::/32",
19
+ "2803:f800::/32",
20
+ "2405:b500::/32",
21
+ "2405:8100::/32",
22
+ "2a06:98c0::/29",
23
+ "2c0f:f248::/32"
24
+ ]
@@ -0,0 +1,231 @@
1
+ [
2
+ "120.52.22.96/27",
3
+ "23.228.222.0/24",
4
+ "205.251.249.0/24",
5
+ "180.163.57.128/26",
6
+ "23.228.220.0/24",
7
+ "204.246.168.0/22",
8
+ "111.13.171.128/26",
9
+ "18.160.0.0/15",
10
+ "205.251.252.0/23",
11
+ "54.192.0.0/16",
12
+ "204.246.173.0/24",
13
+ "54.230.200.0/21",
14
+ "120.253.240.192/26",
15
+ "23.234.192.0/18",
16
+ "116.129.226.128/26",
17
+ "130.176.0.0/17",
18
+ "3.173.192.0/18",
19
+ "108.156.0.0/14",
20
+ "99.86.0.0/16",
21
+ "13.32.0.0/15",
22
+ "120.253.245.128/26",
23
+ "13.224.0.0/14",
24
+ "70.132.0.0/18",
25
+ "15.158.0.0/16",
26
+ "111.13.171.192/26",
27
+ "13.249.0.0/16",
28
+ "18.238.0.0/15",
29
+ "18.244.0.0/15",
30
+ "205.251.208.0/20",
31
+ "3.165.0.0/16",
32
+ "3.168.0.0/14",
33
+ "65.9.128.0/18",
34
+ "130.176.128.0/18",
35
+ "23.228.221.0/24",
36
+ "58.254.138.0/25",
37
+ "205.251.206.0/23",
38
+ "54.230.208.0/20",
39
+ "3.160.0.0/14",
40
+ "116.129.226.0/25",
41
+ "23.91.0.0/19",
42
+ "52.222.128.0/17",
43
+ "18.164.0.0/15",
44
+ "111.13.185.32/27",
45
+ "64.252.128.0/18",
46
+ "205.251.254.0/24",
47
+ "3.166.0.0/15",
48
+ "54.230.224.0/19",
49
+ "71.152.0.0/17",
50
+ "216.137.32.0/19",
51
+ "204.246.172.0/24",
52
+ "205.251.202.0/23",
53
+ "18.172.0.0/15",
54
+ "120.52.39.128/27",
55
+ "118.193.97.64/26",
56
+ "3.164.64.0/18",
57
+ "18.154.0.0/15",
58
+ "3.173.0.0/17",
59
+ "54.240.128.0/18",
60
+ "205.251.250.0/23",
61
+ "180.163.57.0/25",
62
+ "52.46.0.0/18",
63
+ "3.174.0.0/15",
64
+ "52.82.128.0/19",
65
+ "54.230.0.0/17",
66
+ "54.230.128.0/18",
67
+ "54.239.128.0/18",
68
+ "130.176.224.0/20",
69
+ "36.103.232.128/26",
70
+ "52.84.0.0/15",
71
+ "143.204.0.0/16",
72
+ "144.220.0.0/16",
73
+ "120.52.153.192/26",
74
+ "119.147.182.0/25",
75
+ "120.232.236.0/25",
76
+ "111.13.185.64/27",
77
+ "3.164.0.0/18",
78
+ "3.172.64.0/18",
79
+ "54.182.0.0/16",
80
+ "58.254.138.128/26",
81
+ "120.253.245.192/27",
82
+ "54.239.192.0/19",
83
+ "18.68.0.0/16",
84
+ "18.64.0.0/14",
85
+ "120.52.12.64/26",
86
+ "24.110.32.0/19",
87
+ "99.84.0.0/16",
88
+ "205.251.204.0/23",
89
+ "130.176.192.0/19",
90
+ "23.228.223.0/24",
91
+ "52.124.128.0/17",
92
+ "204.246.164.0/22",
93
+ "13.35.0.0/16",
94
+ "204.246.174.0/23",
95
+ "3.164.128.0/17",
96
+ "3.172.0.0/18",
97
+ "36.103.232.0/25",
98
+ "119.147.182.128/26",
99
+ "118.193.97.128/25",
100
+ "120.232.236.128/26",
101
+ "204.246.176.0/20",
102
+ "65.8.0.0/16",
103
+ "65.9.0.0/17",
104
+ "108.138.0.0/15",
105
+ "120.253.241.160/27",
106
+ "3.173.128.0/18",
107
+ "64.252.64.0/18",
108
+ "13.113.196.64/26",
109
+ "13.113.203.0/24",
110
+ "52.199.127.192/26",
111
+ "57.182.253.0/24",
112
+ "57.183.42.0/25",
113
+ "13.124.199.0/24",
114
+ "3.35.130.128/25",
115
+ "52.78.247.128/26",
116
+ "13.203.133.0/26",
117
+ "13.233.177.192/26",
118
+ "15.207.13.128/25",
119
+ "15.207.213.128/25",
120
+ "52.66.194.128/26",
121
+ "13.228.69.0/24",
122
+ "47.129.82.0/24",
123
+ "47.129.83.0/24",
124
+ "47.129.84.0/24",
125
+ "52.220.191.0/26",
126
+ "13.210.67.128/26",
127
+ "13.54.63.128/26",
128
+ "3.107.43.128/25",
129
+ "3.107.44.0/25",
130
+ "3.107.44.128/25",
131
+ "43.218.56.128/26",
132
+ "43.218.56.192/26",
133
+ "43.218.56.64/26",
134
+ "43.218.71.0/26",
135
+ "99.79.169.0/24",
136
+ "18.192.142.0/23",
137
+ "18.199.68.0/22",
138
+ "18.199.72.0/22",
139
+ "18.199.76.0/22",
140
+ "35.158.136.0/24",
141
+ "52.57.254.0/24",
142
+ "18.200.212.0/23",
143
+ "52.212.248.0/26",
144
+ "13.134.24.0/23",
145
+ "13.134.94.0/23",
146
+ "18.175.65.0/24",
147
+ "18.175.66.0/24",
148
+ "18.175.67.0/24",
149
+ "3.10.17.128/25",
150
+ "3.11.53.0/24",
151
+ "52.56.127.0/25",
152
+ "15.188.184.0/24",
153
+ "51.44.234.0/23",
154
+ "51.44.236.0/23",
155
+ "51.44.238.0/23",
156
+ "52.47.139.0/24",
157
+ "3.29.40.128/26",
158
+ "3.29.40.192/26",
159
+ "3.29.40.64/26",
160
+ "3.29.57.0/26",
161
+ "18.229.220.192/26",
162
+ "18.230.229.0/24",
163
+ "18.230.230.0/25",
164
+ "54.233.255.128/26",
165
+ "56.125.46.0/24",
166
+ "56.125.47.0/32",
167
+ "56.125.48.0/24",
168
+ "3.231.2.0/25",
169
+ "3.234.232.224/27",
170
+ "3.236.169.192/26",
171
+ "3.236.48.0/23",
172
+ "34.195.252.0/24",
173
+ "34.226.14.0/24",
174
+ "44.220.194.0/23",
175
+ "44.220.196.0/23",
176
+ "44.220.198.0/23",
177
+ "44.220.200.0/23",
178
+ "44.220.202.0/23",
179
+ "44.222.66.0/24",
180
+ "13.59.250.0/26",
181
+ "18.216.170.128/25",
182
+ "3.128.93.0/24",
183
+ "3.134.215.0/24",
184
+ "3.146.232.0/22",
185
+ "3.147.164.0/22",
186
+ "3.147.244.0/22",
187
+ "52.15.127.128/26",
188
+ "3.101.158.0/23",
189
+ "52.52.191.128/26",
190
+ "34.216.51.0/25",
191
+ "34.223.12.224/27",
192
+ "34.223.80.192/26",
193
+ "35.162.63.192/26",
194
+ "35.167.191.128/26",
195
+ "35.93.168.0/23",
196
+ "35.93.170.0/23",
197
+ "35.93.172.0/23",
198
+ "44.227.178.0/24",
199
+ "44.234.108.128/25",
200
+ "44.234.90.252/30",
201
+ "2600:9000:3000::/36",
202
+ "2600:9000:f600::/39",
203
+ "2600:9000:f540::/42",
204
+ "2409:8c00:2421:300::/56",
205
+ "2600:9000:f000::/38",
206
+ "2600:9000:f500::/43",
207
+ "2600:9000:ddd::/48",
208
+ "2600:9000:f800::/37",
209
+ "2600:9000:f400::/40",
210
+ "2600:9000:f538::/45",
211
+ "2600:9000:5380::/41",
212
+ "2600:f0f0:5504::/46",
213
+ "2600:9000:1000::/36",
214
+ "2600:9000:2000::/36",
215
+ "2400:7fc0:500::/40",
216
+ "2600:9000:4000::/36",
217
+ "2600:9000:fff::/48",
218
+ "2409:8c00:2421:400::/56",
219
+ "2404:c2c0:500::/40",
220
+ "2600:9000:5308::/45",
221
+ "2600:9000:f534::/46",
222
+ "2600:f0f0:601::/48",
223
+ "2600:9000:f520::/44",
224
+ "2600:9000:5320::/43",
225
+ "2600:9000:5310::/44",
226
+ "2600:9000:f580::/41",
227
+ "2600:f0f0:602::/47",
228
+ "2600:9000:5340::/42",
229
+ "2600:9000:eee::/48",
230
+ "2600:9000:5200::/40"
231
+ ]
@@ -0,0 +1,23 @@
1
+ [
2
+ "132.196.86.0/24",
3
+ "172.182.202.0/25",
4
+ "172.182.204.0/24",
5
+ "172.182.207.0/25",
6
+ "172.182.214.0/24",
7
+ "172.182.215.0/24",
8
+ "20.125.66.80/28",
9
+ "20.171.206.0/24",
10
+ "20.171.207.0/24",
11
+ "4.227.36.0/25",
12
+ "52.230.152.0/24",
13
+ "74.7.175.128/25",
14
+ "74.7.227.0/25",
15
+ "74.7.227.128/25",
16
+ "74.7.228.0/25",
17
+ "74.7.230.0/25",
18
+ "74.7.241.0/25",
19
+ "74.7.241.128/25",
20
+ "74.7.242.0/25",
21
+ "74.7.243.128/25",
22
+ "74.7.244.0/25"
23
+ ]
@@ -0,0 +1,37 @@
1
+ [
2
+ "104.210.140.128/28",
3
+ "135.234.64.0/24",
4
+ "172.182.193.224/28",
5
+ "172.182.193.80/28",
6
+ "172.182.194.144/28",
7
+ "172.182.194.32/28",
8
+ "172.182.195.48/28",
9
+ "172.182.209.208/28",
10
+ "172.182.211.192/28",
11
+ "172.182.213.192/28",
12
+ "172.182.224.0/28",
13
+ "172.203.190.128/28",
14
+ "20.14.99.96/28",
15
+ "20.168.18.32/28",
16
+ "20.169.6.224/28",
17
+ "20.169.7.48/28",
18
+ "20.169.77.0/25",
19
+ "20.171.123.64/28",
20
+ "20.171.53.224/28",
21
+ "20.25.151.224/28",
22
+ "20.42.10.176/28",
23
+ "4.227.36.0/25",
24
+ "40.67.175.0/25",
25
+ "40.90.214.16/28",
26
+ "51.8.102.0/24",
27
+ "74.7.175.128/25",
28
+ "74.7.228.0/25",
29
+ "74.7.228.128/25",
30
+ "74.7.229.0/25",
31
+ "74.7.229.128/25",
32
+ "74.7.230.0/25",
33
+ "74.7.241.128/25",
34
+ "74.7.242.128/25",
35
+ "74.7.243.0/25",
36
+ "74.7.244.0/25"
37
+ ]
package/src/index.js CHANGED
@@ -1,3 +1,5 @@
1
+ const path = require('path');
2
+
1
3
  const { merge } = require('lodash');
2
4
 
3
5
  const app = require('./app');
@@ -8,10 +10,18 @@ const lib = require('./lib');
8
10
  const modules = require('./modules');
9
11
  const plugins = require('./plugins');
10
12
 
11
- const { cache, logger, pipeline, util } = lib;
13
+ const { cache, logger, persistence, pipeline, util } = lib;
12
14
 
13
15
  let initialized = false;
14
16
 
17
+ function getPersistenceDir() {
18
+ const base =
19
+ constants.persistence.path || path.join(process.cwd(), '.hyperwatch-data');
20
+ return constants.persistence.namespace
21
+ ? path.join(base, constants.persistence.namespace)
22
+ : base;
23
+ }
24
+
15
25
  function init(config = {}) {
16
26
  if (initialized) {
17
27
  console.warn(`Can't init, Hyperwatch was already initialized.`);
@@ -28,11 +38,22 @@ function start() {
28
38
  return;
29
39
  }
30
40
  modules.start();
41
+ if (constants.persistence.enabled) {
42
+ persistence.load(getPersistenceDir());
43
+ }
31
44
  return Promise.all([app.start(), pipeline.start()]);
32
45
  }
33
46
 
34
- function stop() {
35
- return Promise.all([app.stop(), pipeline.stop()]);
47
+ async function stop() {
48
+ await pipeline.stop();
49
+ try {
50
+ if (constants.persistence.enabled) {
51
+ persistence.dump(getPersistenceDir());
52
+ }
53
+ } catch (err) {
54
+ console.error('Error dumping aggregators:', err.message);
55
+ }
56
+ return app.stop();
36
57
  }
37
58
 
38
59
  module.exports = {
@@ -16,11 +16,15 @@ function create({
16
16
  parse = defaultParse,
17
17
  sample = 1,
18
18
  reconnectOnClose = false,
19
+ heartbeatInterval = 30000,
19
20
  }) {
20
21
  let client;
21
22
 
23
+ let reconnectAttempts = 0;
24
+
22
25
  const setupWebSocketClient = ({ status, success, reject }) => {
23
26
  let isAlive;
27
+ let keepAlive;
24
28
 
25
29
  if (username && password) {
26
30
  options.headers = options.headers || {};
@@ -34,7 +38,23 @@ function create({
34
38
 
35
39
  client.on('open', () => {
36
40
  isAlive = true;
41
+ reconnectAttempts = 0;
37
42
  status(null, `Listening to ${address}`);
43
+
44
+ // Heartbeat: detect stale connections
45
+ keepAlive = setInterval(() => {
46
+ if (isAlive === false) {
47
+ client.terminate();
48
+ clearInterval(keepAlive);
49
+ } else {
50
+ try {
51
+ client.ping();
52
+ } catch (err) {
53
+ status(err, 'Websocket error');
54
+ }
55
+ isAlive = false;
56
+ }
57
+ }, heartbeatInterval);
38
58
  });
39
59
 
40
60
  client.on('message', (message) => {
@@ -52,33 +72,29 @@ function create({
52
72
  status(err, 'Websocket error');
53
73
  });
54
74
 
55
- const keepAlive = setInterval(() => {
56
- if (isAlive === false) {
57
- client.terminate();
58
- clearInterval(keepAlive);
59
- } else {
60
- try {
61
- client.ping();
62
- } catch (err) {
63
- status(err, 'Websocket error');
64
- }
65
- isAlive = false;
66
- }
67
- }, 10 * 1000);
68
-
69
75
  client.on('pong', () => {
70
76
  isAlive = true;
71
77
  });
72
78
 
73
79
  client.on('close', () => {
74
80
  status(null, 'Websocket connection has been closed');
81
+ if (keepAlive) {
82
+ clearInterval(keepAlive);
83
+ }
75
84
  if (reconnectOnClose) {
85
+ reconnectAttempts++;
86
+ const delay = Math.min(
87
+ 10 * 1000 * Math.pow(2, reconnectAttempts - 1),
88
+ 5 * 60 * 1000
89
+ );
90
+ status(
91
+ null,
92
+ `Reconnecting Websocket in ${delay / 1000}s (attempt ${reconnectAttempts})`
93
+ );
76
94
  setTimeout(() => {
77
- status(null, 'Reconnecting Websocket');
78
95
  setupWebSocketClient({ status, success, reject });
79
- }, 10 * 1000);
96
+ }, delay);
80
97
  }
81
- clearInterval(keepAlive);
82
98
  });
83
99
  };
84
100