Test your Load Balancer
This page explains how to test your Load Balancer after installation and configuration, to ensure it is running and routing tasks as expected.
Start the Load Balancer
Make sure your Load Balancer is running locally (default port: 4000):
npm run build
node dist/app.js
Or, if using Docker:
docker network create andera-net
docker compose build
docker compose up
Health Check
Test the health endpoint to verify the Load Balancer is up:
curl http://localhost:4000/health
Expected response:
{
"status": "ready"
}
The status is unreachable when Redis or BullMQ cannot be reached.
The /health endpoint displays more useful information when authenticated with the LB_AUTH_KEY:
curl -H "Authorization: <LB_AUTH_KEY>" http://localhost:4000/health
Submit a Task
Call the /task endpoint to route a task to a connected Worker. You must specify the group, contract, and function fields, and provide two headers:
Authorization: <LB_AUTH_KEY>(your Load Balancer's LB_AUTH_KEY)x-wr-auth: <AUTH_KEY>(the target Worker's AUTH_KEY)
curl -X POST http://localhost:4000/task \
-H "Content-Type: application/json" \
-H "Authorization: <LB_AUTH_KEY>" \
-H "x-wr-auth: <AUTH_KEY>" \
-d '{
"function": "hello",
"input": { "name": "Andera" },
"contract": 1,
"group": "default"
}'
Expected response:
{
"success": true,
"result": {
"message": "Hello Andera!"
}
}
Test MCP
After configuring MCP targets, connect a compatible client to http://localhost:4000/mcp with only MCP_AUTH_KEY. List the tools and call the exact name returned by the catalog. The LB supplies Worker credentials internally.
Troubleshooting
- The Load Balancer does not start: Check the error in its output.
LB_AUTH_KEYis required, and numeric settings are validated at startup. - No workers available: Make sure at least one Worker is connected and healthy. From inside Docker,
localhostis the Load Balancer container itself; use a Docker network address. - 401 Unauthorized: Check your
LB_AUTH_KEYand use the correct header. The Worker also answers 401 whenx-wr-authdoes not match itsAUTH_KEY, or when itsLB_AUTH_KEYdiffers from the Load Balancer's. - 400 Bad Request:
group,contractandfunctionare required, and thex-wr-authheader must be present. - Other 4xx from a Worker: The Worker rejected the task (for example, invalid input). The Load Balancer returns the Worker's status and error message without retrying.
- 500 Task failed or timed out: Check load balancer and worker logs for errors, as well as group name, contract version, etc.