potential ping fix

Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
Andrey Platov 2021-10-27 11:30:32 +02:00
parent 3eab42c15b
commit de395b0a36
No known key found for this signature in database
GPG Key ID: C8787EFEB4B64AF0

View File

@ -36,6 +36,12 @@ class Connection implements Storage {
private lastId = 0
constructor (private readonly url: string, private readonly handler: TxHander) {
console.log('connection created')
setInterval(() => {
console.log('ping')
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.sendRequest('ping')
}, 10000)
}
private openConnection (): Promise<WebSocket> {
@ -56,14 +62,9 @@ class Connection implements Storage {
this.handler(resp.result as Tx)
}
}
const interval = setInterval(() => {
console.log('ping')
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.sendRequest('ping')
}, 10000)
websocket.onclose = () => {
console.log('client websocket closed')
clearInterval(interval)
// clearInterval(interval)
this.websocket = null
}
return new Promise((resolve, reject) => {