examples/ecaptureq_client/TESTING.md
This guide helps you test the ecaptureq WebSocket client with a running eCapture instance.
cd examples/ecaptureq_client
go build -o ecaptureq_client main.go
In one terminal, start eCapture with the --ecaptureq parameter:
# Option A: Listen on localhost (most secure for testing)
sudo ./ecapture tls --ecaptureq=ws://127.0.0.1:28257/
# Option B: Listen on specific network interface
sudo ./ecapture tls --ecaptureq=ws://192.168.1.100:28257/
Important Notes:
/ (trailing slash)127.0.0.1 or your machine's IP0.0.0.0 - it won't work!localhost:28256You should see output like:
2025-01-15T10:30:45Z INF AppName="eCapture(旁观者)"
2025-01-15T10:30:45Z INF Listen for eCaptureQ=ws://127.0.0.1:28257
In another terminal, check that the WebSocket port is listening:
netstat -tlnp | grep 28257
# Should show:
# tcp 0 0 127.0.0.1:28257 0.0.0.0:* LISTEN <pid>/ecapture
If you don't see this, check:
/)0.0.0.0In a third terminal, run the client:
cd examples/ecaptureq_client
# Basic connection
./ecaptureq_client -server ws://127.0.0.1:28257/
# With verbose mode (shows heartbeats)
./ecaptureq_client -server ws://127.0.0.1:28257/ -verbose
You should immediately see:
Connecting to eCapture WebSocket server at ws://127.0.0.1:28257/
Connected successfully!
2025-01-15T10:30:45Z INF AppName="eCapture(旁观者)"
2025-01-15T10:30:45Z INF HomePage=https://v2.ecapture.cc
...
Now generate some SSL/TLS traffic to capture:
# In a fourth terminal
curl https://www.baidu.com
curl https://www.google.com
wget https://www.github.com
In the client terminal, you should see captured events like:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🔍 Captured Event
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🆔 UUID: 12345_12345_curl_5_1_192.168.1.100:54870-180.101.49.44:443
🔢 PID: 12345
📝 Process: curl
🔗 Source: 192.168.1.100:54870
🎯 Destination: 180.101.49.44:443
📊 Type: 1
📏 Length: 104 bytes
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📦 Payload:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
GET / HTTP/1.1
Host: www.baidu.com
Accept: */*
User-Agent: curl/7.81.0
Base64 encoded:
R0VUIC8gSFRUUC8xLjENCkhvc3Q6IHd3dy5iYWlkdS5jb20NCkFjY2VwdDogKi8qDQpVc2VyLUFnZW50OiBjdXJsLzcuODEuMA0KDQo=
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Cause: Server not running or wrong URL
Solutions:
ps aux | grep ecapturenetstat -tlnp | grep 28257/Cause: URL format issue or server not ready
Solutions:
/: ws://127.0.0.1:28257/ ✅ not ws://127.0.0.1:28257 ❌Cause: No traffic to capture or wrong filters
Solutions:
curl https://www.baidu.com./ecaptureq_client -verbose to see heartbeatsCause: eCapture terminated or network issue
Solutions:
# Terminal 1
sudo ./ecapture tls --ecaptureq=ws://127.0.0.1:28257/
# Terminal 2
./ecaptureq_client -server ws://127.0.0.1:28257/
# Terminal 3
curl https://www.baidu.com
# Terminal 1 (on server machine, IP 192.168.1.100)
sudo ./ecapture tls --ecaptureq=ws://192.168.1.100:28257/
# Terminal 2 (on client machine or same machine)
./ecaptureq_client -server ws://192.168.1.100:28257/
# Terminal 3
curl https://www.github.com
# Terminal 1
sudo ./ecapture tls --ecaptureq=ws://127.0.0.1:28257/
# Terminal 2
./ecaptureq_client -server ws://127.0.0.1:28257/ -verbose
# You should see heartbeat messages every 60 seconds
# Terminal 1
sudo ./ecapture tls --ecaptureq=ws://127.0.0.1:28257/
# Terminal 2
./ecaptureq_client -server ws://127.0.0.1:28257/
# Terminal 3
./ecaptureq_client -server ws://127.0.0.1:28257/
# Both clients receive the same events!
-verbose)To integrate this into your own application:
// See main.go for full example
import (
pb "github.com/gojue/ecapture/protobuf/gen/v1"
"golang.org/x/net/websocket"
"google.golang.org/protobuf/proto"
)
ws, _ := websocket.Dial("ws://127.0.0.1:28257/", "", "http://localhost/")
defer ws.Close()
for {
var msgData []byte
websocket.Message.Receive(ws, &msgData)
var logEntry pb.LogEntry
proto.Unmarshal(msgData, &logEntry)
// Handle logEntry based on logEntry.LogType
}
When done testing:
Ctrl+CCtrl+C in the eCapture terminalrm examples/ecaptureq_client/ecaptureq_client
If you encounter issues not covered here, please: