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

Using OrbitDB offline? #367

Closed
maxkerp opened this issue May 17, 2018 · 3 comments
Closed

Using OrbitDB offline? #367

maxkerp opened this issue May 17, 2018 · 3 comments

Comments

@maxkerp
Copy link

maxkerp commented May 17, 2018

Hi there,

I don't know if this is a orbit-db question or a js-ipfs question, but I came across an error which prohibits me from using orbit-db offline. When creating the ipfs node configured to use the dev signal server, I get an error an the node is never created, thus making it impossible to use orbit-db. This is the config:

Addresses: {
  Swarm: [
    // Use IPFS dev signal server
    // '/dns4/star-signal.cloud.ipfs.team/wss/p2p-webrtc-star',
    '/dns4/ws-star.discovery.libp2p.io/tcp/443/wss/p2p-websocket-star',
    // Use local signal server
    // '/ip4/127.0.0.1/tcp/1337/ws/p2p-webrtc-star'
  ]
}

I created an issue here libp2p/js-libp2p-websockets#74
This is the error: WebSocket Error wss://ws-star.discovery.libp2p.io/socket.io

So my question is:
How would I go about creating a node and instantiating orbit-db using it offline, and connecting to the rest of the network at a later time?

With an empty Swarm: [] array, working offline is working just fine Catching the error isn't the problem, but connecting to the network at a later time seems to be.

@haadcode
Copy link
Member

In general, we don't have great primitives yet for going offline/online manually at the moment. We've talked about them in the past but so far none had the need for such functionality. Having functionality to get a db go offline/online at will shouldn't be hard to build but afaik none's looked at what exactly would be required.

As for your particular example and error, sounds to me that something happened with the dev server infrastructure or code as it's giving you an actual error at connect. Hopefully ppl in the issue you opened (thank you!) will be able to give some insight to what happened.

Meanwhile, you can try to run a local signal-sever with https://github.com/libp2p/js-libp2p-websocket-star-rendezvous (this is afaik the same as what's running on the libp2p dev server) and see if that's any different. If not, it may be a code bug (and nothing to do with the dev server infrastructure).

As for how to start offline and then connect: iirc we currently always start pubsub internally in OrbitDB, so it may not be possible to strictly "start offline" with IPFS (tbh I haven't tried this in a very long time). It may be possible to workaround that by starting the IPFS node "online" as you do now, leave the Swarm array empty (don't connect to anyone at start), run OrbitDB normally and then in your app-level code call ipfs.swarm.connect(<signal server address>) which would then connect to the signal server and connect to other peers. Not sure if this works, but this is how I would try it.

That said, it'd be great to add this to the backlog of features and functionality so that we some day can provide something simple like db.connect()/.disconnect() or similar.

@maxkerp
Copy link
Author

maxkerp commented May 18, 2018

Thanks a lot for your quick response!

This helps me a lot. I tried looking for a repo with the dev signal server setup, but there are just so many repos under libp2p and I didn't come across this one. I would love to hear that this functionality made it into the backlog 👍 . With this information, it shouldn't be too difficult to add this to my code. I'll tell you if its working.

@aphelionz
Copy link
Member

Hi @maxkerp! Just wanted to let you know that thanks to your issue and thoughtful question, we were able to address this in the new OrbitDB Field Manual!

Check out that chapter for more info and feel free to open a ticket there if you have more questions.

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