会话类型
文档会话类型

会话类型

轮换代理在每次请求时更改 IP。粘性会话在可配置的时间窗口内保持相同的 IP。以下是两者的使用方法。

轮换会话

默认模式。每个请求通过池中的不同 IP 路由。不需要额外的用户名参数 — 只需使用端口 823 (HTTP) 或 824 (SOCKS5)。

cURL — rotating (default)
curl -x http://USERNAME:PASSWORD@proxy.raxyproxy.com:823 https://httpbin.org/ip

Best for: 大规模抓取、价格监控、广告验证、任何以 IP 多样性为目标的任务。

粘性会话 — 基于端口

连接到 10000–20000 范围内的任何端口。每个端口在该端口连接槽的生命周期内映射到固定 IP。相同的端口始终返回相同的 IP — 不需要额外的用户名参数。

cURL — sticky port 10001
curl -x http://USERNAME:PASSWORD@proxy.raxyproxy.com:10001 https://httpbin.org/ip
# Every request on port 10001 returns the same IP
Python — multiple sticky slots
import requests

proxies_list = [
    f"http://USERNAME:PASSWORD@proxy.raxyproxy.com:{port}"
    for port in range(10001, 10011)  # 10 independent sticky slots
]

for i, proxy_url in enumerate(proxies_list):
    r = requests.get("https://httpbin.org/ip", proxies={"http": proxy_url, "https": proxy_url})
    print(f"Slot {i}: {r.json()['origin']}")

Best for: 并行运行多个独立会话(例如 50 个抓取工作器,每个都有自己的持久 IP)。

粘性会话 — 会话 ID

在用户名后附加__sessid.YOURSTRING。相同的会话字符串始终解析为相同的 IP,持续约 30 分钟(可通过sessttl配置)。这适用于标准端口(823/824)。

cURL — sessid sticky
# session "checkout-user-42" will always get the same IP
curl -x http://USERNAME__sessid.checkout-user-42:PASSWORD@proxy.raxyproxy.com:823 \
     https://httpbin.org/ip
Python — sessid sticky
import requests

session_id = "user-session-abc123"

proxies = {
    "http":  f"http://USERNAME__sessid.{session_id}:PASSWORD@proxy.raxyproxy.com:823",
    "https": f"http://USERNAME__sessid.{session_id}:PASSWORD@proxy.raxyproxy.com:823",
}

# All requests with the same session_id use the same IP
r1 = requests.get("https://httpbin.org/ip", proxies=proxies)
r2 = requests.get("https://httpbin.org/ip", proxies=proxies)
print(r1.json(), r2.json())  # same IP

会话 ID 格式

会话字符串可以是任何字母数字字符串。使用有意义的名称(例如 user-42task-abc)在代码中跟踪会话。

Best for: 登录流程、多步骤结账、表单提交、需要在多个请求中保持持久状态的 AI 代理。

会话时长 — sessttl

住宅IP可能随时下线 — 我们建议会话时长保持在30分钟以内以确保可靠性。您可以使用120分钟以内的更长时长,通过sessttl进行设置,但不能保证整个时间窗内始终使用相同IP。

cURL — sessid + custom TTL (60 min)
curl -x http://USERNAME__sessid.mysession;sessttl.60:PASSWORD@proxy.raxyproxy.com:823 \
     https://httpbin.org/ip

参数顺序

组合sessidsessttl时,使用分号分隔它们:__sessid.ID;sessttl.MINUTES。不要将sessttl放在 sessid 之前。

比较

功能轮换粘性 — 端口粘性 — sessid
端口823 / 82410000–20000823 / 824
IP 变更每次请求每端口(持久)按sessttl(建议≤30分钟)
用户名更改Append __sessid.ID
并行会话无限每端口一个(最多 10,001 个槽)无限(每个唯一 ID 一个)
最适合批量抓取多个独立工作流单用户会话 / 身份验证流程

从 AI 代理使用会话类型?

RaxyProxy Claude Code skill自动生成轮换或粘性代理字符串 — 包括会话 ID 和地理定位 — 无需手动构建用户名格式。使用npx skills add raxyproxy/skills安装。