Feature: tcp connect timeot#1
Merged
Merged
Conversation
…eout Give the PAL tcp_connect callback a caller-supplied timeout so a stalled TCP connect can no longer hang the caller on the OS default (tens of seconds). The POSIX and FreeRTOS/lwIP implementations now do a non-blocking connect bounded by select() and restore blocking mode afterwards; 0 = non-blocking single attempt, matching the tcp_send/tcp_recv convention. The loopback test double ignores the new parameter. Wire the timeout through every call site: ai-tcp passes connect_timeout_ms, HTTP passes the request timeout, MQTT gets a new MQTT_CONNECT_TIMEOUT_MS. Collapse tls_config_t's two timeouts into one: connect_timeout_ms now bounds the TCP connect AND the TLS handshake as a single establishment deadline, removing handshake_timeout_ms / TLS_DEFAULT_HANDSHAKE_TIMEOUT_MS. tls_connect therefore returns within ~one budget regardless of which phase stalls, which also restores tai_connect's documented ~2x worst case. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
dns_test, atop_test and ota_test forked their Python mock then slept a fixed 1-2s before connecting. On a loaded CI runner the mock isn't accepting yet when that sleep expires; the first real connect then races its startup. This was harmless while tcp_connect blocked on the OS default, but now that tcp_connect is time-bounded the racing connect times out and the test fails (only the later, mock-dependent cases; the param/failure cases still pass). Replace the blind sleep with the wait_for_port() readiness probe already proven in on_boarding_test (which uses the same mocks and passes): a non-blocking connect probe that returns once the port genuinely accepts, up to 15s. No SDK change -- this is purely a test-harness startup race. Verified: all three suites pass locally, and a slow-mock simulation confirms the probe waits ~until the port binds instead of failing fast. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
11088d8 to
2f19809
Compare
heshaoqiong-tuya
pushed a commit
that referenced
this pull request
Jul 3, 2026
Feature: tcp connect timeot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Give the PAL tcp_connect callback a caller-supplied timeout so a stalled TCP
connect can no longer hang the caller on the OS default (tens of seconds). The
POSIX and FreeRTOS/lwIP implementations now do a non-blocking connect bounded
by select() and restore blocking mode afterwards; 0 = non-blocking single
attempt, matching the tcp_send/tcp_recv convention. The loopback test double
ignores the new parameter.
Wire the timeout through every call site: ai-tcp passes connect_timeout_ms,
HTTP passes the request timeout, MQTT gets a new MQTT_CONNECT_TIMEOUT_MS.
Collapse tls_config_t's two timeouts into one: connect_timeout_ms now bounds
the TCP connect AND the TLS handshake as a single establishment deadline,
removing handshake_timeout_ms / TLS_DEFAULT_HANDSHAKE_TIMEOUT_MS. tls_connect
therefore returns within ~one budget regardless of which phase stalls, which
also restores tai_connect's documented ~2x worst case.