SignalK / signalk-server

An implementation of a Signal K central server for boats.
http://signalk.org
Apache License 2.0
322 stars 156 forks source link

JWT TokenExpiredError #1513

Open tvr256 opened 1 year ago

tvr256 commented 1 year ago

My SignalK system appears to be functioning normally, but once a minute the following error appears in the SignalK log file.

It looks like a signalk-derived-data JWT token expired on 17 January 2023. Any idea how to fix it?

Jan 30 12:06:04 [object Object]

Jan 30 12:06:08 TokenExpiredError: jwt expired at

/usr/lib/node_modules/signalk-server/node_modules/jsonwebtoken/verify.js:152:21 at

getSecret (/usr/lib/node_modules/signalk-server/node_modules/jsonwebtoken/verify.js:90:14) at

Object.module.exports [as verify] (/usr/lib/node_modules/signalk-server/node_modules/jsonwebtoken/verify.js:94:10) at

Object.strategy.authorizeWS (/usr/lib/node_modules/signalk-server/lib/tokensecurity.js:576:27) at

Object.strategy.verifyWS (/usr/lib/node_modules/signalk-server/lib/tokensecurity.js:535:22) at

FullSignalK.<anonymous> (/usr/lib/node_modules/signalk-server/lib/interfaces/ws.js:491:30) at

FullSignalK.emit (node:events:525:35) at

FullSignalK.addDelta (/usr/lib/node_modules/signalk-server/node_modules/@signalk/signalk-schema/dist/fullsignalk.js:52:8) at

DeltaChain.doProcess (/usr/lib/node_modules/signalk-server/lib/deltachain.js:14:18) at

DeltaChain.process (/usr/lib/node_modules/signalk-server/lib/deltachain.js:10:21) at

Function.Server.app.handleMessage (/usr/lib/node_modules/signalk-server/lib/index.js:180:32) at

Object.handleMessage (/usr/lib/node_modules/signalk-server/lib/interfaces/plugins.js:185:17) at

/home/pi/.signalk/node_modules/signalk-derived-data/index.js:156:21 at

/home/pi/.signalk/node_modules/signalk-derived-data/node_modules/baconjs/dist/Bacon.js:1048:16 at

/home/pi/.signalk/node_modules/signalk-derived-data/node_modules/baconjs/dist/Bacon.js:463:23 at

processAfters (/home/pi/.signalk/node_modules/signalk-derived-data/node_modules/baconjs/dist/Bacon.js:359:11) at

Object.inTransaction (/home/pi/.signalk/node_modules/signalk-derived-data/node_modules/baconjs/dist/Bacon.js:439:9) at

Dispatcher.push (/home/pi/.signalk/node_modules/signalk-derived-data/node_modules/baconjs/dist/Bacon.js:1214:24) at

Dispatcher.handleEvent (/home/pi/.signalk/node_modules/signalk-derived-data/node_modules/baconjs/dist/Bacon.js:1267:17) at

/home/pi/.signalk/node_modules/signalk-derived-data/node_modules/baconjs/dist/Bacon.js:242:17 at

flushWhileTriggers (/home/pi/.signalk/node_modules/signalk-derived-data/node_modules/baconjs/dist/Bacon.js:1502:25) at

flush (/home/pi/.signalk/node_modules/signalk-derived-data/node_modules/baconjs/dist/Bacon.js:1531:23)

{ expiredAt: 2023-01-17T12:38:03.000Z }
tkurki commented 1 year ago

There's something weird going on here. It looks like a WebSocket connection is connected but with a JWT token that is expired. So when we attemmpt to write a value coming from the derived data plugin to the ws connection the jwt expiration check kicks in and logs the error with stack trace, but the ws connection is not terminated.

I transferred the issue to the server repository, because this is not really an issue in the plugin.

Have you just tried to restart the server? The error should go away, when the ws should be no longer able to reconnect.

tvr256 commented 1 year ago

I've restarted the server multiple times, but the error appears once a minute from server startup.

According to the main SignalK dashboard I have 4 WebSocket Clients, is there any way to identify them or force them to disconnect?

tkurki commented 9 months ago

Is this still relevant?