dolphindb 3.0.30 → 3.0.31

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/browser.js CHANGED
@@ -5,7 +5,7 @@ import ipaddrjs from 'ipaddr.js';
5
5
  const { fromByteArray: buf2ipaddr } = ipaddrjs;
6
6
  import 'xshell/prototype.browser.js';
7
7
  import { blue, cyan, green, grey, magenta } from 'xshell/chalk.browser.js';
8
- import { concat, assert, Lock, genid, seq, zip_object, decode } from 'xshell/utils.browser.js';
8
+ import { concat, assert, Lock, genid, seq, zip_object, decode, delay } from 'xshell/utils.browser.js';
9
9
  import { connect_websocket } from 'xshell/net.browser.js';
10
10
  import { t } from './i18n/index.js';
11
11
  export const nulls = {
@@ -2650,6 +2650,23 @@ export class DDB {
2650
2650
  await this.rpc('connect', { skip_connection_check: true });
2651
2651
  if (this.streaming)
2652
2652
  await this.subscribe();
2653
+ else
2654
+ // 定时执行一次空脚本作为心跳检查,避免因为 nat 超时导致 tcp 连接断开
2655
+ (async () => {
2656
+ while (true) {
2657
+ await delay(1000 * 60 * 4.5);
2658
+ if (this.connected)
2659
+ try {
2660
+ await this.eval('');
2661
+ }
2662
+ catch (error) {
2663
+ console.log(t('{{time}} 心跳检测失败,连接已断开', { time: new Date().to_formal_str() }), error);
2664
+ break;
2665
+ }
2666
+ else
2667
+ break;
2668
+ }
2669
+ })();
2653
2670
  resolve();
2654
2671
  }
2655
2672
  catch (error) {