Skip to content

[BUG] v0.2.5 WebSocket connect fail #2319

@axwfae

Description

@axwfae

Quick Summary

WebSocket connect fail

Environment & Tools

  • PicoClaw Version: v.0.2.5
  • Go Version: (e.g., go 1.22)
  • AI Model & Provider: (e.g., GPT-4o via OpenAI / DeepSeek via SiliconFlow)
  • Operating System: (e.g., Ubuntu 22.04 / macOS / Android Termux)
  • Channels: (e.g., Discord, Telegram, Feishu, ...)

📸 Steps to Reproduce

  1. v0.2.4 WebSocket connect ok
  2. set launcher_token fix to 'clawtestoken"
  3. v0.2.5 WebSocket connect fail

❌ Actual Behavior

PicoClaw Chrome Extension Connection Issue - Bug Report

Environment

  • PicoClaw Version: 0.2.5
  • Chrome Extension Version: 1.0.56
  • NAS Docker: Running on local network (192.168.1.200)
  • Gateway Port: 18790
  • Launcher/API Port: 18800

Current Configuration

  • Dashboard Token (launcher_token): clawtestoken
  • Pico Token (from /api/pico/token): b9825e6b35e5a67444e795c2547a5110
  • Gateway PID Token (from ~/.picoclaw/.picoclaw.pid): 5713189781afdcf865a26f273fbcf1fe

Problem Description

The Chrome extension cannot connect to the PicoClaw WebSocket server (both via Gateway port 18790 and Launcher port 18800). All authentication attempts fail with various HTTP errors.

Test Results

Test 1: Direct to Gateway (18790) - Simple Token

GET /pico/ws
Sec-Websocket-Protocol: token.b9825e6b35e5a67444e795c2547a5110

Result: 401 Unauthorized

Test 2: Direct to Gateway (18790) - Composed Token

GET /pico/ws
Sec-Websocket-Protocol: token.pico-5713189781afdcf865a26f273fbcf1feb9825e6b35e5a67444e795c2547a5110

Result: 400 Bad Request

Test 3: Via Launcher (18800) - Simple Token

GET /pico/ws
Authorization: Bearer clawtestoken
Sec-Websocket-Protocol: token.b9825e6b35e5a67444e795c2547a5110

Result: 400 Bad Request

Test 4: Via Launcher (18800) - Composed Token

GET /pico/ws
Authorization: Bearer clawtestoken
Sec-Websocket-Protocol: token.pico-5713189781afdcf865a26f273fbcf1feb9825e6b35e5a67444e795c2547a5110

Result: 403 Forbidden - "Invalid Pico token"

Test 5: Via Launcher (18800) - Dashboard Auth Only

GET /pico/ws?token=clawtestoken

Result: 302 Found (redirects to /launcher-login)

Expected Behavior

  1. Either direct connection to Gateway (18790) should work with the simple picoToken
  2. Or connection via Launcher (18800) should work when public=true is set

Code Analysis

Gateway Authentication (pkg/channels/pico/pico.go)

The authenticate() function accepts three methods:

  1. Authorization: Bearer
  2. Sec-Websocket-Protocol: token.
  3. Query parameter token (only if AllowTokenQuery is enabled)

But the token stored in config appears to be overwritten to pico-{pidToken}{picoToken} at gateway startup.

Launcher Proxy (web/backend/api/pico.go)

The launcher proxy validates the token via picoComposedToken() which requires:

  • Client sends: token.prefix+picoToken
  • Launcher looks up: gateway.picoToken
  • Launcher expects: tokenPrefix + gateway.picoToken == client token
  • If match, transforms to: pico.PicoTokenPrefix + gateway.pidData.Token + gateway.picoToken

Questions for PicoClaw Team

  1. Authentication Scheme: What is the correct authentication method for external clients (Chrome extension) to connect to the WebSocket?

  2. Token Format: Should clients use:

    • Simple token: token.{picoToken} (e.g., token.b9825e6b35e5a67444e795c2547a5110)
    • Composed token: token.pico-{pidToken}{picoToken} (e.g., token.pico-5713189781afdcf865a26f273fbcf1feb9825e6b35e5a67444e795c2547a5110)
  3. Gateway vs Launcher: Should clients connect directly to Gateway (18790) or through Launcher (18800)?

  4. Public Mode: When launcher is set to public: true, should /pico/ws be accessible without authentication?

  5. Breaking Change: This is a breaking change from older versions where only picoToken was needed. Is this intentional?

How to Reproduce

  1. Start PicoClaw Docker with ports 18790 (gateway) and 18800 (launcher)
  2. Configure launcher with Dashboard Token
  3. Enable Pico channel and get picoToken via /api/pico/token
  4. Attempt WebSocket connection from external client
  5. All authentication methods fail

Additional Notes

  • The old PicoClaw version worked with just the simple picoToken
  • The new version requires some additional authentication that is not clearly documented
  • PID token changes on every gateway restart, making it difficult for clients to connect

✅ Expected Behavior

v0.2.4 old

Image

💬 Additional Context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions