Skip to content

Commit

Permalink
Merge pull request #962 from colinl/946_socket_error_recovery_2
Browse files Browse the repository at this point in the history
Force page reload on socket connect error 'parser error'
  • Loading branch information
cstns authored Jun 12, 2024
2 parents b496129 + 2845d93 commit a57d4b0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ui/src/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a57d4b0

Please sign in to comment.