Skip to content

fix: pass Platform request timeouts to platform-mobile in seconds - #45

Merged
HashEngineering merged 2 commits into
mainfrom
fix/sdk-timeout-seconds
Nov 26, 2026
Merged

HashEngineering merged 2 commits into
mainfrom
fix/sdk-timeout-seconds

Conversation

@HashEngineering

@HashEngineering HashEngineering commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

DapiClient keeps timeOut in milliseconds (DEFAULT_TIMEOUT = 5000L; the same value is used with TimeUnit.MILLISECONDS in DAPIGrpcMasternode). It was passed unchanged to platformMobileSdkCreateDashSdkWithNetwork / WithContext, and platform-mobile builds RequestSettings with Duration::from_secs (sdk.rs, config.rs).

So every Platform request ran with a 5000s request timeout and a 10000s connect timeout, with 10 retries. The SDK logs this on every call:

settings: RequestSettings { connect_timeout: Some(10000s), timeout: Some(5000s), retries: Some(10), ... }

A DAPI node that accepts the connection and then stalls can hold a call for well over an hour per retry; only the HTTP/2 keep-alive cuts some of these short. In the wallet this shows up as DashConnect requests that never reach the approve dialog: a thread dump 28s after one tap had 11 Platform calls still blocked in getIdentity / refreshProtocolVersion / getPlatformTime.

The mismatch dates from the original platform-mobile commit (ac3e29d).

Fix

  • New millisToSdkSeconds() converts the millisecond timeouts to whole seconds before both SDK constructors. It rounds up and never returns 0, which would time out every request.
  • Defaults now reach the SDK as 5s request / 10s connect.
  • SdkTimeoutTest covers the defaults, rounding up, and the zero/negative cases.

Testing

  • ./gradlew :dpp:test --tests org.dashj.platform.dapiclient.SdkTimeoutTest: 3/3 pass.
  • Mainnet on Android emulators, compared with a build without this PR. With some nodes made to silently drop traffic, requests ended at 5 s (open connection) or 10 s (new connection), then the node was banned and the request retried. The build without this PR stalled 74 s on one dead node. Full results are in this comment.
  • Not yet verified on a physical device.

🤖 Generated with Claude Code

DapiClient keeps timeOut in milliseconds (DEFAULT_TIMEOUT = 5000) but
handed it unchanged to platformMobileSdkCreateDashSdkWith*, whose
RequestSettings use Duration::from_secs. Every request therefore ran
with a 5000s timeout and a 10000s connect timeout, so a DAPI node that
accepts a connection and then stalls could hold a call for over an hour
per retry.

Convert with millisToSdkSeconds(), which rounds up and never returns 0
(a zero Duration would time out every request). Defaults now reach the
SDK as 5s request / 10s connect.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4680c025-e7f5-4226-894d-81d877eff494
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@HashEngineering

Copy link
Copy Markdown
Collaborator Author

Test results: mainnet, Android emulators

The fix works on mainnet. A request to an unresponsive node now ends at the configured limit (5 s on an open connection, 10 s on a new one), and the SDK bans that node and retries elsewhere. Without the fix, one dead node stalled the DashPay contacts sync for 74 s.

Builds

Baseline (no fix) QA build (with fix)
Wallet prod 11.9.2, installed 2026-11-16 dash-wallet master @ 5aed9d1ca, prod debug
kotlin-platform 5.0.1, without this PR main @ f840f46 + this PR (598ea41) + #46, built locally as 5.0.1-qa45-SNAPSHOT
Emulator Pixel 9, API 35 (emulator-5556) Pixel 5, API 34 (emulator-5562)
RequestSettings in the log connect_timeout: Some(10000s), timeout: Some(5000s) connect_timeout: Some(10s), timeout: Some(5s)

Both apps had a DashPay identity (a different one on each emulator) and synced against mainnet.

