RangerMauve / hyperswarm-web

Implementation of the hyperswarm API for use in web browsers
MIT License
102 stars 15 forks source link

Slow discovery of peers on localhost #7

Open pasqui23 opened 3 years ago

pasqui23 commented 3 years ago

I have an application that emits peer events very slowly. As in,if I open 2 tabs in the same browser,the second tabs discover the first after a few minutes,but the fist discover the second after a few hours.

RangerMauve commented 3 years ago

Could you try testing version 2.0.1 to see if it's better?

tinchoz49 commented 3 years ago

Hey @RangerMauve, sorry, are you sure was published? https://www.npmjs.com/package/hyperswarm-web I cannot see it in versions

RangerMauve commented 3 years ago

@tinchoz49 Whoops, I must have forgotten to publish after tagging. Try 2.0.2 instead. 😅

pasqui23 commented 3 years ago

Updated to 2.0.2,still having the same problem

RangerMauve commented 3 years ago

Weird. Lets debug this a bit further.

  1. Are you getting anything interesting in the dev tools? Like errors or warning messages.
  2. Are connections actually being made to the signalling servers?
  3. What browser version are you using?
  4. What data are you trying to replicate?
pasqui23 commented 3 years ago
  1. No,no message at all
  2. I have bootstrap:["ws://localhost:4799"],how do I check it?
  3. Chromium 83.0.4103.116 4: WHat you need toknow exactly?
tinchoz49 commented 3 years ago

Hey @pasqui23, it could be helpful a demo repository with your failing test, we can try to find the issue from that point.

pasqui23 commented 3 years ago

https://github.com/pasqui23/.hswm-bug

tinchoz49 commented 3 years ago

https://github.com/pasqui23/.hswm-bug gets 404

pasqui23 commented 3 years ago

It's a private repo,now you should be able to open it.

tinchoz49 commented 3 years ago

thank you

tinchoz49 commented 3 years ago

https://github.com/pasqui23/.hswm-bug/blob/master/src/index.js#L29

there is a typo in the bootstrap url, it should be: ws://localhost:4977

pasqui23 commented 3 years ago

I'm using it without TLS,wouldn't break oon wss?

tinchoz49 commented 3 years ago

I didn't write wss..

You wrote localost, should be localhost

pasqui23 commented 3 years ago

The risks of programming at midnight ...

pasqui23 commented 3 years ago

Fixed typo,but discovery is still slow

pasqui23 commented 3 years ago

Still important to me and I don't know how to start debugging hyperswarm.Any tips,@tinchoz49 @RangerMauve ?

tinchoz49 commented 3 years ago

I don't see the slow discovery

Peek 2020-09-15 11-19

RangerMauve commented 3 years ago

I don't have time at the moment to look too deeply into this due to work, but you could try setting up breakpoints inside the simple peer code to see if you're actually getting peers through it.

pasqui23 commented 3 years ago

It looks like the _onIceCandidate ( https://github.com/feross/simple-peer/blob/0dd27ee83d615a8ff0eb48c49ed4917c9d6e2ff1/index.js#L904 ) method fires several times without discovering any peer,is that normal?

tinchoz49 commented 3 years ago

which browser are you using?

pasqui23 commented 3 years ago

@tinchoz49 still the same.I'm debuuging using VSCode's Debugger for chrome extension

tinchoz49 commented 3 years ago

I cannot reproduce your error, in chrome I get a connection in less of 1 second: https://github.com/RangerMauve/hyperswarm-web/issues/7#issuecomment-692747458

pasqui23 commented 3 years ago

@RangerMauve where do you suggest I put breakpoints? My selection of breakpoints interrupts right after continuing from the previous breakpoint.

pasqui23 commented 3 years ago

I suspect it's something with [https://en.wikipedia.org/wiki/Internet_in_Italy](Italian Internet) as other people in Italy could replicate the problem.

pasqui23 commented 3 years ago

@RangerMauve I did set up a breakpoint on Peer._onIceCandidate and it did fire up but still no discovery The about:webrtc of this session so that someone more familiar with webrtc can look it up.

RangerMauve commented 3 years ago

You could try setting up custom TURN servers for your app with a service like XirSys to improve browser-to-browser connectivity. Else you might want to find a consultant that can figure out why WebRTC isn't working for you. 😅