Skip to content

Commit 70ed087

Browse files
committed
Attempt different ciphers based on error message seen from i1+
1 parent d1ea23f commit 70ed087

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"homebridge-roomba2": patch
3+
---
4+
5+
Attempt different ciphers based on error message seen from i1+

src/accessory.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ export default class RoombaAccessory implements AccessoryPlugin {
386386
failed = true;
387387

388388
/* Check for recoverable errors */
389-
if (error instanceof Error && error.message.indexOf("TLS") !== -1 && attempts < ROBOT_CIPHERS.length) {
389+
if (error instanceof Error && shouldTryDifferentCipher(error) && attempts < ROBOT_CIPHERS.length) {
390390
/* Perhaps a cipher error, so we retry using the next cipher */
391391
this.currentCipherIndex = (this.currentCipherIndex + 1) % ROBOT_CIPHERS.length;
392392
this.log.debug("Retrying connection to Roomba with cipher %s", ROBOT_CIPHERS[this.currentCipherIndex]);
@@ -880,3 +880,15 @@ function millisToString(millis: number): string {
880880
return `${Math.round((millis / 60_000) * 10) / 10}m`;
881881
}
882882
}
883+
884+
function shouldTryDifferentCipher(error: Error) {
885+
/* Explicit TLS errors definitely suggest a different cipher should be used */
886+
if (error.message.indexOf("TLS") !== -1) {
887+
return true;
888+
}
889+
/* We have seen this error connecting to an i1+ https://github.com/homebridge-plugins/homebridge-roomba2/issues/129#issuecomment-1520733025 */
890+
if (error.message.toLowerCase().indexOf("identifier rejected") !== -1) {
891+
return true;
892+
}
893+
return false;
894+
}

0 commit comments

Comments
 (0)