What was tested

  1. Normal use and DashConnect. Launch, identity restore, the routine contacts and profiles sync, and DashConnect logins, with both apps watched side by side. Request durations come from the rs_dapi_client "calling ip" lines and the next log line on the same thread.
  2. Forced dead nodes on the QA build. The 5 nodes the app was actively using were made to silently drop all traffic (iptables -j DROP inside the emulator), then the app was left running for 15 minutes.
  3. Dead nodes on the baseline. The baseline still ships the old node list, which includes nodes that no longer answer. It hit one of them on its own during the session.

Results

Dead node behaviour

Case Baseline With this PR
New connection to a silent node 73.9 s, ended only by Android's TCP give-up (tcp connect error) 9.8–10.0 s (tcp connect error), then ban and retry
Node goes silent on an open connection not hit in this session; bounded only by the 5000 s request timeout 5.0 s every time (Timeout expired), then ban and retry
Effect on the contacts sync one sync took 1.28 min (normally about 1 s); no other contacts sync ran meanwhile the affected sync was delayed 5–15 s, then completed

On the QA build, 4 of 238 requests reached a blocked node. Each was cut off at its limit and banned, and the retry went out 0.01 s later. The other 234 requests took at most 1.10 s (median 0.19 s), and none were left unfinished.

Normal use, no dead nodes involved: no change. Median request time was 0.17–0.19 s on both builds.

DashConnect: the flow's Platform calls (getIdentity, getDataContract, and refreshProtocolVersion on the baseline) finished in about 2–2.5 s on both builds, each request under 1 s. No DashConnect errors were logged.

Things worth knowing

  • Retries can chain through several dead nodes. On the first blocked sync, one contacts request went through 3 blocked nodes in a row, adding 15 s before a working node answered. Up to 10 retries are allowed, so a pool with many dead nodes can still add up. The cost is bounded now, where before it effectively wasn't. Keeping the node list fresh (chore: refresh mainnet evonode lists and document how to update them #46) keeps this rare.
  • A first ban lasts 60 s (base_ban_period: 60s). After that the node can be picked again, and it costs another timeout. In 15 minutes, one blocked node was re-picked once.
  • The 5000 s request-timeout case (a node that accepts the connection and then never replies) wasn't reproduced on the baseline. Only connection-level blocking was possible on that emulator image, so the baseline's worst case above comes from Android's TCP limit (about 74 s), not from the 5000 s setting.

Not covered

  • Physical devices. Both runs were on emulators, against mainnet.
  • Testnet.
  • Write paths (state-transition broadcasts) under a dead node. The forced-block run exercised only reads (getDocuments, getIdentity). They use the same RequestSettings, so they should behave the same.

The unit mismatch this PR fixes came from unlabelled `usize` timeout
parameters. Doc-comment them as seconds in sdk.rs and config.rs, label
DEFAULT_TIMEOUT as milliseconds, and convert in the commented-out
create call so it isn't copied back with milliseconds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@HashEngineering HashEngineering self-assigned this Nov 26, 2026
@HashEngineering
HashEngineering merged commit 6ba5d5e into main Nov 26, 2026
2 checks passed
@HashEngineering
HashEngineering deleted the fix/sdk-timeout-seconds branch November 26, 2026 03:53
HashEngineering added a commit that referenced this pull request Nov 26, 2026
* chore: prepare 5.0.2 Maven Central release

5.0.2 = 5.0.1 + #45 (SDK timeouts passed in seconds) and #46 (refreshed
mainnet evonode lists). Same Platform pin (platform-revision.txt) and
dashj 24.0.0 as 5.0.1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* chore: set dash-sdk-bindings and platform-mobile crate versions to 5.0.2

The release commit bumped only the Android bindings crate. The desktop
dash-sdk-bindings crate was still 5.0.1 and platform-mobile had stayed
at 4.0.1 since that release. No code reads these versions, so the
published 5.0.2 artifacts are unaffected; this keeps the repo consistent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant