Skip to main content
Version: Dev (main)

Remote App on Another PC

What you build​

Your application already spans two PCs, for example a simulation server on the QAROS PC and its clients on other PCs, and the part on the other PC should stream into the same QAROS session without an operator walking over to pair it. One program plays three roles:

RoleWhereWhat it does
issuethe primary hub's PCcreates a member-hub invitation carrying a remote-app grant and writes it to stdout
jointhe other PC, first startreads the invitation, joins that PC's hub to the primary, onboards the app redeeming the grant
startthe other PC, every later startonboards as a plain local app: no invitation, no prompt

What you will learn:

  • how MemberHubInvitationConfig::app_grant_tag makes an invitation that admits one app
  • how Runtime::join_hub_as_member joins a PC's hub, not the app, to the primary
  • how OnboardExtensions::remote_app_grant redeems the grant, and what happens on later starts

An app cannot obtain a pairing code or an unbound invite for another PC: the grant is the only app-issued way in, and it admits exactly one app.

Before you start​

  • Windows, with QAROS installed on both PCs. Elsewhere the member-hub calls fail with NOT_IMPLEMENTED.
  • On the primary's PC, the operator gives the issuing app's approval the right to bring in member hubs ("May bring in member hubs"), with quota left.
  • A channel between the PCs that you trust: encrypted and authenticated. The example uses stdout and stdin as stand-ins for it.
  • macOS or Linux: the example runs against qaros-stub, which admits everything at once; set it up as in Local App Onboarding.

Run it​

# On the primary hub's PC:
cargo run -p qaros-examples --bin remote_app_onboarding -- issue | <your channel>
# On the other PC, first start:
<your channel> | cargo run -p qaros-examples --bin remote_app_onboarding -- join
# On the other PC, every later start:
cargo run -p qaros-examples --bin remote_app_onboarding -- start

issue refuses to print the invitation on a console, so it never lands on screen or in a terminal log; its messages go to stderr. To try it by hand, redirect it to a file you delete right after join read it. Exit codes, as in the C sample: 0 done, 1 error, 2 QAROS is not installed.

Walkthrough​

1. Issue the invitation on the primary's PC​

let config = MemberHubInvitationConfig {
label: Some("Remote app example".to_string()), // shown to the primary's operator
app_grant_tag: Some(GRANT_TAG.to_string()),
// Defaults: valid 24 h, one hub. Keep both as small as your flow allows.
..MemberHubInvitationConfig::default()
};
let invitation = runtime
.create_member_hub_invitation(&config, None)
.inspect_err(|error| {
if error.has_code(StatusCode::MEMBER_SPONSOR_NOT_ALLOWED) {
eprintln!("Ask the operator to allow this app to bring in member hubs.");
}
})?;
let mut bytes = invitation.serialize()?;
drop(invitation); // destroys the handle
// stdout stands in for your channel to the other PC; never log the bytes.
let written = std::io::stdout()
.write_all(&bytes)
.and_then(|()| std::io::stdout().flush());
bytes.fill(0); // clear the secret before freeing it
written.map_err(|error| {
Error::InvalidArgument(format!("the invitation was not handed over: {error}"))
})?;
eprintln!("qar_runtime_create_member_hub_invitation: ok");

The example first joins as a local app with its own tag, so the user can approve it; the issuing app is normally in the session anyway. What the primary hub checks:

CheckRefused with
the calling process is an app it approved (identified from Windows, as for a local app)ONBOARDING_APPROVAL_DENIED
the approval may bring in member hubs, with quota leftMEMBER_SPONSOR_NOT_ALLOWED, MEMBER_SPONSOR_QUOTA_EXCEEDED
the hub on this PC is a primary, not a memberSESSION_WIDE_ACTION_ON_MEMBER
the grant's tag follows the app tag rulesARGUMENT_NOT_SUPPORTED

The invitation is signed by the primary hub, valid 24 h and for one hub by default, and listed in the primary's Visualizer, where the operator can revoke it. It is a bearer secret: send it only over a channel you trust, never log it, never put it on a command line. The example clears its bytes once they are written.

2. Join the other PC's hub as a member​

let (progress, reports) = mpsc::channel::<Progress>();
let printer = std::thread::spawn(move || {
for report in reports {
eprintln!("{}", report.message);
}
});
let joined = runtime.join_hub_as_member(
&invitation, // borrowed for the call
&JoinHubAsMemberConfig::default(),
&BlockingOptions {
progress: Some(progress),
cancel: None,
},
);
let _ = printer.join();
if let Err(error) = &joined
&& error.has_code(StatusCode::TIMEOUT)
{
eprintln!("The join is committed; run join again once the hub is back.");
}
joined?;
  • This joins the hub of that PC, not the app. The call starts the installed hub when none runs, checks the invitation's signature and expiry, checks that this PC trusts the primary (an administrator's allow-list, else the primary this hub joined first), joins and waits through the hub's restart into the primary's session.
  • Typical failures: MEMBER_INVITATION_EXPIRED, _USED_UP, _REVOKED (ask for a new invitation), MEMBER_INVITATION_PRIMARY_NOT_ALLOWED (this PC does not trust that primary), PRIMARY_UNREACHABLE, TIMEOUT (the join is committed; calling again succeeds once the hub is back).
  • Called again for the primary it already belongs to, it succeeds at once.

3. Onboard, redeeming the grant​

let session = onboard_local(runtime, None, Some(&invitation)).inspect_err(|error| {
if error.has_code(StatusCode::ONBOARDING_APPROVAL_DENIED) {
eprintln!("The grant already admitted another app, or it was revoked.");
}
})?;

onboard_local passes the invitation as OnboardExtensions::remote_app_grant next to OnboardMethod::LocalApp; the grant's tag applies, so it sends no app_tag of its own.

  • Only a member hub redeems a grant, which is why the join comes first. A hub that is not a member ignores the grant and asks its own operator, as for any local app.
  • The first executable that redeems the grant is approved on the primary without a prompt and recorded by its publisher (signed) or file hash (unsigned). A different executable is refused afterwards with ONBOARDING_APPROVAL_DENIED, also with a later invitation of the same app and tag.
  • The primary picks the peer id and remembers it under the grant's tag.
  • With a grant, the issuing app's own approval is not extended to the member hub: the grant admits this one app only.

4. Every later start​

// No tag needed: the primary remembers a granted app under the grant's tag, whatever
// tag the app sends.
let session = onboard_local(runtime, None, None)?;

A plain local onboard: the app is approved now, so no invitation and no prompt are needed, and the primary gives it the same peer id while no other live process holds it.

What is stored, and for how long​

WhereWhatHow long
either appnothing
your channelthe invitationuntil used up or expired (one hub, 24 h by default)
the remote app's memoryits key and a 30-minute certificate, renewed while it runsthe process
the primary hubthe granted approval and the remembered peer iduntil revoked; the peer id until unused for 30 days

Revoking the issuing app's approval, or the granted one, on the primary revokes the remote app and forgets its peer id.

Ownership and teardown​

  • MemberHubInvitation owns its handle and destroys it on drop. join_hub_as_member and the onboard borrow it for their call only.
  • The serialized bytes are a copy the example clears after use; the handle keeps its own.
  • Sessions, runtime and library drop in any order, as in every example: each keeps its parent alive.

Troubleshooting​

What you seeCauseWhat to do
refusing to print the invitation on a consoleissue writes to a terminalpipe stdout into your channel, or redirect it to a file
Ask the operator to allow this app to bring in member hubs.the approval lacks the rightask the primary's operator
MEMBER_INVITATION_PRIMARY_NOT_ALLOWEDthis PC trusts another primary, or its administrator's allow-list does not name this oneask the PC's administrator
ONBOARDING_APPROVAL_DENIED on jointhe grant already admitted another executable, or it was revokedissue a grant with a new tag
an approval prompt on jointhe hub on this PC is not a member, so it ignores the grantrun join until the hub joined; check the join's error

From C​

The C tutorial is Remote App on Another PC.

CRust
QarMemberHubInvitationInit with a chained QarMemberHubInvitationAppGrantExtMemberHubInvitationConfig { app_grant_tag, .. }
qar_runtime_create_member_hub_invitationRuntime::create_member_hub_invitation
qar_member_hub_invitation_serialized_size, _serializeMemberHubInvitation::serialize
qar_member_hub_invitation_deserializeLibrary::deserialize_member_hub_invitation
qar_runtime_join_hub_as_member with QarJoinHubAsMemberInitRuntime::join_hub_as_member with JoinHubAsMemberConfig
QarOnboardRemoteAppGrantExt after QarOnboardLocalAppExtOnboardExtensions { remote_app_grant: Some(&invitation), .. } with OnboardMethod::LocalApp
qar_member_hub_invitation_handle_destroydrop the MemberHubInvitation
isatty(fileno(stdout))std::io::stdout().is_terminal()

Next​