-
Notifications
You must be signed in to change notification settings - Fork 462
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
Version >= 0.1.2 don't work with webtorrent #406
Comments
Thanks, @Fabiencdp. I will test it out |
Hi friends -- has there been any progress on this? Is there anything I can do to help? |
Hi @surprisetalk, Yes, you can definitely help out! We still don't know why it doesn't work. I took a look at @Fabiencdp's example, but I wasn't sure what the expected behavior was (I've never used instant.io, for example, which is mentioned in the usage example). I was AFK for a bit, so I haven't followed up, but if you could take a look, that would help. I think we want to identify,
My feeling is that adding some logging to @Fabiencdp's project or some logging in its dependencies may help us answer these questions. Mark |
Thanks @markandrus! I did some research today with Seeding consistently works in the following scenario:
So seeding files works, but somewhere the metadata exchange is breaking! Indeed, take a look at the following log (this happens when you add a magnet link on instant.io):
Interesting, right? It looks like some initial handshake messages are getting garbled. You can even see a I'll continue investigating tomorrow -- just thought I'd post my first findings here in case this seems familiar to anybody. |
Update: Started two leeching peers using Peer 1 had the following exchange:
Peer 2 logged this:
Note that both peers sent the exact same message at the same time, yet one received buffer was prefixed with I'm trying to track down what occurs after this._push(buffer)
if (data) this._push(data) As always, let me know if anything jumps out at you. EDIT: If both peers are started at about the same time, the handshake sends successfully. The errors only seem to occur when one leecher is running, and then I remove and start a second leecher. Strange! |
Hmm, I wonder if this is specific to Buffers that get var dataLength = data ? data.length : 0
var buffer = Buffer.allocUnsafe(5 + (4 * numbers.length))
buffer.writeUInt32BE(buffer.length + dataLength - 4, 0)
buffer[4] = id
for (var i = 0; i < numbers.length; i++) {
buffer.writeUInt32BE(numbers[i], 5 + (4 * i))
} Buffer support was actually added in v0.0.65. See these changes in datachannel.cc. I'm not sure what's significant about v0.1.2, though. There are only very minor changes in, e.g., how we copy the |
I found the problem! First, look at the following block of code from simple-peer/index.js: Peer.prototype._onChannelMessage = function (event) {
var self = this
if (self.destroyed) return
var data = event.data
if (data instanceof ArrayBuffer) data = Buffer.from(data)
self.push(data)
} This function takes Anyway, if you look at the Peer.prototype._onChannelMessage = function (event) {
var self = this
if (self.destroyed) return
var data = event.data
if (data instanceof ArrayBuffer) {
let data_ = Buffer.allocUnsafe(Buffer.from(data).length)
Buffer.from(data).copy( data_ )
self.push( data_ )
} else
{
self.push( data )
}
} So it looks like
|
Awesome work! I’m AFK this weekend, but happy to look more closely Monday. :-) |
@surprisetalk OK, I believe I understand the bug now. It is a bug in node-webrtc and the way we construct ArrayBuffer. Actually, I am surprised this hasn't caused more problems! :-O We call this version of New with Herein lies the problem, though: if we hold onto two ArrayBuffers from an RTCDataChannel in the JavaScript layer, the Here's what we can do, then: construct ArrayBuffer in an "internalized" state, and Thanks again! You're investigation helped a ton. |
@Fabiencdp @surprisetalk I merged #419 and release [email protected]. Can either of y'all retest with webtorrent? If it works, then I think we can close this issue. |
Sorry, I've been on vacation and working on other projects. Just tested |
Very nice, thank you! 👍 |
Hi,
I try to use node-webrtc with webtorrent-hybrid instead of electron-webrtc.
It works with node-webrtc version 0.1.0 and 0.1.1. But don't with 0.1.2 and superior versions.
After some test, it look like the problem come from the binary from 0.1.2. I run my test on linux x64.
I have made a test repo to show the difference : https://github.com/Fabiencdp/webtorrent-wrtc-test
Did you have an idea on what happen ?
You can take a look at this issue webtorrent/webtorrent#76
The text was updated successfully, but these errors were encountered: