SDK Troubleshooting Guide
Common issues when using the AnkaSecure Java SDK and their solutions.
Connection Issues
Connection Refused
Symptom:
Causes: - API endpoint URL incorrect - Firewall blocking outbound HTTPS (port 443) - Network connectivity issues
Solutions:
-
Verify API endpoint:
-
Test connectivity:
-
Check firewall: Allow outbound HTTPS to
*.ankasecure.comport 443
Connection Timeout
Symptom:
Causes: - Network latency too high - Default timeout too short (10 seconds) - Server overloaded (rare)
Solutions:
-
Increase timeout:
-
Check network latency:
SSL Certificate Validation Failed
Symptom:
Causes: - Outdated CA certificates in JVM - Corporate proxy intercepting TLS (MITM)
Solutions:
-
Update JVM (recommended):
-
Update CA certificates:
-
If behind corporate proxy with custom CA:
❌ DON'T: Disable certificate validation (insecure):
Authentication Issues
401 Unauthorized
Symptom:
Causes: - API key invalid or expired - JWT token expired (1-hour lifetime) - Wrong tenant ID
Solutions:
-
Verify API key:
-
Check tenant ID:
-
Test authentication:
-
For JWT tokens: Implement token refresh
403 Forbidden
Symptom:
Causes: - User/application lacks required permissions - Trying to access another tenant's resources - Key belongs to different tenant
Solutions:
-
Verify permissions: Check user role in Admin Console (Tenant Admin, Application Admin, User)
-
Verify tenant ownership:
-
Check RBAC: Contact tenant admin to grant permissions
Cryptographic Errors
422 Unprocessable Entity (Crypto Error)
Symptom:
Causes: - Ciphertext corrupted during transmission - Ciphertext modified (integrity violation) - Wrong decryption key used
Solutions:
-
Verify ciphertext integrity:
-
Use correct key for decryption:
-
Check for encoding issues:
Key Not Found (404)
Symptom:
Causes: - Key ID doesn't exist - Typo in key ID (case-sensitive) - Key belongs to different tenant
Solutions:
-
List available keys:
-
Verify key ID (case-sensitive):
-
Check tenant: Ensure key created in same tenant as API key
Performance Issues
Slow Encryption (>500ms for 5 MB)
Symptom: Encryption takes significantly longer than benchmarks
Causes: - Network latency (high ping to API) - Creating new client per request (connection overhead) - Using slow algorithm (Classic McEliece, SLH-DSA-S)
Solutions:
-
Check network latency:
-
Verify client reuse:
-
Choose faster algorithm:
See performance optimization →
Out of Memory (Large Files)
Symptom:
Causes: - Using compact API for files >5 MB (loads entire file into memory) - JVM heap size too small
Solutions:
-
Use streaming API for large files:
-
Increase JVM heap (if needed):
See streaming API documentation →
Dependency Conflicts
NoSuchMethodError or ClassNotFoundException
Symptom:
Causes: - Version conflict with OkHttp (SDK uses 4.12.0) - Version conflict with Gson (SDK uses 2.10.1)
Solutions:
-
Exclude conflicting dependencies:
<dependency> <groupId>co.ankatech</groupId> <artifactId>ankasecure-sdk</artifactId> <version>3.0.0</version> <exclusions> <exclusion> <groupId>com.squareup.okhttp3</groupId> <artifactId>okhttp</artifactId> </exclusion> </exclusions> </dependency> <!-- Use your preferred OkHttp version --> <dependency> <groupId>com.squareup.okhttp3</groupId> <artifactId>okhttp</artifactId> <version>4.12.0</version> </dependency> -
Check dependency tree:
Common SDK Exceptions
AnkaSecureException
Base exception for all SDK errors:
try {
client.encrypt(request);
} catch (AnkaSecureException e) {
System.err.println("Error Code: " + e.getErrorCode()); // e.g., "CRYPTO_001"
System.err.println("Message: " + e.getMessage());
System.err.println("HTTP Status: " + e.getHttpStatus()); // e.g., 422
System.err.println("Trace ID: " + e.getTraceId()); // For support
}
Common Error Codes:
- AUTH_001: Authentication failed (401)
- KEY_001: Key not found (404)
- CRYPTO_001: Cryptographic operation failed (422)
- RATE_001: Rate limit exceeded (429)
- QUOTA_001: Monthly quota exceeded (402)
RateLimitException
Thrown when rate limit exceeded:
try {
client.encrypt(request);
} catch (RateLimitException e) {
int retryAfter = e.getRetryAfter(); // Seconds to wait
System.err.println("Rate limited. Retry after: " + retryAfter + "s");
// Implement backoff
Thread.sleep(retryAfter * 1000);
client.encrypt(request); // Retry
}
ValidationException
Thrown when request validation fails:
try {
client.generateKey(request);
} catch (ValidationException e) {
List<ValidationError> errors = e.getValidationErrors();
errors.forEach(error -> {
System.err.println("Field: " + error.getField());
System.err.println("Issue: " + error.getIssue());
System.err.println("Received: " + error.getReceived());
});
}
// Example output:
// Field: algorithm
// Issue: Must be one of: ML-KEM-512, ML-KEM-768, ML-KEM-1024
// Received: INVALID_ALGO
Debugging Tips
Enable Debug Logging
Configure SDK logging:
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
// Enable debug logs for AnkaSecure SDK
Logger sdkLogger = (Logger) LoggerFactory.getLogger("co.ankatech.ankasecure");
sdkLogger.setLevel(Level.DEBUG);
Or via logback.xml:
<configuration>
<logger name="co.ankatech.ankasecure" level="DEBUG"/>
<logger name="okhttp3" level="DEBUG"/> <!-- HTTP client logs -->
</configuration>
Debug Output:
DEBUG co.ankatech.ankasecure.client - Request: POST /api/v1/crypto/encrypt
DEBUG co.ankatech.ankasecure.client - Headers: Authorization=Bearer ask_***, X-Tenant-ID=acme-corp
DEBUG co.ankatech.ankasecure.client - Body: {"keyId":"my-key","plaintext":"..."}
DEBUG co.ankatech.ankasecure.client - Response: 200 OK
DEBUG co.ankatech.ankasecure.client - Latency: 124ms
Extract Correlation ID
Use correlation ID for support:
try {
client.encrypt(request);
} catch (AnkaSecureException e) {
String traceId = e.getTraceId(); // Correlation ID
System.err.println("Error occurred. Trace ID: " + traceId);
System.err.println("Include this ID when contacting support");
// Log for troubleshooting
log.error("Encryption failed [traceId={}]", traceId, e);
}
Contact Support: Provide trace ID for faster resolution
Need Help?
- Common Errors - FAQ-style troubleshooting
- API Errors - API error resolution
- Error Catalog - Complete error reference
- Support - Contact support team
Documentation Version: 3.0.0 Last Updated: 2025-12-26