-
Notifications
You must be signed in to change notification settings - Fork 208
Description
I am having a strange issue with websockets. I have my websocket server behind an apache httpd 2.4.51 proxy and the sockets keep disconnecting after 30 seconds or so. I am trying to investigate the issue but in the meantime I have installed reconnecting-websockets and it seems to work.
But now I have discovered that the chrome tab eventually runs out of memory and looking into the network tab on chrome reveals that lots of duplicate websockets are being created and they have status "101" whereas sometimes i get one that says status "finished"
I am using VueX to try to store a single instance of each reconnecting websocket, essentially like this
function urlProviderAutorespond() {
return `${process.env.VUE_APP_CT_WS_V1}/websockets/admin/autoreply?access_token=${Vue.prototype.$keycloak.token}`;
}
initialiseWsAutorespond({ state, commit }) {
if (!state.wsAutorespond) {
const ws = new ReconnectingWebSocket(urlProviderAutorespond);
ws.onmessage = (event) => {
commit('setAutorespond', JSON.parse(event.data));
};
ws.onopen = async () => {
if (state.firstAutorespond) {
// fetch some data
commit('setFirstAutorespond', false);
}
console.log("Autorespond websocket opening...");
};
commit('setWsAutorespond', ws);
}
}The issue may be related to the way that the server is terminating the connection but reconnecting-websockets shouldn't create a new one while the old one is still open?
