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

I can not make browser pubsub example working - Uncaught (in promise) Error: PublishError.InsufficientPeers #70

Open
scenaristeur opened this issue Nov 3, 2023 · 4 comments

Comments

@scenaristeur
Copy link
Contributor

I'm on Linux Mint 21.2 Cinnamon 5.15.0-87-generic #97-Ubuntu SMP Mon Oct 2 21:09:21 UTC 2023 x86_64 GNU/Linux
node V18.18.0

js-libp2p-examples@1.0.0 /home/smag/dev/js-libp2p-examples
└─┬ @libp2p/example-browser-pubsub@1.0.0 -> ./examples/js-libp2p-example-browser-pubsub
├── @chainsafe/libp2p-gossipsub@10.1.0
├── @chainsafe/libp2p-noise@13.0.2
├── @chainsafe/libp2p-yamux@5.0.0
├── @libp2p/webrtc@3.2.5
├── @libp2p/websockets@7.0.10
├── @multiformats/multiaddr@12.1.8
├── libp2p@0.46.16
├── test-ipfs-example@1.1.0
└── vite@4.5.0

image

@silkroadnomad
Copy link

silkroadnomad commented Nov 6, 2023

I can confirm. Your screenshot says, you do not have any "topic peers". This means if you post a message to pubsub without peers you get the error "insufficient peers"

In my case its the exact same problem. I am subscribing to the topic, but I don't get any topic peers. If I hit the "subscribe to topic" button about 5-10 times fast after another, I suddenly receive a sdp (WebRTC) error message:

initiate-connection.ts:75 Uncaught (in promise) CodeError: SDP handshake aborted
    at AbortSignal.sdpAbortedListener (initiate-connection.ts:75:31)
    at AbortSignal.onAbort (index.ts:14:16)
    at AbortSignal.onAbort (index.ts:14:16)

and 

dial-queue.ts:253 Uncaught (in promise) CodeError: The task was aborted.
    at dial-queue.ts:253:25
    at async DefaultConnectionManager.openConnection (index.ts:517:24)
    at async HTMLButtonElement.dialMultiaddrButton (+page.svelte:127:36)

SDP means probably that both peers (both browsers) cannot connect via WebRTC to each other.
I was using Opera and Firefox for that test. Brave gives the same error message after first subscribing.

@silkroadnomad
Copy link

silkroadnomad commented Nov 6, 2023

might be related. Mentioned fixes libp2p/js-libp2p#2179
(e.g. upgraded to libp2p@0.46.20) didn't seem to help.

Looks like it only works between chrome based browsers e.g. between Brave, Opera and Chrome.
I tested it first with Firefox (as you) but something is going the wrong way here.

If you run the test inside the example directory like
npm run test:firefoxthis test also crashes.

In the browser console in firefox now I receive a:

webRTC: ICE failed, add a STUN server and see about:webrtc for more details 
Uncaught (in promise) CodeError: RTCPeerConnection was closed
    CodeError errors.ts:29
    <anonymous> util.ts:106
    Firefox can’t establish a connection to the server at ws://127.0.0.1:60326/p2p/12D3KooWRzj9vTiyzPt48iHECnzaJygBUyPjHfX97ZcRjTUuhgSW.
´´´

@sOniri
Copy link

sOniri commented Dec 6, 2023

I tried without using webrtc and only the websocket address and I get the same error "insufficient peers" . It seems that when using circuit-relay with websocket produces this error . when using webrtc in chrome it works . The same applies when running in node and not the browser .

@3mg
Copy link

3mg commented Jan 4, 2024

I faced the same error. In my case, the reason was that Firefox does not normally support webrtc on the localhost domain. After changing the hostname to anything else the error had disappeared.

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

4 participants