Files
proxycast/scripts/test-ws-connection.mjs
T
coso cd95cac72f feat: release v0.74.0 - Chrome Bridge 浏览器自动化集成
🎉 重大功能
- Chrome Bridge: 完整的浏览器自动化控制系统
- 零配置自动连接:扩展自动加载和配置
- AI 原生集成:作为 MCP 工具支持自然语言控制
- 支持导航、页面读取、元素交互、表单操作等

🐛 Bug 修复
- WebSocket 路由修复 (Axum 路径参数语法)
- Chrome 扩展存储清理
- 扩展重复注入防护
- 剪贴板权限添加

🔧 代码质量
- 修复 33+ Clippy 警告
- 所有 259 个测试通过
- ESLint 无警告

📝 文档
- Chrome Bridge 使用指南
- API 技术文档
- 快速参考卡片
2026-02-28 16:05:36 +08:00

41 lines
1.0 KiB
JavaScript

#!/usr/bin/env node
import WebSocket from 'ws';
const serverUrl = 'ws://127.0.0.1:8999';
const bridgeKey = 'Proxycast-key11';
const profileKey = 'search_google';
const url = `${serverUrl}/proxycast-chrome-observer/${encodeURIComponent(bridgeKey)}?profileKey=${encodeURIComponent(profileKey)}`;
console.log(`[测试] 连接 URL: ${url}`);
const ws = new WebSocket(url);
ws.on('open', () => {
console.log('[测试] ✅ WebSocket 连接成功');
// 发送心跳
const heartbeat = JSON.stringify({ type: 'heartbeat' });
console.log(`[测试] 发送心跳: ${heartbeat}`);
ws.send(heartbeat);
setTimeout(() => {
console.log('[测试] 关闭连接');
ws.close();
}, 2000);
});
ws.on('message', (data) => {
console.log('[测试] 收到消息:', data.toString());
});
ws.on('error', (error) => {
console.error('[测试] ❌ WebSocket 错误:', error.message);
});
ws.on('close', (code, reason) => {
console.log(`[测试] 连接关闭: code=${code}, reason=${reason.toString()}`);
process.exit(code === 1000 ? 0 : 1);
});