Skip to content

Commit 58713d9

Browse files
authored
Merge pull request #248 from synonymdev/android-timeout-fix
fix: increase android connect timeout to 3s
2 parents 564684d + 9c08fbc commit 58713d9

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

lib/android/src/main/java/com/reactnativeldk/LdkModule.kt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ class LdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
513513
override fun run() {
514514
handleDroppedPeers()
515515
}
516-
}, 1000, 1000)
516+
}, 1000, 3000)
517517
timerTaskScheduled = true
518518
}
519519

@@ -638,7 +638,7 @@ class LdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
638638

639639
try {
640640
currentlyConnectingPeers.add(pubKey)
641-
peerHandler!!.connect(pubKey.hexa(), InetSocketAddress(address, port.toInt()), 10)
641+
peerHandler!!.connect(pubKey.hexa(), InetSocketAddress(address, port.toInt()), 3000)
642642
LdkEventEmitter.send(EventTypes.native_log, "Connection to peer $pubKey re-established by handleDroppedPeers().")
643643
} catch (e: Exception) {
644644
LdkEventEmitter.send(EventTypes.native_log, "Error connecting peer $pubKey. Error: $e")
@@ -667,19 +667,20 @@ class LdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaMod
667667
currentlyConnectingPeers.add(pubKey)
668668
peerHandler!!.connect(pubKey.hexa(), InetSocketAddress(address, port.toInt()), timeout.toInt())
669669

670+
handleResolve(promise, LdkCallbackResponses.add_peer_success)
671+
} catch (e: Exception) {
672+
handleReject(promise, LdkErrors.add_peer_fail, Error(e))
673+
} finally {
674+
currentlyConnectingPeers.remove(pubKey)
675+
676+
//Should retry if success or fail
670677
if (!addedPeers.map { it["pubKey"] as String }.contains(pubKey)) {
671678
addedPeers.add(hashMapOf(
672679
"address" to address,
673680
"port" to port,
674681
"pubKey" to pubKey
675682
))
676683
}
677-
678-
handleResolve(promise, LdkCallbackResponses.add_peer_success)
679-
} catch (e: Exception) {
680-
handleReject(promise, LdkErrors.add_peer_fail, Error(e))
681-
} finally {
682-
currentlyConnectingPeers.remove(pubKey)
683684
}
684685
}
685686

lib/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@synonymdev/react-native-ldk",
33
"title": "React Native LDK",
4-
"version": "0.0.141",
4+
"version": "0.0.143",
55
"description": "React Native wrapper for LDK",
66
"main": "./dist/index.js",
77
"types": "./dist/index.d.ts",

0 commit comments

Comments
 (0)