Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

A way which uses 'CDN' type to use js-ipfs in browser doesn't work. #2219

Closed
hapsody opened this issue Jul 5, 2019 · 2 comments
Closed

A way which uses 'CDN' type to use js-ipfs in browser doesn't work. #2219

hapsody opened this issue Jul 5, 2019 · 2 comments

Comments

@hapsody
Copy link
Contributor

hapsody commented Jul 5, 2019

  • Version: {version: "0.36.4", repo: 7, commit: ""} in chrome browser(75.0.3770.100(official build) (64bit))
  • Platform: Darwin neojuneui-MacBook-Pro-146.local 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64
  • Subsystem: -

Type: Question

Severity: very low

Description:

I've been trying to use js-ipfs functions without a daemon, I don't know if there's a way or not.
I wrote browser-side js code right below. and I share this code and result.

<html>

<!-- loading the human-readable (not minified) version jsDelivr -->
<script src="https://cdn.jsdelivr.net/npm/ipfs/dist/index.js"></script>
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
  $(document).ready(function() {
    ipfs = new window.Ipfs({
      repo: "/"
    })

    ipfs.once('ready', function() {
      ipfs.config.get().then((res) => console.log('node config:', res))
      ipfs.ls('QmZPHFcKBw2N4ja2Gkvt2YbPHRuaWUbKDjuKw5TurRHJ4q').then((res) => console.log(res));
    })

  })
</script>

</html>

result>
스크린샷 2019-07-05 오후 3 54 20

I think it may because of config.Addresses attributes.
so I set some config attributes likt this but I couldn't make it.

"Addresses": {
"API": "/ip4/127.0.0.1/tcp/5001",
"Announce": [],
"Gateway": "/ip4/127.0.0.1/tcp/8080",
"NoAnnounce": [],
"Swarm": [
"/ip4/0.0.0.0/tcp/4001",
"/ip4/127.0.0.1/tcp/4003/ws",
"/ip6/::/tcp/4001"
]
}

'ls' as well as other features like 'get', 'cat' didn't work.

No way to use js-ipfs without local daemon ever?

@hapsody hapsody changed the title A way which uses 'CDN' type to using js-ipfs in browser doesn't work. A way which uses 'CDN' type to use js-ipfs in browser doesn't work. Jul 5, 2019
@alanshaw
Copy link
Member

There's no error here, your browser node is just not able to find or connect to a peer that has the content you're looking for.

You could use webrtc or websocket star rendezvous and relays to get better connectivity.

Please also note that JS IPFS doesn't have a DHT just yet so finding nodes with content is also more difficult from the browser.

We need better docs to explain the state of IPFS in the browser for people who don't know what the limitiations are. I'll open an issue and hopefulyl we can get it sorted.

@hapsody
Copy link
Contributor Author

hapsody commented Jul 11, 2019

Thank you for your details. I clearly understand it. I'm sorry to ask with a lack of my knowledge.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants