sipeed/picoclaw · error

OneBot WebSocket not connected

Error message

OneBot WebSocket not connected

What it means

Guard in OneBotChannel.Send: fires when the channel is running but the WebSocket connection to the OneBot implementation is nil at send time (disconnected and not yet re-established). The message cannot be written, so Send returns this error.

Solutions

  1. Wait for the reconnect loop to restore the WebSocket before sending
  2. Check OneBot connectivity logs for disconnect reasons
  3. Surface a temporary error so upper layers retry
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at pkg/channels/onebot/onebot.go:416 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of sipeed/picoclaw@49183d7e8d (2026-08-15). Data as JSON: /api/errors/19f96a16572e5f1a. Report an issue: GitHub.

Appendix: source

Thrown at pkg/channels/onebot/onebot.go:416

func (c *OneBotChannel) Send(ctx context.Context, msg bus.OutboundMessage) ([]string, error) {
	if !c.IsRunning() {
		return nil, channels.ErrNotRunning
	}

	// Check ctx before entering write path
	select {
	case <-ctx.Done():
		return nil, ctx.Err()
	default:
	}

	c.mu.Lock()
	conn := c.conn
	c.mu.Unlock()

	if conn == nil {
		return nil, fmt.Errorf("OneBot WebSocket not connected")
	}

	action, params, err := c.buildSendRequest(msg)
	if err != nil {
		return nil, err
	}

	echo := fmt.Sprintf("send_%d", atomic.AddInt64(&c.echoCounter, 1))

	req := oneBotAPIRequest{
		Action: action,
		Params: params,
		Echo:   echo,
	}

	data, err := json.Marshal(req)
	if err != nil {
		return nil, fmt.Errorf("failed to marshal OneBot request: %w", err)

View on GitHub (pinned to 49183d7e8d)