@meta2d/core 1.0.91 → 1.0.92

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.
package/src/core.js CHANGED
@@ -2527,7 +2527,7 @@ export class Meta2d {
2527
2527
  // Object.assign(options,{clean: false});
2528
2528
  // }
2529
2529
  if (!options.hasOwnProperty("reconnectPeriod")) {
2530
- Object.assign(options, { reconnectPeriod: 0 });
2530
+ Object.assign(options, { reconnectPeriod: 5000 });
2531
2531
  }
2532
2532
  if (!options.hasOwnProperty("connectTimeout")) {
2533
2533
  Object.assign(options, { connectTimeout: 10 * 1000 });
@@ -2545,24 +2545,25 @@ export class Meta2d {
2545
2545
  this.mqttClients[net.index].on('error', (error) => {
2546
2546
  this.store.emitter.emit('error', { type: 'mqtt', error });
2547
2547
  });
2548
- let reconnectDelay = 1000;
2549
- this.mqttClients[net.index].on('close', () => {
2550
- if (this.store.options.reconnetTimes) {
2551
- net.times++;
2552
- if (net.times >= this.store.options.reconnetTimes) {
2553
- net.times = 0;
2554
- this.mqttClients && this.mqttClients[net.index]?.end();
2555
- }
2556
- setTimeout(() => {
2557
- if (net.times < this.store.options.reconnetTimes) {
2558
- this.mqttClients[net.index].reconnect(options);
2559
- reconnectDelay = Math.min(reconnectDelay * 2, 10 * 1000);
2560
- }
2561
- }, reconnectDelay);
2562
- }
2563
- });
2548
+ //mqtt 默认重连配置 reconnectPeriod
2549
+ // let reconnectDelay = 1000;
2550
+ // this.mqttClients[net.index].on('close', () => {
2551
+ // if (this.store.options.reconnetTimes) {
2552
+ // net.times++;
2553
+ // if (net.times >= this.store.options.reconnetTimes) {
2554
+ // net.times = 0;
2555
+ // this.mqttClients && this.mqttClients[net.index]?.end();
2556
+ // }
2557
+ // setTimeout(()=>{
2558
+ // if (net.times < this.store.options.reconnetTimes) {
2559
+ // this.mqttClients[net.index].reconnect(options as any);
2560
+ // reconnectDelay = Math.min(reconnectDelay * 2, 10 * 1000);
2561
+ // }
2562
+ // },reconnectDelay)
2563
+ // }
2564
+ // });
2564
2565
  this.mqttClients[net.index].on('connect', (connack) => {
2565
- reconnectDelay = 1000;
2566
+ // reconnectDelay = 1000;
2566
2567
  if (!connack.sessionPresent) {
2567
2568
  // 创建了新会话或没有找到旧会话,需要重新订阅主题
2568
2569
  if (net.topics) {