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

Proper Way To Replicate DB and Access From Another Device #468

Closed
polluterofminds opened this issue Sep 28, 2018 · 5 comments
Closed

Proper Way To Replicate DB and Access From Another Device #468

polluterofminds opened this issue Sep 28, 2018 · 5 comments

Comments

@polluterofminds
Copy link

polluterofminds commented Sep 28, 2018

Great project! I can very easily log in with uPort and store data. However, it seems I am only storing data to local storage, because when I use another browser as a test of accessing from another device, I cannot open the DB created from Browser1. Here's what I'm trying:

on Browser1:

export function loadDB() {
  ipfs.on('ready', async () => {
    const orbitdb = new OrbitDB(ipfs)
    db = await orbitdb.open("/orbitdb/QmdABCZSfHpGunEEZznoWsXWcRTKgFvawVh4LSL1m8YqEd/first-database", {create: true, type: "keyvalue"})
    db.load()
    .then(() => {
      this.handleGet();
    });
  })

Note: handleGet() loads the previously stored documents, which works on Browser1. I am also passing a hard-coded orbitdb address for now as I test.

Now, on Browser2, I am trying to load the DB using the exact same code as above, but the documents I stored in Browser1 do not load. I get an empty object instead.

Any help would be greatly appreciated because I know I'm doing something wrong here. Just can't figure it out.

@m00nwtchr
Copy link

m00nwtchr commented Sep 28, 2018

Are you using js-ipfs or js-ipfs-api + go-ipfs? Because iirc js-ipfs doesn't have node discovery properly implemented yet (only in the browser) and you need to specify servers that are going to be used for that manually:

	let ipfs = new IPFS({
		EXPERIMENTAL: {
			pubsub: true
		},
		config: {
			Addresses: {
				Swarm: [
					// Use IPFS dev signal server
					// Prefer websocket over webrtc
					//
					// Local signal server
					//'/ip4/127.0.0.1/tcp/13579/ws/p2p-websocket-star',
					// Websocket:
					'/dns4/ws-star-signal-1.servep2p.com/tcp/443/wss/p2p-websocket-star',
					'/dns4/ws-star-signal-2.servep2p.com/tcp/443/wss/p2p-websocket-star',
					'/dns4/ws-star.discovery.libp2p.io/tcp/443/wss/p2p-websocket-star',
					// WebRTC:
					// '/dns4/star-signal.cloud.ipfs.team/wss/p2p-webrtc-star',
				]
			}
		}
	});

@polluterofminds
Copy link
Author

Thanks, @lukas2005! I'm using js-ipfs (I think). I went through the quick start guide instructions on OrbitDB to get started:

npm install orbit-db ipfs

So are you saying that with the configuration example you provided, you can manually specify servers with js-ipfs? And if so, are those standard websocket signaling server addresses or do I have to provide my own?

@m00nwtchr
Copy link

the node.js ipfs package is js-ipfs and yes those are the official ones. You can also run your own signal server if you want using https://github.com/libp2p/js-libp2p-websocket-star-rendezvous

@polluterofminds
Copy link
Author

Thanks a lot. I can't get it to work with that configuration, and I feel like I'm missing a step somewhere that's just not documented maybe:

webSocket connection to 'wss://ws-star-signal-1.servep2p.com/socket.io/?EIO=3&transport=websocket' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED

@polluterofminds
Copy link
Author

FYI I got this working with the following configuration:

  EXPERIMENTAL: {
        pubsub: true
      },
      config: {
        Addresses: {
          // ...And supply a swarm address to announce on to find other peers
          Swarm: [
            '/dns4/ws-star.discovery.libp2p.io/tcp/443/wss/p2p-websocket-star'
          ]
        }
      }
}```

So it just took using a different websocket address. Thanks for the help, @lukas2005!

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

3 participants