Skip to content

Subsequent calls to subscribeMany? #484

@tfreedman

Description

@tfreedman

I've created a SimplePool, connected to some relays, and then queried some notes before receiving an EOSE event. In response to the notes I've received, I'd like to see if they have comments:

Fetch some threads

  window.pool = new window.NostrTools.SimplePool()

  let h = window.pool.subscribeMany(
    relays,[
      {kinds: [1], '#t': ["whatever"]} // Fetch threads
    ],
    {
      onevent(event) {
          doSomething(event);
        }
      },
      oneose() {
         // Leave the connection open
        // h.close()
      }
    }
  )

Later on....

Fetch the comments on those earlier threads

      let h = window.pool.subscribeMany(
        relays,[
          {kinds: [1], '#e': [whatever, "", "root"]} // Load the comments on those threads we received earlier
        ],
        {
          onevent(event) {
            doSomething(event);
          },
          oneose() {
            // h.close();
          }
        }
      )
    }

With my sample code, using subscribeMany again on the previous pool appears to open a new connection to the relay, and then my test relay bans me for having too many connections (presumably one connection per note received in the first part), so 30 notes means 31 connections. How are you supposed to re-use the same connection to request additional data?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions