Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Message delivery not working if publisher is sending message to early after connect #483

Open
koh-osug opened this issue Jan 9, 2024 · 0 comments

Comments

@koh-osug
Copy link

koh-osug commented Jan 9, 2024

The subscribe function is called from a subscriber with node.services.pubsub.subscribe(PEER_SUBSCRIPTION_TOPIC) and the other publishing peer is sending a notification with node.services.pubsub.publish(PEER_SUBSCRIPTION_TOPIC, new Uint8Array(BSON.serialize({ipAddress: argv.ipAddress}).buffer)).
What I notice is that the publishing only works if the subscription of the other peer is know, i.e. if the publish is executed too early before the subscribe is known, publish is not doing anything and any listener node.services.pubsub.addEventListener('message', (message) => {...} is never called in the subscriber. To make it work I have to wait until the publishing peer is connected and I have to use a delay in the publisher like:

        setTimeout( () => {
            node.services.pubsub.publish(PEER_SUBSCRIPTION_TOPIC, new Uint8Array(BSON.serialize({ipAddress: argv.ipAddress}).buffer))
        }, 5000)

What is the correct way to send a message from a publisher, so that a connecting client can receive it without using this delay? is there a callback?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant