curl -X POST "http://localhost:5001/conn/kick" \
-H "Content-Type: application/json" \
-d '{
"uid": "user123",
"conn_id": 12345,
"node_id": 1
}'
const response = await fetch('http://localhost:5001/conn/kick', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
uid: 'user123',
conn_id: 12345,
node_id: 1
})
});
const data = await response.json();
console.log(data);
import requests
data = {
"uid": "user123",
"conn_id": 12345,
"node_id": 1
}
response = requests.post('http://localhost:5001/conn/kick', json=data)
result = response.json()
print(result)
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
data := map[string]interface{}{
"uid": "user123",
"conn_id": 12345,
"node_id": 1,
}
jsonData, _ := json.Marshal(data)
resp, err := http.Post(
"http://localhost:5001/conn/kick",
"application/json",
bytes.NewBuffer(jsonData),
)
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)
}
{
"status": "ok"
}
连接管理
踢出连接
踢出/断开指定用户的连接
POST
/
conn
/
kick
curl -X POST "http://localhost:5001/conn/kick" \
-H "Content-Type: application/json" \
-d '{
"uid": "user123",
"conn_id": 12345,
"node_id": 1
}'
const response = await fetch('http://localhost:5001/conn/kick', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
uid: 'user123',
conn_id: 12345,
node_id: 1
})
});
const data = await response.json();
console.log(data);
import requests
data = {
"uid": "user123",
"conn_id": 12345,
"node_id": 1
}
response = requests.post('http://localhost:5001/conn/kick', json=data)
result = response.json()
print(result)
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
data := map[string]interface{}{
"uid": "user123",
"conn_id": 12345,
"node_id": 1,
}
jsonData, _ := json.Marshal(data)
resp, err := http.Post(
"http://localhost:5001/conn/kick",
"application/json",
bytes.NewBuffer(jsonData),
)
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)
}
{
"status": "ok"
}
概述
踢出/断开指定用户的特定连接,与移除连接类似,但通常用于主动断开活跃连接。请求体
用户 ID
连接 ID
节点 ID,指定特定节点上的连接
curl -X POST "http://localhost:5001/conn/kick" \
-H "Content-Type: application/json" \
-d '{
"uid": "user123",
"conn_id": 12345,
"node_id": 1
}'
const response = await fetch('http://localhost:5001/conn/kick', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
uid: 'user123',
conn_id: 12345,
node_id: 1
})
});
const data = await response.json();
console.log(data);
import requests
data = {
"uid": "user123",
"conn_id": 12345,
"node_id": 1
}
response = requests.post('http://localhost:5001/conn/kick', json=data)
result = response.json()
print(result)
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func main() {
data := map[string]interface{}{
"uid": "user123",
"conn_id": 12345,
"node_id": 1,
}
jsonData, _ := json.Marshal(data)
resp, err := http.Post(
"http://localhost:5001/conn/kick",
"application/json",
bytes.NewBuffer(jsonData),
)
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)
}
{
"status": "ok"
}
响应字段
操作状态,成功时返回
"ok"状态码
| 状态码 | 说明 |
|---|---|
| 200 | 连接踢出成功 |
| 400 | 请求参数错误 |
| 404 | 连接不存在 |
| 500 | 服务器内部错误 |
与移除连接的区别
| 操作 | 接口 | 用途 | 特点 |
|---|---|---|---|
| 踢出连接 | /conn/kick | 主动断开活跃连接 | 会发送断开通知给客户端 |
| 移除连接 | /conn/remove | 清理连接记录 | 直接清理服务器端连接记录 |
⌘I

