curl -X GET "http://localhost:5001/connz?offset=0&limit=50&subs=1"
const response = await fetch('http://localhost:5001/connz?offset=0&limit=50&subs=1');
const data = await response.json();
console.log(data);
import requests
params = {
'offset': 0,
'limit': 50,
'subs': 1
}
response = requests.get('http://localhost:5001/connz', params=params)
data = response.json()
print(data)
package main
import (
"encoding/json"
"fmt"
"net/http"
)
func main() {
resp, err := http.Get("http://localhost:5001/connz?offset=0&limit=50&subs=1")
if err != nil {
panic(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Printf("%+v\n", result)
}
{
"now": "2024-01-15T10:30:00Z",
"num_connections": 1250,
"total": 1250,
"offset": 0,
"limit": 50,
"connections": [
{
"cid": 12345,
"uid": "user123",
"ip": "192.168.1.100",
"port": 54321,
"start": "2024-01-15T09:15:30Z",
"last_activity": "2024-01-15T10:29:45Z",
"uptime": "1h14m15s",
"idle": "15s",
"pending_bytes": 0,
"in_msgs": 156,
"out_msgs": 203,
"in_bytes": 15680,
"out_bytes": 25440,
"subscriptions": 8,
"device_flag": 1,
"device_level": 1,
"version": "1.0.0"
}
]
}
Monitoring
Get Connection Information
Get current server connection statistics including connection count and user distribution
GET
/
connz
curl -X GET "http://localhost:5001/connz?offset=0&limit=50&subs=1"
const response = await fetch('http://localhost:5001/connz?offset=0&limit=50&subs=1');
const data = await response.json();
console.log(data);
import requests
params = {
'offset': 0,
'limit': 50,
'subs': 1
}
response = requests.get('http://localhost:5001/connz', params=params)
data = response.json()
print(data)
package main
import (
"encoding/json"
"fmt"
"net/http"
)
func main() {
resp, err := http.Get("http://localhost:5001/connz?offset=0&limit=50&subs=1")
if err != nil {
panic(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Printf("%+v\n", result)
}
{
"now": "2024-01-15T10:30:00Z",
"num_connections": 1250,
"total": 1250,
"offset": 0,
"limit": 50,
"connections": [
{
"cid": 12345,
"uid": "user123",
"ip": "192.168.1.100",
"port": 54321,
"start": "2024-01-15T09:15:30Z",
"last_activity": "2024-01-15T10:29:45Z",
"uptime": "1h14m15s",
"idle": "15s",
"pending_bytes": 0,
"in_msgs": 156,
"out_msgs": 203,
"in_bytes": 15680,
"out_bytes": 25440,
"subscriptions": 8,
"device_flag": 1,
"device_level": 1,
"version": "1.0.0"
}
]
}
Overview
Get current server connection statistics, including connection count, user distribution and other monitoring data.Query Parameters
integer
default:0
Offset for pagination
integer
default:20
Limit for pagination
integer
default:0
Whether to include subscription information
0- Do not include subscription information1- Include subscription information
curl -X GET "http://localhost:5001/connz?offset=0&limit=50&subs=1"
const response = await fetch('http://localhost:5001/connz?offset=0&limit=50&subs=1');
const data = await response.json();
console.log(data);
import requests
params = {
'offset': 0,
'limit': 50,
'subs': 1
}
response = requests.get('http://localhost:5001/connz', params=params)
data = response.json()
print(data)
package main
import (
"encoding/json"
"fmt"
"net/http"
)
func main() {
resp, err := http.Get("http://localhost:5001/connz?offset=0&limit=50&subs=1")
if err != nil {
panic(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Printf("%+v\n", result)
}
{
"now": "2024-01-15T10:30:00Z",
"num_connections": 1250,
"total": 1250,
"offset": 0,
"limit": 50,
"connections": [
{
"cid": 12345,
"uid": "user123",
"ip": "192.168.1.100",
"port": 54321,
"start": "2024-01-15T09:15:30Z",
"last_activity": "2024-01-15T10:29:45Z",
"uptime": "1h14m15s",
"idle": "15s",
"pending_bytes": 0,
"in_msgs": 156,
"out_msgs": 203,
"in_bytes": 15680,
"out_bytes": 25440,
"subscriptions": 8,
"device_flag": 1,
"device_level": 1,
"version": "1.0.0"
}
]
}
Response Fields
string
required
Current server time (ISO 8601 format)
integer
required
Current number of connections
integer
required
Total number of connections
integer
required
Current offset
integer
required
Current limit
array
required
Connection details list
Show connections fields
Show connections fields
integer
Connection ID
string
User ID
string
Client IP address
integer
Client port
string
Connection start time
string
Last activity time
string
Connection duration
string
Idle time
integer
Pending bytes to send
integer
Number of received messages
integer
Number of sent messages
integer
Number of received bytes
integer
Number of sent bytes
integer
Number of subscriptions
integer
Device flag
integer
Device level
string
Client version
Status Codes
| Status Code | Description |
|---|---|
| 200 | Successfully retrieved connection information |
| 500 | Internal server error |
Best Practices
- Paginated Queries: Use pagination for large numbers of connections to avoid performance issues
- Regular Monitoring: Set reasonable monitoring intervals, avoid excessive frequency
- Alert Mechanisms: Set alerts for key metrics like connection count and activity
- Data Export: Support export and analysis of connection data
- Performance Optimization: Monitor connection performance metrics to identify issues promptly
- Security Monitoring: Pay attention to connections from abnormal IPs

