Skip to main content

Pipeline Service Connection Test

This file helps test and troubleshoot WebSocket connections to the AIQlick pipeline service.

Expected Service Configuration

According to the integration guide, the pipeline service should be running on:

  • Development: ws://localhost:8000/ws/pipeline/{client_id}
  • Production: {client_id}

Current Error Analysis

The error you're seeing indicates that the WebSocket connection is being rejected immediately:

WebSocket connection to 'ws://localhost:3003/ws/pipeline/cv-processor-...' failed:
WebSocket is closed before the connection is established.

Possible Causes

  1. Service Not Running: The pipeline service is not running on port 8000
  2. Wrong Port: The service is running on a different port
  3. Service Configuration: The service doesn't accept WebSocket connections on the expected endpoint

Troubleshooting Steps

1. Check if Service is Running

# Check if anything is listening on port 8000
lsof -i :8000

# Or using netstat
netstat -tlnp | grep :8000

# Or using ss
ss -tlnp | grep :8000

2. Test Direct Connection

# Test if the service responds to HTTP requests
curl http://localhost:8000

# Test WebSocket connection with wscat (if installed)
wscat -c ws://localhost:8000/ws/pipeline/test-client

3. Check Service Logs

If you have access to the pipeline service logs, check for:

  • WebSocket endpoint registration
  • CORS configuration
  • Error messages during startup

Quick Fix Options

Option 1: Update Port (if service runs on different port)

If your pipeline service runs on a different port, update usePipeline.ts:

const PIPELINE_URLS = {
production: "wss://pipeline.aiqlick.com",
development: "ws://localhost:YOUR_PORT", // Replace YOUR_PORT
} as const

Option 2: Disable Auto-Connection (for development)

If you want to test the UI without the pipeline service, you can temporarily disable auto-connection by commenting out the useEffect in usePipeline.ts:

// useEffect(() => {
// connect();
// return () => {
// if (reconnectTimeoutRef.current) {
// clearTimeout(reconnectTimeoutRef.current);
// }
// if (wsRef.current) {
// wsRef.current.close();
// }
// };
// }, [connect]);

Option 3: Mock Service (for testing)

Create a simple mock WebSocket server for testing:

// mock-pipeline-server.js
const WebSocket = require("ws")

const wss = new WebSocket.Server({ port: 8000 })

wss.on("connection", function connection(ws, req) {
console.log("Client connected:", req.url)

ws.on("message", function message(data) {
console.log("Received:", data.toString())

// Echo back a mock response
const response = {
type: "pipeline_result",
data: { message: "Mock response from pipeline service" },
}

ws.send(JSON.stringify(response))
})

// Send welcome message
ws.send(
JSON.stringify({
type: "connection_status",
data: "Connected to mock pipeline service",
})
)
})

console.log("Mock pipeline service running on ws://localhost:8000")

Run with: node mock-pipeline-server.js

Integration Guide Alignment

The current implementation is aligned with the comprehensive integration guide:

  • ✅ Hardcoded URLs (no environment variables)
  • ✅ Proper WebSocket message format
  • ✅ Error handling and reconnection logic
  • ✅ Support for all pipeline types (cv_extraction, cv_processing, job_parsing, matching)
  • ✅ MinIO file upload integration
  • ✅ Progressive reconnection backoff

Next Steps

  1. Verify the pipeline service is running and accessible
  2. Confirm the correct port/endpoint configuration
  3. Test the connection manually before using the React hook
  4. Check service logs for any configuration issues

Once the service is properly configured and running, the WebSocket connection should work seamlessly with the current implementation.