Updated stream ws to close if backend api error

• Updated:
- stream ws to close if backend api error and not retry over and over again
This commit is contained in:
mgabdev 2021-02-10 23:08:00 -05:00
parent a42b7797d8
commit 72162affcf

View File

@ -76,6 +76,10 @@ export default function getStream(streamingAPIBaseURL, accessToken, stream, { co
const ws = new WebSocketClient(`${streamingAPIBaseURL}/api/v1/streaming/?${params.join('&')}`, accessToken); const ws = new WebSocketClient(`${streamingAPIBaseURL}/api/v1/streaming/?${params.join('&')}`, accessToken);
ws.onopen = connected; ws.onopen = connected;
ws.onerror = (e) => {
// If errors, dont retry
ws.close();
};
ws.onmessage = e => received(JSON.parse(e.data)); ws.onmessage = e => received(JSON.parse(e.data));
ws.onclose = disconnected; ws.onclose = disconnected;
ws.onreconnect = reconnected; ws.onreconnect = reconnected;