Exceptions you’ll see
| Exception | When | Recovery |
|---|---|---|
STXWrongCredentialsException | Email or password rejected at login | Prompt user for fresh creds |
STXSessionExpiredException | JWT and refresh token both expired | Call STXLoginService.LoginAsync again |
STXTokenExpiredException | JWT expired but refresh token is still valid | Call STXTokenService.RefreshTokenAsync, or rely on keepSessionAlive: true |
STXCancelOnDisconnectNotEnabledException | ConfirmOrderAsync(cancelOnDisconnect: true) called before joining STXActiveOrdersChannel | Join the channel first, or pass cancelOnDisconnect: false |
STXGeoComplyException | Geo-compliance check failed | User is outside a permitted jurisdiction — surface to your UI |
GraphQLHttpRequestException | Non-200 HTTP response from the GraphQL endpoint | Usually transient; retries handled internally (see below) |
STX.Sdk.Exceptions.
Example: handle auth failures
Example: refresh on expired token
When not usingkeepSessionAlive: true, wrap trading calls with a token-refresh retry:
Transient retries (automatic)
Every GraphQL mutation runs throughSTXGraphQLBaseService.SendMutationWithRetry, which uses Polly to retry on:
HttpRequestExceptionTaskCanceledException(timeout)- 5xx responses from the GraphQL endpoint
GraphQLHttpRequestException surfaces. Treat it as a service outage, not a programmer error — back off and try again later.
Rate limits
The exchange rate-limits by IP + account. Bursty order placement can return an HTTP 429. The SDK does not retry 429s automatically (retrying would make it worse). If you see them, lower your request rate or batch viaConfirmOrdersAsync.
Debugging
EnableDebug logging to see full GraphQL request/response bodies:

