From 2ddff2ada391e988542d33cf00bc18c081c11a5b Mon Sep 17 00:00:00 2001 From: colinl Date: Sun, 9 Jun 2024 21:45:46 +0100 Subject: [PATCH 1/4] Force a page reload if the socket connect fails with 'parser error[' --- ui/src/main.mjs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ui/src/main.mjs b/ui/src/main.mjs index 8f28b59b1..58dd47be6 100644 --- a/ui/src/main.mjs +++ b/ui/src/main.mjs @@ -151,6 +151,14 @@ fetch('_setup') socket.on('connect_error', (err) => { console.error('SIO connect error:', err, `err: ${JSON.stringify(err)}`) + if (err?.code === "parser error") { + // There has been a 'parser error' during the attempt to connect. This means that socket.io + // does not like the response from the server from the attempt to connect. + // This happens if there is a proxy server in front of node red that has redirected to + // a login page. There may also be other situations under which this error occurs, but whatever the + // cause it doesn't seem that we can do much other than force a reload. + forcePageReload("parser error") + } }) // default interval - every 5 seconds From 71490f1403b6d04510f8690f4bcde76d250fab00 Mon Sep 17 00:00:00 2001 From: colinl Date: Sun, 9 Jun 2024 21:45:46 +0100 Subject: [PATCH 2/4] Force a page reload if the socket connect fails with 'parser error[' --- ui/src/main.mjs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ui/src/main.mjs b/ui/src/main.mjs index dd1484fca..6428e7704 100644 --- a/ui/src/main.mjs +++ b/ui/src/main.mjs @@ -151,6 +151,14 @@ fetch('_setup') socket.on('connect_error', (err) => { console.error('SIO connect error:', err, `err: ${JSON.stringify(err)}`) + if (err?.code === "parser error") { + // There has been a 'parser error' during the attempt to connect. This means that socket.io + // does not like the response from the server from the attempt to connect. + // This happens if there is a proxy server in front of node red that has redirected to + // a login page. There may also be other situations under which this error occurs, but whatever the + // cause it doesn't seem that we can do much other than force a reload. + forcePageReload("parser error") + } }) // default interval - every 2.5 seconds From f3531a340887f47761a344bac11000e0f769b6ef Mon Sep 17 00:00:00 2001 From: colinl Date: Sun, 9 Jun 2024 21:45:46 +0100 Subject: [PATCH 3/4] Force a page reload if the socket connect fails with 'parser error[' --- ui/src/main.mjs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ui/src/main.mjs b/ui/src/main.mjs index 019086949..16ac59090 100644 --- a/ui/src/main.mjs +++ b/ui/src/main.mjs @@ -151,6 +151,14 @@ fetch('_setup') socket.on('connect_error', (err) => { console.error('SIO connect error:', err, `err: ${JSON.stringify(err)}`) + if (err?.code === "parser error") { + // There has been a 'parser error' during the attempt to connect. This means that socket.io + // does not like the response from the server from the attempt to connect. + // This happens if there is a proxy server in front of node red that has redirected to + // a login page. There may also be other situations under which this error occurs, but whatever the + // cause it doesn't seem that we can do much other than force a reload. + forcePageReload("parser error") + } }) // default interval - every 2.5 seconds From 2845d93d3a3bb9a2ddea6c9e5d070e41380604ca Mon Sep 17 00:00:00 2001 From: colinl Date: Wed, 12 Jun 2024 10:27:09 +0100 Subject: [PATCH 4/4] Fix lint errors, double quotes instead of single. --- ui/src/main.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/src/main.mjs b/ui/src/main.mjs index 16ac59090..871787cda 100644 --- a/ui/src/main.mjs +++ b/ui/src/main.mjs @@ -151,13 +151,13 @@ fetch('_setup') socket.on('connect_error', (err) => { console.error('SIO connect error:', err, `err: ${JSON.stringify(err)}`) - if (err?.code === "parser error") { + if (err?.code === 'parser error') { // There has been a 'parser error' during the attempt to connect. This means that socket.io // does not like the response from the server from the attempt to connect. // This happens if there is a proxy server in front of node red that has redirected to // a login page. There may also be other situations under which this error occurs, but whatever the // cause it doesn't seem that we can do much other than force a reload. - forcePageReload("parser error") + forcePageReload('parser error') } })