Skip to main content

Troubleshooting Common Issues

Troubleshooting Common Issues

Issue: Rate Limiting

Symptoms: 429 Too Many Requests responses

Solution: Implement exponential backoff and respect retry-after headers

const fetchWithBackoff = async (url, options, maxRetries = 3) => {
for (let i = 0; i < maxRetries; i++) {
const response = await fetch(url, options);

if (response.status !== 429) {
return response;
}

const retryAfter = response.headers.get('Retry-After') || Math.pow(2, i);
await new Promise(resolve => setTimeout(resolve, retryAfter * 1000));
}

throw new Error('Max retries exceeded');
};

Issue: Large Data Set Handling

Solution: Use time-bounded queries and subscriptions for streaming

// For historical data, use time-bounded queries
const getHistoryInChunks = async (token, elementId, startTime, endTime) => {
const response = await fetch('https://api.i3x.dev/v0/objects/history', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
elementId: elementId,
startTime: startTime,
endTime: endTime,
maxDepth: 1
})
});

return await response.json();
};

// For real-time streaming, use subscriptions
const streamObjectData = async (token, elementIds, callback) => {
// Create subscription
const createRes = await fetch('https://api.i3x.dev/v0/subscriptions', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({})
});
const { subscriptionId } = await createRes.json();

// Register objects to monitor
await fetch(`https://api.i3x.dev/v0/subscriptions/${subscriptionId}/register`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ elementIds, maxDepth: 1 })
});

// Stream via SSE
const eventSource = new EventSource(
`https://api.i3x.dev/v0/subscriptions/${subscriptionId}/stream`
);
eventSource.onmessage = (event) => callback(JSON.parse(event.data));

return { subscriptionId, eventSource };
};