openclaw - 💡(How to fix) Fix Nostr channel: WebSocket subscriptions fail with timeout/connection refused [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#55409Fetched 2026-04-08 01:39:52
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

Error Message

[default] Nostr error (subscription): Subscription closed: connection timed out, connection timed out, connection timed out

Fix Action

Workaround

None found. The channel is currently unusable.

RAW_BUFFERClick to expand / collapse

Bug Description

The Nostr channel plugin fails to maintain WebSocket subscriptions. It connects to relays successfully, but subscriptions close immediately with timeout/connection errors, causing an infinite restart loop.

Environment

  • OpenClaw version: 2026.3.2
  • Plugin: @openclaw/[email protected]
  • nostr-tools: 2.23.3
  • Node: v25.7.0
  • OS: Linux 6.17.0-19-generic (x64)

Steps to Reproduce

  1. Enable the Nostr plugin: `openclaw plugins enable nostr`
  2. Configure in openclaw.json: ```json "nostr": { "enabled": true, "privateKey": "nsec1...", "relays": ["wss://relay.damus.io", "wss://nos.lol", "wss://relay.nostr.band"], "dmPolicy": "allowlist", "allowFrom": ["npub1..."], "name": "TestBot" } ```
  3. Restart gateway: `openclaw gateway restart`

Expected Behavior

The Nostr provider should maintain WebSocket subscriptions to receive DMs (kind:4 events).

Actual Behavior

Logs show: ``` [default] Nostr provider started, connected to 3 relay(s) [default] auto-restart attempt 1/10 in 5s [default] Nostr error (subscription): Subscription closed: connection timed out, connection timed out, connection timed out ```

The pattern repeats indefinitely:

  1. Connects to relays ✓
  2. Subscription fails within 3 seconds ✗
  3. Auto-restart with exponential backoff
  4. Repeats

Evidence

Manual WebSocket Test

Using nostr-tools directly, subscriptions work: ```javascript const { SimplePool } = require('nostr-tools/pool'); const pool = new SimplePool(); const sub = pool.subscribeMany(['wss://relay.damus.io'], [{kinds: [4], '#p': [pubkey], limit: 1}], { oneose: () => console.log('EOSE received') }); // EOSE received successfully ```

This suggests the issue is in how the OpenClaw plugin constructs/manages subscriptions, not in relay connectivity.

Relays Tested

  • wss://relay.damus.io
  • wss://nos.lol
  • wss://relay.nostr.band
  • wss://nostr.wine
  • wss://relay.primal.net
  • wss://offchain.pub
  • wss://nostr.einundzwanzig.de
  • wss://relay.nostr.ch

All exhibit the same behavior.

Additional Context

  • TCP connectivity to relays works (port 443 reachable)
  • Manual tests with nostr-tools show relays respond correctly
  • The plugin's `pool.subscribeMany` call in `nostr-bus.ts` seems to produce subscription requests that relays reject or timeout on

Potential Causes

  1. Filter format incompatibility with relay expectations
  2. WebSocket connection lifecycle management issue
  3. Subscription not properly awaiting connection ready state
  4. Relay-specific NOTICE responses not being handled

Workaround

None found. The channel is currently unusable.

extent analysis

Fix Plan

To resolve the Nostr channel plugin issue, we need to modify the nostr-bus.ts file to properly handle WebSocket connections and subscription requests. Here are the steps:

  • Update the pool.subscribeMany call to include a filter option that correctly formats the filter for relay expectations.
  • Implement a retry mechanism for subscription requests to handle potential connection timeouts.
  • Ensure the subscription request awaits the connection ready state before sending the request.

Example code changes:

// nostr-bus.ts
import { SimplePool } from 'nostr-tools/pool';

// ...

const pool = new SimplePool();
const filter = {
  kinds: [4],
  '#p': [pubkey],
  limit: 1,
};

// Update subscribeMany call with filter option
const sub = pool.subscribeMany(['wss://relay.damus.io'], [filter], {
  oneose: () => console.log('EOSE received'),
  // Add retry mechanism for subscription requests
  retry: {
    attempts: 3,
    delay: 5000,
  },
});

// Ensure subscription request awaits connection ready state
pool.on('connect', () => {
  sub.send();
});

Additionally, consider updating the nostr-tools version to the latest available to ensure compatibility with the relays.

Verification

To verify the fix, restart the OpenClaw gateway and check the logs for successful subscription connections. You can also use the manual WebSocket test to confirm that the subscription requests are being handled correctly.

Extra Tips

  • Monitor the relay responses to ensure they are handling the updated subscription requests correctly.
  • Consider implementing additional logging to track subscription request failures and successes.
  • Review the nostr-tools documentation to ensure the SimplePool class is being used correctly.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING