Skip to content

Commit c4df534

Browse files
committed
Handle reconnect events for websocket errors
1 parent 910a2d7 commit c4df534

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

app/Services/Nodes/NodeJWTService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function handle(Node $node, string $identifiedBy)
5555

5656
$builder = (new Builder)->issuedBy(config('app.url'))
5757
->permittedFor($node->getConnectionAddress())
58-
->identifiedBy(hash('sha256', $identifiedBy), true)
58+
->identifiedBy(md5($identifiedBy), true)
5959
->issuedAt(CarbonImmutable::now()->getTimestamp())
6060
->canOnlyBeUsedAfter(CarbonImmutable::now()->subMinutes(5)->getTimestamp());
6161

resources/scripts/components/server/WebsocketHandler.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ import { CSSTransition } from 'react-transition-group';
77
import Spinner from '@/components/elements/Spinner';
88
import tw from 'twin.macro';
99

10+
const reconnectErrors = [
11+
'jwt: exp claim is invalid',
12+
'jwt: created too far in past (denylist)',
13+
];
14+
1015
export default () => {
1116
let updatingToken = false;
1217
const [ error, setError ] = useState<'connecting' | string>('');
@@ -64,7 +69,7 @@ export default () => {
6469
setConnectionState(false);
6570
console.warn('JWT validation error from wings:', error);
6671

67-
if (error === 'jwt: exp claim is invalid') {
72+
if (reconnectErrors.find(v => error.toLowerCase().indexOf(v) >= 0)) {
6873
updateToken(uuid, socket);
6974
} else {
7075
setError('There was an error validating the credentials provided for the websocket. Please refresh the page.');
@@ -95,7 +100,7 @@ export default () => {
95100
</p>
96101
</>
97102
:
98-
<p css={tw`ml-2 text-sm text-red-100`}>
103+
<p css={tw`ml-2 text-sm text-white`}>
99104
{error}
100105
</p>
101106
}

0 commit comments

Comments
 (0)