bropat/eufy-security-client

[Bug]: Unexpected token p in JSON

kusmierz opened this issue · 1 comments

Client version

2.9.1

Node version

18

Operating System type

Docker

Operating system version

node:18-alpine

Describe the bug

I'm having a problem with my Eufy Security running with the eufy-security-ws Docker image. Sometimes it works fine for a few days. But then suddenly it starts having problems several times a day. It seems like it's happening more often now.

The main problem is that something is going wrong and I don't know what it is because there is no clear error message (but the logs are attached below). What's more, when this happens, the node process starts using 100% CPU. As a result, my HomeAssistant can't talk to my Eufy Security. Restarting the container is the only solution that helps at the moment.

My camera is 2K Indoor Cam Pan&Tilt (T8410 with 2.1.9.7 firmware) if that helps.

To reproduce

Just run and wait, because eventually it will happen. In other words: I can't reproduce it, but I have a system that fails from time to time.

Screenshots & Logfiles

2024-02-03 21:09:37.915  DEBUG [parseJSON] JSON parse error
{
  error: {
    cause: undefined,
    message: 'SyntaxError: Unexpected token p in JSON at position 21490',
    context: undefined,
    stacktrace: 'SyntaxError: Unexpected token p in JSON at position 21490\n' +
      '    at JSON.parse (<anonymous>)\n' +
      '    at parseJSON (/usr/src/app/node_modules/eufy-security-client/build/utils.js:156:21)\n' +
      '    at P2PClientProtocol.handleDataControl (/usr/src/app/node_modules/eufy-security-client/build/p2p/session.js:1483:72)\n' +
      '    at P2PClientProtocol.handleData (/usr/src/app/node_modules/eufy-security-client/build/p2p/session.js:1133:18)\n' +
      '    at P2PClientProtocol.parseDataMessage (/usr/src/app/node_modules/eufy-security-client/build/p2p/session.js:1121:26)\n' +
      '    at P2PClientProtocol.handleMsg (/usr/src/app/node_modules/eufy-security-client/build/p2p/session.js:963:30)\n' +
      '    at Socket.<anonymous> (/usr/src/app/node_modules/eufy-security-client/build/p2p/session.js:113:56)\n' +
      '    at Socket.emit (node:events:517:28)\n' +
      '    at Socket.emit (node:domain:489:12)\n' +
      '    at UDP.onMessage [as onmessage] (node:dgram:942:8)'
  },
  data: '(...)'... 11974 more characters
}
2024-02-03 21:09:37.915  DEBUG [Station.onCameraInfo] Station got camera info
{
  station: 'T8410XXXXXXX',
  cameraInfo: undefined
}
2024-02-03 21:09:37.916  ERROR [P2PClientProtocol.handleDataControl] Handle DATA CONTROL - Camera info - Error
{
  error: {
    cause: undefined,
    message: "TypeError: Cannot read properties of undefined (reading 'params')",
    context: undefined,
    stacktrace: "TypeError: Cannot read properties of undefined (reading 'params')\n" +
      '    at Station.onCameraInfo (/usr/src/app/node_modules/eufy-security-client/build/http/station.js:801:20)\n' +
      '    at P2PClientProtocol.<anonymous> (/usr/src/app/node_modules/eufy-security-client/build/http/station.js:49:64)\n' +
      '    at P2PClientProtocol.emit (node:events:517:28)\n' +
      '    at P2PClientProtocol.emit (node:domain:489:12)\n' +
      '    at P2PClientProtocol.handleDataControl (/usr/src/app/node_modules/eufy-security-client/build/p2p/session.js:1483:30)\n' +
      '    at P2PClientProtocol.handleData (/usr/src/app/node_modules/eufy-security-client/build/p2p/session.js:1133:18)\n' +
      '    at P2PClientProtocol.parseDataMessage (/usr/src/app/node_modules/eufy-security-client/build/p2p/session.js:1121:26)\n' +
      '    at P2PClientProtocol.handleMsg (/usr/src/app/node_modules/eufy-security-client/build/p2p/session.js:963:30)\n' +
      '    at Socket.<anonymous> (/usr/src/app/node_modules/eufy-security-client/build/p2p/session.js:113:56)\n' +
      '    at Socket.emit (node:events:517:28)'
  },
  stationSN: 'T8410XXXXXXX',
  message: {
    seqNo: 24,
    channel: 0,
    commandType: 'CMD_CAMERA_INFO',
    signCode: 1,
    type: 0,
    dataType: 'CONTROL',
    data: '(..)'... 33968 more characters
  }
}
2024-02-03 21:09:37.917  DEBUG [P2PClientProtocol.handleMsg] Received message - DATA CONTROL - Processing sequence 24...
{
  stationSN: 'T8410XXXXXXX',
  remoteAddress: 'xxx.xxx.242.xxx',
  remotePort: 14906,
  dataType: 'CONTROL',
  seqNo: 24
}
2024-02-03 21:09:37.917  DEBUG [P2PClientProtocol.handleMsg] Received message - DATA CONTROL - Received already processed sequence
{
  stationSN: 'T8410XXXXXXX',
  remoteAddress: 'xxx.xxx.242.xxx',
  remotePort: 14906,
  dataType: 'CONTROL',
  seqNo: 24,
  expectedSeqNo: 25,
  queuedDataSize: 0

Additional context

No response

The log entries supplied do not provide any information.
Try to reproduce the problem with the new version (as soon as it is released) and provide the complete logs.
In the meantime, I am closing this issue as I cannot reproduce it.