Periodically ping websocket to prevent it from being closed
This commit is contained in:
parent
b92ffc7bad
commit
5844deac1a
|
@ -39,6 +39,14 @@ export function ConnectionProvider({ children }) {
|
|||
return () => connection.removeAccountChangeListener(id);
|
||||
}, [connection]);
|
||||
|
||||
useEffect(() => {
|
||||
const id = setInterval(
|
||||
() => connection._rpcWebSocket.call('ping').catch(() => {}),
|
||||
2000,
|
||||
);
|
||||
return () => clearInterval(id);
|
||||
}, [connection]);
|
||||
|
||||
return (
|
||||
<ConnectionContext.Provider
|
||||
value={{ endpoint, setEndpoint, connection, sendConnection }}
|
||||
|
|
Loading…
Reference in New Issue