From 0700f3a9e9cb0c14ad2e31c598b98323c8e17006 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Powaga?= Date: Tue, 21 May 2019 16:30:18 +0100 Subject: [PATCH] fix(State Channels): Remove automatic pinging to fix browser compatibility (#432) --- es/channel/internal.js | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/es/channel/internal.js b/es/channel/internal.js index fbef924908..6ae711428c 100644 --- a/es/channel/internal.js +++ b/es/channel/internal.js @@ -21,9 +21,6 @@ import * as R from 'ramda' import { pascalToSnake } from '../utils/string' import { awaitingConnection } from './handlers' -const PING_TIMEOUT_MS = 10000 -const PONG_TIMEOUT_MS = 5000 - const options = new WeakMap() const status = new WeakMap() const state = new WeakMap() @@ -37,8 +34,6 @@ const actionQueueLocked = new WeakMap() const sequence = new WeakMap() const channelId = new WeakMap() const rpcCallbacks = new WeakMap() -const pingTimeoutId = new WeakMap() -const pongTimeoutId = new WeakMap() function channelURL (url, params) { const paramString = R.join('&', R.values(R.mapObjIndexed((value, key) => @@ -159,21 +154,10 @@ function call (channel, method, params) { }) } -function ping (channel) { - const ws = websockets.get(channel) - if (ws.readyState === ws.OPEN) { - ws._connection.ping() - clearTimeout(pongTimeoutId.get(channel)) - pongTimeoutId.set(channel, setTimeout(() => ws._connection.drop(), PONG_TIMEOUT_MS)) - } -} - function disconnect (channel) { const ws = websockets.get(channel) if (ws.readyState === ws.OPEN) { ws._connection.close() - clearTimeout(pongTimeoutId.get(channel)) - clearTimeout(pingTimeoutId.get(channel)) } } @@ -213,12 +197,6 @@ async function initialize (channel, channelOptions) { onclose: () => changeStatus(channel, 'disconnected'), onmessage: ({ data }) => onMessage(channel, data) }) - ws._connection.on('pong', () => { - clearTimeout(pongTimeoutId.get(channel)) - clearTimeout(pingTimeoutId.get(channel)) - pingTimeoutId.set(channel, setTimeout(() => ping(channel), PING_TIMEOUT_MS)) - }) - pingTimeoutId.set(channel, setTimeout(() => ping(channel), PING_TIMEOUT_MS)) websockets.set(channel, ws) }