arj03 / ssb-browser-core

ssb-server in a browser
Other
50 stars 8 forks source link

testing replication #43

Closed nichoth closed 3 years ago

nichoth commented 3 years ago

Hello. I'm getting a simple demo running. I was wondering how I should go about testing the replication.

It seems like I could start 2 sbot instances in the same browser process, giving each one different config for where to store the db, then call .net.connect, passing the address for one sbot. But what would the address be in this case?

Was wondering what is the best way to do this

arj03 commented 3 years ago

The way I have been testing this in browser demo is to have 2 browsers, could be 2 incognito modes or a chrome and a firefox. Then you basically create a follow messages on one of the browsers for the other identity. Do the same with the other browser. After that if you connect to the same room. You can use the one in browser demo, then the two browsers should start exchanging messages.

nichoth commented 3 years ago

Thanks @arj03 . It all makes sense to me except the part

After that if you connect to the same room.

I'm not really familiar with the 'rooms' idea.

arj03 commented 3 years ago

So a room is basically a server that multiple peers can connect to. The room will faciliate e2e encrypted tunnels between the peers. This means that it won't have any trouble with hole punching and all of that stuff. This is an address to a room that works in the browser: https://github.com/arj03/ssb-browser-demo/blob/e935636feaddd6d13868a104a2ea0fdb3c176bff/defaultprefs.json#L12

So you basically connect both clients to that using something like: https://github.com/arj03/ssb-browser-demo/blob/master/ui/connections.js

arj03 commented 3 years ago

As you can see @nichoth we now support DHT, so that might be another option. If you look at the linked PRs you can see how to try that out if you want.

nichoth commented 3 years ago

Thanks for the advice. I've starting working on making some automated tests that do this, using browser-run -- https://github.com/nichoth/ssb-browser-demo/blob/071676bdeb3b66724feff781be2e50a74979ef5d/test/test.js . I think it will work. the part left to do is to send a message from the two 'browser' processes into the node process with the public keys so they can follow each other. Also should run a local room server maybe.

The part that doesn't work that bothers me is that the process doesn't end. I've tried calling end on the browser stream but it wont work. So you have to press control-c when its done. 🤷