v2.2.1: fix ws & rest authentication issues caused by time-sync mechanism
This commit is contained in:
@@ -288,9 +288,10 @@ export default abstract class BaseRestClient {
|
||||
}
|
||||
|
||||
const end = Date.now();
|
||||
const severTimeMs = serverTime * 1000;
|
||||
|
||||
const avgDrift = (end - start) / 2;
|
||||
return Math.ceil(serverTime - end + avgDrift);
|
||||
return Math.ceil(severTimeMs - end + avgDrift);
|
||||
} catch (e) {
|
||||
console.error('Failed to fetch get time offset: ', e);
|
||||
return 0;
|
||||
|
||||
@@ -6,7 +6,11 @@ import { LinearClient } from './linear-client';
|
||||
import { DefaultLogger } from './logger';
|
||||
import { KlineInterval } from './types/shared';
|
||||
import { signMessage } from './util/node-support';
|
||||
import { serializeParams, isWsPong } from './util/requestUtils';
|
||||
import {
|
||||
serializeParams,
|
||||
isWsPong,
|
||||
RestClientOptions,
|
||||
} from './util/requestUtils';
|
||||
|
||||
import WsStore from './util/WsStore';
|
||||
|
||||
@@ -141,7 +145,7 @@ export interface WSClientConfigurableOptions {
|
||||
pongTimeout?: number;
|
||||
pingInterval?: number;
|
||||
reconnectTimeout?: number;
|
||||
restOptions?: any;
|
||||
restOptions?: RestClientOptions;
|
||||
requestOptions?: any;
|
||||
wsUrl?: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user