HotFix WebSocket error 1006 (#2063)
* Delete cookie posthog Signed-off-by: Gregoire Parant <g.parant@thecodingmachine.com>
This commit is contained in:
parent
ad229460ef
commit
a287d5e272
@ -295,7 +295,32 @@ class ConnectionManager {
|
||||
});
|
||||
|
||||
connection.connectionErrorStream.subscribe((event: CloseEvent) => {
|
||||
console.log("connectionErrorStream => An error occurred while connecting to socket server. Retrying");
|
||||
console.info(
|
||||
"An error occurred while connecting to socket server. Retrying => Event: ",
|
||||
event.reason,
|
||||
event.code,
|
||||
event
|
||||
);
|
||||
|
||||
//However, Chrome will rarely report any close code 1006 reasons to the Javascript side.
|
||||
//This is likely due to client security rules in the WebSocket spec to prevent abusing WebSocket.
|
||||
//(such as using it to scan for open ports on a destination server, or for generating lots of connections for a denial-of-service attack).
|
||||
// more detail here: https://www.rfc-editor.org/rfc/rfc6455#section-7.4.1
|
||||
if (event.code === 1006) {
|
||||
//check cookies
|
||||
const cookies = document.cookie.split(";");
|
||||
for (const cookie of cookies) {
|
||||
//check id cookie posthog exist
|
||||
const numberIndexPh = cookie.indexOf("_posthog=");
|
||||
if (numberIndexPh !== -1) {
|
||||
//if exist, remove posthog cookie
|
||||
document.cookie =
|
||||
cookie.slice(0, numberIndexPh + 9) +
|
||||
"; domain=.workadventu.re; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
reject(
|
||||
new Error(
|
||||
"An error occurred while connecting to socket server. Retrying. Code: " +
|
||||
|
Loading…
Reference in New Issue
Block a user