Network Troubleshooting
This guide covers network-related issues affecting communication between Tamandua components, including WebSocket connections, TLS/mTLS, firewalls, and proxies.
WebSocket Connection Failures
Symptoms
- Agents show as offline
- Connection drops frequently
- WebSocket upgrade fails
Diagnostic Steps
- Test WebSocket connectivity
# Using websocat
websocat wss://server:4000/socket/agent
# Using wscat
wscat -c wss://server:4000/socket/agent
- Check HTTP upgrade
curl -v -H "Connection: Upgrade" -H "Upgrade: websocket" \
https://server:4000/socket/agent
Common Causes and Solutions
WebSocket Upgrade Rejected
Error:HTTP/1.1 400 Bad Request
error: missing upgrade header
Solution:
- Verify request headers include:
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Key: <base64-key>
Sec-WebSocket-Version: 13
- Check reverse proxy passes WebSocket headers
Load Balancer Not Supporting WebSockets
Error:HTTP/1.1 502 Bad Gateway
WebSocket connection failed: upstream closed connection
Solution (AWS ALB):
# Target group settings
stickiness.enabled: true
stickiness.type: lb_cookie
Solution (nginx):
location /socket {
proxy_pass http://backend;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_read_timeout 86400;
}
Solution (HAProxy):
frontend https
bind *:443 ssl crt /etc/ssl/tamandua.pem
acl is_websocket hdr(Upgrade) -i websocket
use_backend websocket_backend if is_websocket
default_backend http_backend
backend websocket_backend
timeout server 86400s
timeout tunnel 86400s
server srv1 backend1:4000 check
Connection Timeout
Error:WebSocket connection timeout after 30s
Solution:
- Increase timeout in agent configuration:
[transport]
connect_timeout_secs = 60
- Check for network latency:
ping server.example.com
traceroute server.example.com
- Verify no rate limiting on connection establishment
Frequent Disconnections
Error:WebSocket disconnected: ping timeout
Connection lost, attempting reconnect (attempt 5/10)
Solution:
- Adjust ping/pong intervals:
# Server config
config :tamandua_server, TamanduaServerWeb.Endpoint,
http: [
transport_options: [
idle_timeout: 120_000
]
]
# Agent config
[transport]
ping_interval_secs = 30
ping_timeout_secs = 60
- Check for aggressive NAT timeouts
- Verify load balancer idle timeout settings
Firewall Configuration
Required Ports
| Port | Protocol | Direction | Purpose |
|---|---|---|---|
| 4000 | TCP | Agent -> Server | WebSocket/HTTPS |
| 443 | TCP | Agent -> Server | HTTPS (alt config) |
| 5432 | TCP | Server -> DB | PostgreSQL |
| 6379 | TCP | Server -> Redis | Redis |
| 5672 | TCP | Server -> RabbitMQ | AMQP |
| 8000 | TCP | Server -> ML | ML Service |
Firewall Rules
Linux (iptables)
# Allow outbound from agent to server
iptables -A OUTPUT -p tcp --dport 4000 -j ACCEPT
# Allow inbound to server
iptables -A INPUT -p tcp --dport 4000 -j ACCEPT
Linux (firewalld)
# On server
firewall-cmd --permanent --add-port=4000/tcp
firewall-cmd --reload
Windows Firewall
# Allow Tamandua agent outbound
New-NetFirewallRule -DisplayName "Tamandua Agent" `
-Direction Outbound -Program "C:\Program Files\Tamandua\tamandua-agent.exe" `
-Action Allow
# Allow server inbound
New-NetFirewallRule -DisplayName "Tamandua Server" `
-Direction Inbound -LocalPort 4000 -Protocol TCP `
-Action Allow
AWS Security Groups
{
"SecurityGroupIngress": [
{
"IpProtocol": "tcp",
"FromPort": 4000,
"ToPort": 4000,
"CidrIp": "10.0.0.0/8",
"Description": "Tamandua agent connections"
}
]
}
Troubleshooting Firewall Issues
Symptoms:- Connection refused or timeout
- Works from some networks but not others
# Test connectivity
telnet server.example.com 4000
nc -zv server.example.com 4000
# Check if port is listening
netstat -tlnp | grep 4000
# Test from agent network
curl -v https://server.example.com:4000/api/health
Proxy Issues
HTTP Proxy Configuration
Agent Configuration
[transport]
proxy_url = "http://proxy.corp.com:8080"
proxy_username = "user"
proxy_password = "pass"
Environment Variables
# HTTP proxy
export HTTP_PROXY="http://proxy.corp.com:8080"
export HTTPS_PROXY="http://proxy.corp.com:8080"
export NO_PROXY="localhost,127.0.0.1,.internal.corp.com"
Common Proxy Issues
Proxy Authentication Required
Error:HTTP/1.1 407 Proxy Authentication Required
Solution:
- Configure proxy credentials:
[transport]
proxy_url = "http://user:pass@proxy.corp.com:8080"
- Or use NTLM authentication:
[transport]
proxy_url = "http://proxy.corp.com:8080"
proxy_auth = "ntlm"
proxy_domain = "CORP"
proxy_username = "user"
proxy_password = "pass"
Proxy Not Supporting WebSocket
Error:WebSocket upgrade failed through proxy
HTTP/1.1 400 Bad Request
Solution:
- Use CONNECT method (HTTPS tunneling):
[transport]
proxy_tunnel = true
- Configure proxy to allow CONNECT to port 4000
- Consider direct connection bypass for internal servers
Proxy SSL Interception
Error:Certificate verification failed: issuer not trusted
SSL certificate signed by: "Corp Proxy CA"
Solution:
- Add corporate CA to trust store:
# Linux
sudo cp corp-ca.pem /usr/local/share/ca-certificates/corp-ca.crt
sudo update-ca-certificates
# Windows
certutil -addstore -f "ROOT" corp-ca.pem
- Or specify CA in agent config:
[transport]
ca_cert_path = "/etc/tamandua/corp-ca.pem"
Proxy Timeout
Error:Proxy connection timeout
Solution:
- Increase proxy timeout:
[transport]
proxy_connect_timeout_secs = 60
- Check proxy server health
- Verify proxy allows long-lived connections
Transparent Proxy Detection
# Check if connections are being proxied
curl -v https://server.example.com:4000/api/health 2>&1 | grep -i "proxy\|via"
# Compare certificate chains
openssl s_client -connect server.example.com:4000 -showcerts
mTLS Handshake Failures
Symptoms
- TLS handshake fails
- Certificate rejected by server
- Agent cannot authenticate
Diagnostic Steps
- Test TLS connection
openssl s_client -connect server:4000 \
-cert client.pem -key client-key.pem -CAfile ca.pem
- Verify certificate
openssl x509 -in client.pem -noout -text
openssl verify -CAfile ca.pem client.pem
Common Causes and Solutions
Client Certificate Not Presented
Error:Server: SSL peer did not return a certificate
Agent: SSL handshake failed
Solution:
Configure client certificate:
[transport]
client_cert_path = "/etc/tamandua/agent.pem"
client_key_path = "/etc/tamandua/agent-key.pem"
Certificate Chain Incomplete
Error:verify error:num=21:unable to verify the first certificate
Solution:
- Include intermediate certificates in cert file:
cat agent.pem intermediate.pem > agent-chain.pem
- Configure full chain:
[transport]
client_cert_path = "/etc/tamandua/agent-chain.pem"
Certificate Expired
Error:verify error:num=10:certificate has expired
Solution:
- Check expiration:
openssl x509 -in agent.pem -noout -dates
- Renew certificate and redeploy
- Set up certificate rotation automation
Certificate Revoked
Error:verify error:num=23:certificate revoked
Solution:
- Check CRL/OCSP:
openssl verify -crl_check -CAfile ca.pem -CRLfile crl.pem agent.pem
- Issue new certificate
- Review revocation reason
Wrong CA
Error:verify error:num=20:unable to get local issuer certificate
Solution:
- Verify certificate was signed by expected CA:
openssl verify -CAfile server-ca.pem agent.pem
- Update CA certificate on server or agent
Key Mismatch
Error:error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch
Solution:
- Verify key matches certificate:
openssl x509 -noout -modulus -in agent.pem | md5sum
openssl rsa -noout -modulus -in agent-key.pem | md5sum
# Must match
- Regenerate certificate with correct key
CN/SAN Mismatch
Error:Agent certificate CN does not match agent_id
Solution:
- Check certificate CN and SAN:
openssl x509 -in agent.pem -noout -subject -ext subjectAltName
- Generate certificate with correct CN matching agent_id
Certificate Generation
# Generate agent certificate
openssl req -new -nodes -keyout agent-key.pem -out agent.csr \
-subj "/CN=agent-uuid-here/O=Tamandua"
# Sign with CA
openssl x509 -req -in agent.csr -CA ca.pem -CAkey ca-key.pem \
-CAcreateserial -out agent.pem -days 365
DNS Resolution
Symptoms
- Hostname resolution fails
- Intermittent connectivity based on DNS
- Wrong server IP returned
Diagnostic Steps
- Test resolution
nslookup server.example.com
dig server.example.com
host server.example.com
- Check resolv.conf
cat /etc/resolv.conf
Common Causes and Solutions
DNS Server Unreachable
Error:Failed to resolve hostname: server.example.com
connection timed out; no servers could be reached
Solution:
- Check DNS server:
dig @8.8.8.8 server.example.com
- Update DNS configuration:
# /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
NXDOMAIN (Host Not Found)
Error:Host server.example.com not found: NXDOMAIN
Solution:
- Verify hostname spelling
- Check if internal DNS is required
- Add to hosts file as workaround:
# /etc/hosts
10.0.1.100 server.example.com
DNS Cache Poisoning/Stale
Error:Resolved to wrong IP address
Solution:
- Flush DNS cache:
# Linux (systemd-resolved)
resolvectl flush-caches
# Windows
ipconfig /flushdns
# macOS
sudo dscacheutil -flushcache
- Lower TTL for entries that change frequently
Split-Horizon DNS Issues
Error:Different results from internal vs external
Solution:
- Configure agent to use correct DNS server
- Use IP address directly in configuration
- Verify DNS zone configuration
DNS Configuration for Agent
# Use specific DNS servers
[network]
dns_servers = ["10.0.0.53", "10.0.0.54"]
# Or use system DNS with fallback
[network]
dns_fallback = ["8.8.8.8", "1.1.1.1"]
Network Debugging Tools
tcpdump
# Capture WebSocket traffic
tcpdump -i eth0 -w capture.pcap port 4000
# Capture with filter
tcpdump -i eth0 -n 'host server.example.com and port 4000'
Wireshark Filters
# WebSocket traffic
websocket
# TLS handshake issues
ssl.handshake.type == 1 || ssl.alert_message
# Filter by server
ip.addr == 10.0.1.100 and tcp.port == 4000
ss/netstat
# Check established connections
ss -tnp | grep 4000
# Check connection states
netstat -an | grep 4000 | awk '{print $6}' | sort | uniq -c
curl Verbose Mode
# Full connection debug
curl -v --trace-ascii /dev/stdout https://server:4000/api/health
# With client certificate
curl -v --cert agent.pem --key agent-key.pem https://server:4000/api/health
Network Performance Issues
High Latency
Symptoms:- Slow response times
- Frequent timeouts
- Measure latency:
ping server.example.com
mtr server.example.com
- Increase timeouts
- Consider geographic proximity
- Use CDN for static content
Packet Loss
Symptoms:- Intermittent failures
- Retransmissions
- Measure packet loss:
ping -c 100 server.example.com | grep loss
mtr --report server.example.com
- Investigate network path
- Contact network team/ISP
MTU Issues
Error:Packet too large, fragmentation needed
Solution:
- Discover MTU:
ping -M do -s 1472 server.example.com
- Configure MSS clamping
- Adjust MTU on interfaces
Next Steps
- Agent Troubleshooting - Agent-specific issues
- Server Troubleshooting - Backend server issues
- Detection Troubleshooting - Detection rule issues
- Troubleshooting Overview - General diagnostic tools