Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
O
openclaw-android-node
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lisa
openclaw-android-node
Commits
3180219d
Commit
3180219d
authored
Mar 11, 2026
by
Lisa (AI Assistant)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: Send pairing request on reconnect instead of on closing socket
parent
e36c37af
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
11 deletions
+25
-11
NodeClient.kt
...n/java/com/nexlab/openclaw/node/data/remote/NodeClient.kt
+25
-11
No files found.
app/src/main/java/com/nexlab/openclaw/node/data/remote/NodeClient.kt
View file @
3180219d
...
@@ -63,6 +63,7 @@ class NodeClient() {
...
@@ -63,6 +63,7 @@ class NodeClient() {
private
var
challengeNonce
:
String
=
""
private
var
challengeNonce
:
String
=
""
private
var
challengeTimestamp
:
Long
=
0
private
var
challengeTimestamp
:
Long
=
0
private
var
hasReceivedChallenge
=
false
private
var
hasReceivedChallenge
=
false
private
var
pendingPairingAfterConnect
=
false
// Flag to send pairing request after reconnect
// SharedPreferences for device identity persistence
// SharedPreferences for device identity persistence
private
var
prefs
:
SharedPreferences
?
=
null
private
var
prefs
:
SharedPreferences
?
=
null
...
@@ -223,8 +224,15 @@ class NodeClient() {
...
@@ -223,8 +224,15 @@ class NodeClient() {
hasReceivedChallenge
=
true
hasReceivedChallenge
=
true
Log
.
d
(
TAG
,
"Received challenge: nonce=$challengeNonce, ts=$challengeTimestamp"
)
Log
.
d
(
TAG
,
"Received challenge: nonce=$challengeNonce, ts=$challengeTimestamp"
)
// Now send connect request with proper v3 signature
// Check if we need to send pairing request instead of connect
sendConnectRequestWithChallenge
(
nodeId
,
token
,
capabilities
)
if
(
pendingPairingAfterConnect
)
{
pendingPairingAfterConnect
=
false
Log
.
d
(
TAG
,
"Sending pairing request after reconnect"
)
sendPairingRequest
(
nodeId
,
token
,
capabilities
)
}
else
{
// Now send connect request with proper v3 signature
sendConnectRequestWithChallenge
(
nodeId
,
token
,
capabilities
)
}
}
else
if
(
event
==
"node.pair.resolved"
)
{
}
else
if
(
event
==
"node.pair.resolved"
)
{
// Pairing was approved, now reconnect with token
// Pairing was approved, now reconnect with token
val
approved
=
json
.
optJSONObject
(
"payload"
)
?.
optBoolean
(
"approved"
,
false
)
val
approved
=
json
.
optJSONObject
(
"payload"
)
?.
optBoolean
(
"approved"
,
false
)
...
@@ -252,9 +260,9 @@ class NodeClient() {
...
@@ -252,9 +260,9 @@ class NodeClient() {
if
((
error
?.
contains
(
"device-required"
)
==
true
||
if
((
error
?.
contains
(
"device-required"
)
==
true
||
error
?.
contains
(
"device signature"
)
==
true
||
error
?.
contains
(
"device signature"
)
==
true
||
error
?.
contains
(
"invalid"
)
==
true
)
&&
isPairingMode
)
{
error
?.
contains
(
"invalid"
)
==
true
)
&&
isPairingMode
)
{
//
Now send pairing request after connect failed
//
Set flag to send pairing request after reconnect
Log
.
d
(
TAG
,
"Sending pairing request after connection rejection"
)
pendingPairingAfterConnect
=
true
sendPairingRequest
(
currentNodeId
,
currentToken
,
capabilities
)
Log
.
d
(
TAG
,
"Will send pairing request on reconnect after connection rejection"
)
}
else
{
}
else
{
_connectionStatus
.
trySend
(
ConnectionStatus
(
false
,
nodeId
))
_connectionStatus
.
trySend
(
ConnectionStatus
(
false
,
nodeId
))
}
}
...
@@ -276,13 +284,13 @@ class NodeClient() {
...
@@ -276,13 +284,13 @@ class NodeClient() {
override
fun
onClosing
(
webSocket
:
WebSocket
,
code
:
Int
,
reason
:
String
)
{
override
fun
onClosing
(
webSocket
:
WebSocket
,
code
:
Int
,
reason
:
String
)
{
Log
.
d
(
TAG
,
"WebSocket closing: code=$code reason=$reason"
)
Log
.
d
(
TAG
,
"WebSocket closing: code=$code reason=$reason"
)
// Check if it's a device signature error
and we should send
pairing request
// Check if it's a device signature error
- need to reconnect with
pairing request
if
(
isPairingMode
&&
(
reason
.
contains
(
"device signature"
)
||
if
(
isPairingMode
&&
(
reason
.
contains
(
"device signature"
)
||
reason
.
contains
(
"invalid"
)
||
reason
.
contains
(
"invalid"
)
||
reason
.
contains
(
"device-required"
)))
{
reason
.
contains
(
"device-required"
)))
{
Log
.
d
(
TAG
,
"Connection rejected due to device auth,
sending pairing reques
t"
)
Log
.
d
(
TAG
,
"Connection rejected due to device auth,
will send pairing request on reconnec
t"
)
// Se
nd pairing request after connection rejection
// Se
t flag to send pairing request after reconnect
sendPairingRequest
(
currentNodeId
,
currentToken
,
capabilities
)
pendingPairingAfterConnect
=
true
}
}
webSocket
.
close
(
1000
,
null
)
webSocket
.
close
(
1000
,
null
)
...
@@ -296,8 +304,14 @@ class NodeClient() {
...
@@ -296,8 +304,14 @@ class NodeClient() {
if
(
isPairingMode
&&
(
reason
.
contains
(
"device signature"
)
||
if
(
isPairingMode
&&
(
reason
.
contains
(
"device signature"
)
||
reason
.
contains
(
"invalid"
)
||
reason
.
contains
(
"invalid"
)
||
reason
.
contains
(
"device-required"
)))
{
reason
.
contains
(
"device-required"
)))
{
Log
.
d
(
TAG
,
"Connection rejected due to device auth, sending pairing request"
)
Log
.
d
(
TAG
,
"Connection rejected due to device auth, will send pairing request on reconnect"
)
sendPairingRequest
(
currentNodeId
,
currentToken
,
capabilities
)
// Set flag to send pairing request after reconnect
pendingPairingAfterConnect
=
true
// Reconnect
scope
.
launch
{
delay
(
500
)
// Brief delay before reconnecting
connect
(
currentNodeId
,
currentToken
,
capabilities
)
}
return
return
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment