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

ipfs-address in the browser #847

Closed
ticruz38 opened this issue May 9, 2017 · 8 comments
Closed

ipfs-address in the browser #847

ticruz38 opened this issue May 9, 2017 · 8 comments

Comments

@ticruz38
Copy link

ticruz38 commented May 9, 2017

I am using ipfs in the browser, I just figured out that my browser node does not connect to peers except when I explicitly connect with ipfs.swarm.connect(address). After that I got one peer connected to my browser node.
I am also unable to get my browser node address, the field multiaddress is always an empty list.

Is that a normal behaviour, is there any configuration needed to get my browser node discoverable by the ipfs network? How could I get my browser node address?

@victorb
Copy link
Member

victorb commented May 9, 2017

Take a look at the example "Transfer Files" which shows how you can use a Signaling Server to help nodes to find each others:

node = new self.Ipfs({
repo: repoPath,
config: {
Addresses: {
Swarm: [
'/libp2p-webrtc-star/dns4/star-signal.cloud.ipfs.team/wss'
]
}
}
})

There is also bootstrap nodes on the way, which would help as well.

@daviddias
Copy link
Member

Following on what @victorbjelkholm already explained.

browser node does not connect to peers

If you try the latest js-ipfs from github master, it will auto connect to bootstraper nodes, this feature hasn't been released yet

discover other nodes

As @victorbjelkholm suggested, you need to enable the WebRTC transport for that

I am also unable to get my browser node address, the field multiaddress is always an empty list.

That is because you are just using WebSockets in the browser, which doesn't have a listener, it can only dial.

@ticruz38
Copy link
Author

thank you for your helpful answer, I couldn't find a suitable example in the test folder to up and download file from ipfs, the one you shared works just as expected.

@ticruz38
Copy link
Author

I've enabled webRTC, so now my peers do have address and browser nodes connect directly to each other.
But it seems like webRTC enabled node can't share data via block or file api. Only the pubsub seems to work.
Is this a normal behaviour? Something in the configuration to enable block and file sharing via webRTC?

@daviddias
Copy link
Member

They should be able to share it, see the example https://github.com/ipfs/js-ipfs/tree/master/examples/transfer-files

Note, if you are using Chrome, you might need to open two windows due to Chrome's throttling policy #611

@ticruz38
Copy link
Author

they do open a connection through the file api, but it's as if the stream object were damaged. it either never ends or ends up with such error.

DOMException: The JWK's "y" member defines an octet string of length 31 bytes but should be 32
index.js:27 Error: Stream ended prematurely

I'm trying to transfer image files (png, jpg) as shown in this sample
the files resolve when they are already stored in the node repo, but not when transferring from other nodes.

@daviddias
Copy link
Member

Do you have success using the example? As in, did you manage to transfer files using it?

@ticruz38
Copy link
Author

ticruz38 commented May 16, 2017

I just tried the transfer file sample. I do have the same problems. I opened 2 chrome windows and launched a desktop websocket enabled node. connected my two browser node together and with the desktop node.
Uploading and fetching file in the same window works. Fetching a file from the other window dont.
I tried with different connection, wifi and mobile data, the result is the same.

When fetching data from the other window:

The ipfs.files.get function does resolve with a stream full of data, but I can't sink it without error. it sink eternally or send an error.

  • That experiment need to be done with files that has never been updated to ipfs before, to ensure the connexion is made between our 2 webrtc nodes.

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

3 participants