Skip to content

Commit

Permalink
set a crypto socket reconnect timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
kajgm committed Nov 14, 2024
1 parent c5c5477 commit 3aeaa3f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions client/src/crypto/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,18 @@ export function coinbaseConnect() {

socket.onclose = (e) => {
console.log(e);
console.log('Socket closing, opening new socket');
const newSocket = coinbaseConnect();
tickerStore.setSocket(newSocket);
if (tickerStore.cryptoStatus === 'UPDATED') {
console.log('Socket closing, opening new socket');
const newSocket = coinbaseConnect();
tickerStore.setSocket(newSocket);
} else {
console.log('Waiting 10 seconds to open new socket');
setTimeout(() => {
console.log('Socket closing, opening new socket');
const newSocket = coinbaseConnect();
tickerStore.setSocket(newSocket);
}, 10000);
}
};

socket.onerror = (err) => {
Expand Down

0 comments on commit 3aeaa3f

Please sign in to comment.