================================================================================ API CARTEC - ACCESO DESDE RED LOCAL (192.168.100.87) ================================================================================ CONFIGURACIÓN RÁPIDA ================================================================================ 1. EN EL SERVIDOR (192.168.100.87): # Abrir puerto en firewall $ sudo ufw allow 3000/tcp # Verificar que escucha en todas las interfaces $ sudo netstat -tlnp | grep 3000 # Debe mostrar: 0.0.0.0:3000 (no 127.0.0.1:3000) # Si muestra 127.0.0.1, reiniciar el servicio $ sudo systemctl restart cartec-api ================================================================================ 2. DESDE OTRA MÁQUINA EN LA RED (192.168.100.x): # Verificar conectividad $ ping 192.168.100.87 # Verificar puerto abierto $ telnet 192.168.100.87 3000 # o $ nc -zv 192.168.100.87 3000 ================================================================================ PRUEBAS DESDE OTRA MÁQUINA ================================================================================ Health Check: ------------- curl http://192.168.100.87:3000/api/health Crear OT: --------- curl -X POST http://192.168.100.87:3000/api/ot/create \ -H "Content-Type: application/json" \ -d '{ "cliente": { "rut": "12345678-5", "nombre": "Cliente Prueba Red", "direccion": "Av. Test 123", "comuna": "Santiago", "telefono": "+56912345678", "email": "test@cartec.cl" }, "tecnico": { "rut": "11111111-1" }, "servicio": { "presGPS": "gpsimple", "tiposerv": "instalacion_gps", "taller_install": "cartec" }, "vehiculos": [ { "patente": "RED01", "marca": "Toyota", "modelo": "Corolla", "color": "Blanco", "anio": 2021 } ] }' ================================================================================ INTEGRACIÓN PHP (desde otro servidor): ================================================================================ [ 'rut' => '12345678-5', 'nombre' => 'Cliente PHP', 'direccion' => 'Av. PHP 123', 'comuna' => 'Santiago', 'telefono' => '+56912345678', 'email' => 'php@cartec.cl' ], 'tecnico' => ['rut' => '11111111-1'], 'servicio' => [ 'presGPS' => 'gpsimple', 'tiposerv' => 'instalacion_gps', 'taller_install' => 'cartec' ], 'vehiculos' => [ [ 'patente' => 'PHP001', 'marca' => 'Toyota', 'modelo' => 'Corolla', 'color' => 'Blanco', 'anio' => 2021 ] ] ]; $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($datos)); curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); $resultado = json_decode($response, true); if ($resultado['success']) { echo "OT creada: " . $resultado['data']['id_ot']; } else { echo "Error: " . $resultado['message']; } ?> ================================================================================ TROUBLESHOOTING ================================================================================ Problema: "Connection refused" Solución: 1. Verificar que la API está ejecutándose: $ sudo systemctl status cartec-api 2. Verificar firewall: $ sudo ufw status $ sudo ufw allow 3000/tcp 3. Verificar que escucha en 0.0.0.0: $ sudo netstat -tlnp | grep 3000 -------------------------------------------------------------------------------- Problema: "Connection timeout" Solución: 1. Verificar red: $ ping 192.168.100.87 2. Verificar puerto: $ telnet 192.168.100.87 3000 3. Verificar firewall del servidor remoto -------------------------------------------------------------------------------- Problema: API solo escucha en localhost (127.0.0.1) Solución: La API de Node.js ya está configurada para escuchar en 0.0.0.0 Si no funciona, verificar que no haya proxy o configuración adicional ================================================================================ URLS DE ACCESO ================================================================================ Desde el mismo servidor: http://localhost:3000/api Desde la red local: http://192.168.100.87:3000/api Desde otra subred: Configurar router/firewall ================================================================================ ENDPOINTS DISPONIBLES ================================================================================ GET /api/health - Verificación de estado POST /api/ot/create - Crear orden de trabajo ================================================================================ CONTACTO ================================================================================ Servidor: 192.168.100.87 Puerto: 3000 Servicio: cartec-api Logs: sudo journalctl -u cartec-api -f ================================================================================