Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Debug and troubleshoot Azure Container Apps and Function Apps using logs, KQL, and health checks.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
troubleshooting/messaging/azure-eventhubs-js.md
1# Azure Event Hubs SDK — JavaScript23Package: `@azure/event-hubs` | [README](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/event-hubs/) | [Full Troubleshooting Guide](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/eventhub/event-hubs/TROUBLESHOOTING.md)45## Common Errors67| Error | Code | Fix |8|-------|------|-----|9| `MessagingError` (connection:forced) | Idle disconnect | Auto-recovers; no action needed |10| `MessagingError` (Unauthorized) | Bad credentials | Verify connection string, SAS, or RBAC roles |11| `MessagingError` (retryable: true) | Transient issue | Auto-retried per `RetryOptions`. If surfaced, all retries exhausted |1213`MessagingError` fields: `name`, `code`, `retryable`, `info`, `address`, `errno`, `port`, `syscall`.1415## Enable Logging1617```bash18# All SDK logs19export AZURE_LOG_LEVEL=verbose2021# Or use DEBUG for granular control22export DEBUG=azure*,rhea*2324# Errors only25export DEBUG=azure:*:(error|warning),rhea-promise:error,rhea:events,rhea:frames,rhea:io,rhea:flow26```2728Browser:29```javascript30localStorage.debug = "azure:*:info";31```3233## Key Issues3435- **Socket exhaustion**: Treat clients as singletons. Each new client creates a new AMQP connection/socket. Always call `close()`.36- **412 precondition failures**: Normal during subscription partition ownership negotiation.37- **Partition ownership churn**: Expected when scaling instances. Should stabilize within minutes.38- **High CPU**: Limit to 1.5–3 partitions per CPU core.39- **Subscription stops receiving**: Often a symptom of an underlying race condition during error recovery. File a GitHub issue with DEBUG logs.40- **WebSockets**: Pass `webSocketOptions` to client constructor to connect over port 443.4142## Checkpointing (BlobCheckpointStore)4344Package: `@azure/eventhubs-checkpointstore-blob`4546> **Auth:** `DefaultAzureCredential` is for local development. See [auth-best-practices.md](auth-best-practices.md) for production patterns.4748```javascript49const { BlobCheckpointStore } = require("@azure/eventhubs-checkpointstore-blob");50const { BlobServiceClient } = require("@azure/storage-blob");5152const containerClient = new BlobServiceClient(storageEndpoint, credential)53.getContainerClient("checkpointstore");54const checkpointStore = new BlobCheckpointStore(containerClient);5556const consumerClient = new EventHubConsumerClient(57consumerGroup, fullyQualifiedNamespace, eventHubName, credential, checkpointStore58);59```6061**Common issues:**62- **Soft delete / blob versioning**: Disable both on the storage account — they cause delays during load balancing.63- **412 precondition failures**: Normal during partition ownership negotiation; not an error.64- **Checkpoint frequency**: Call `updateCheckpoint()` per batch, not per event, to reduce storage calls.65