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
Enabling protocol encryption stalls downloads #2594
Comments
oops. might be my fault, i dont think we have tests for this which is an issue too |
lets try reproducing this on 1.9.6, could you maybe write a test case on webtorrent 1.9.6 where this works? |
Ok, I can try tomorrow. I'm not familiar with how webtorrent does testing. |
thanks tests are actually really simple: |
does it pass on v1.9.x and fail on v2.x.x? |
this is the test for the 1.9.x version and it fails with an error: https://github.com/anma-dev/webtorrent/blob/add-pe-tests-1.9x/test/node/protocol-encryption.js this is the test for the 2.x version and it doesn't show and error but it stalls indefinitely: https://github.com/anma-dev/webtorrent/blob/master/test/node/protocol-encryption.js |
oke thanks for the tests, this is helpful af, im gonna look when i have the time |
I'm happy to help :) |
I opened a PR |
Can you kindly link the pull @ghost |
I am thinking to work on this issue in this year's hacktober fest. Any suggestions as I am new to open source contributions. |
it was worked on, but we didn't have the time to finish it, should be a simple one, see the changes and conversation in: https://github.com/webtorrent/bittorrent-protocol/pull/120/files |
Okay, I have started to work on it. |
What version of this package are you using?
webtorrent version 2.1.9
What operating system, Node.js, and npm version?
The problem occurs on macOS and Linux as far as I know.
Node 19.4.0
Npm 9.7.1
What happened?
This issue is related to bittorrent protocol encryption. When enabling protocol encryption the torrent never starts downloading and it hangs indefinitely.
Steps to installation
the code:
I think the problem is with this while loop that never ends and is always waiting for setGenerators to be set to true, which never happens: https://github.com/webtorrent/bittorrent-protocol/blob/v4.1.7/index.js#L1157
A potential solution is to change this line at https://github.com/webtorrent/webtorrent/blob/v2.1.5/lib/peer.js#L130 for:
I'm not sure why this works but the script no longer stalls. I'm not sure how to check that encryption is actually being used after this change.
What did you expect to happen?
Specifying the secure option should enable protocol encryption without interrupting the download of torrented content.
Are you willing to submit a pull request to fix this bug?
Yes
The text was updated successfully, but these errors were encountered: