Skip to content

connect() discards the synchronous SDK::Connect status — failures report a 15s timeout that never happened #38

Description

@jordlee

Symptom

A failed POST /api/cameras/{id}/connection returns:

Connection did not complete within 15s. If this is a network connection, check
that remote shooting is enabled on the camera.

…but it returns in ~3.6s, and no 15s wait ever occurred. The message names the wrong cause and a wait that did not happen, so it sends you toward camera network settings when the failure was elsewhere entirely.

Cause

CameraDeviceRest::connect() zeroes the error, then drops the SDK status on the synchronous-failure path:

https://github.com/crsdk/alpha-sdk-api/blob/main/api/server/src/device/CameraDeviceRest.cpp#L93-L110

m_lastError.store(0);
auto status = SDK::Connect(...);
if (CR_FAILED(status)) {
    return false;              // <-- status never stored into m_lastError
}

The controller then skips wait_for_connection() (it only runs if (connect_result)), so last_error() is still 0 and it falls into the "no SDK error ⇒ it must have timed out" branch:

https://github.com/crsdk/alpha-sdk-api/blob/main/api/server/src/CameraWebController.cpp#L714-L719

That branch's assumption is sound only when the wait actually ran. On a synchronous failure it is reached with no wait and no error, and it fabricates a timeout.

Impact

Every synchronous SDK::Connect failure is misreported as a 15s network timeout, and the SDK's real error code is discarded — so the one piece of information that would identify the actual fault never reaches the caller or the logs. Observed via the MCP bundle as Connect failed: Connection did not complete within 15s, returned instantly.

Suggested fix

Store the status before returning, so the existing error-code branch can report it:

if (CR_FAILED(status)) {
    m_lastError.store(status);
    return false;
}

Then make the timeout branch in CameraWebController conditional on the wait having actually run, so "timed out" can only be claimed when something was waited on.

Environment

macOS 15 (arm64), ILCE-7M5 over USB, main @ 4e1927a.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions