Skip to content

Bounty: $300 for Fixing js-libp2p Compatibility Issues in react-native-tcp-socket #209

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

Open
palmtown opened this issue Feb 20, 2025 · 33 comments · May be fixed by #210
Open

Bounty: $300 for Fixing js-libp2p Compatibility Issues in react-native-tcp-socket #209

palmtown opened this issue Feb 20, 2025 · 33 comments · May be fixed by #210
Labels
bug Something isn't working

Comments

@palmtown
Copy link

palmtown commented Feb 20, 2025

Background
js-libp2p is the JavaScript implementation of the libp2p networking stack, enabling peer-to-peer communication with modular transport, discovery, and security protocols. Integrating it with React Native is critical for decentralized applications, allowing mobile clients to connect to peer networks without relying on centralized servers.

Currently, react-native-tcp-socket, which serves as a TCP transport layer in React Native, faces compatibility issues with js-libp2p. Fixing these issues will not only enable seamless connectivity for libp2p-based applications on mobile but also improve react-native-tcp-socket by bringing it closer to Node.js's net implementation, ensuring long-term maintainability and broader adoption.

Bounty Details
I am offering $300 to the developer who successfully creates a PR addressing the following:

Tasks

  1. Solve react-native-tcp-socket issue #183: Implement support for the options parameter in the net.createServer method to align with Node.js's net module.
  2. Fix connection failures when a React Native client dials a relay: Ensure that React Native clients can successfully establish connections with relays without encountering errors such as UnexpectedEOFError (see Exhibit 2 below).

Acceptance Criteria (AC)
✅ Issue #183 is resolved.
✅ A React Native client can successfully dial a bootstrap/relay/peer without connection failures.
✅ A pull request (PR) is created with the fixes.

If you need assistance testing, I am happy to help by setting up a reproducible repository.

Exhibit 2: Connection Failure Log
libp2p:tcp:socket:error encrypting inbound connection from /ip4/X.X.X.X/tcp/58057 failed UnexpectedEOFError: unexpected end of input
at Object.read (file:///home/nodejs/libp2p/node_modules/it-byte-stream/dist/src/index.js:94:31)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async Object.read (file:///home/nodejs/libp2p/node_modules/it-length-prefixed-stream/dist/src/index.js:45:37)
at async read (file:///home/nodejs/libp2p/node_modules/@libp2p/multistream-select/dist/src/multistream.js:22:17)
at async Module.readString (file:///home/nodejs/libp2p/node_modules/@libp2p/multistream-select/dist/src/multistream.js:33:17)
at async Module.handle (file:///home/nodejs/libp2p/node_modules/@libp2p/multistream-select/dist/src/handle.js:63:26)
at async DefaultUpgrader._encryptInbound (file:///home/nodejs/libp2p/node_modules/libp2p/dist/src/upgrader.js:458:42)
at async DefaultUpgrader._performUpgrade (file:///home/nodejs/libp2p/node_modules/libp2p/dist/src/upgrader.js:173:21)
at async DefaultUpgrader.upgradeInbound (file:///home/nodejs/libp2p/node_modules/libp2p/dist/src/upgrader.js:99:13) {
code: 'ERR_UNEXPECTED_EOF'

How This Helps the Future of react-native-tcp-socket
By resolving these issues, react-native-tcp-socket will better align with Node.js's net module, making it a more reliable and future-proof solution for TCP networking in React Native. This improvement is essential for decentralized applications, Web3 projects, and any use case requiring peer-to-peer communication on mobile.

If you're up for the challenge, submit your PR and claim the bounty! 🚀 Please feel free to reach out to me with any questions.

@achingbrain
@abuvanth

@palmtown
Copy link
Author

Update: For anyone interested in taking on this bounty, I can make payments via Bitcoin, USDT, Zelle, or CashApp. Let me know if you have any questions!

@omarsoufiane
Copy link

@palmtown we can help you streamline your bounty and make it visible to more developers, can you reach out to me via email (yours is not visible on your profile)?

@palmtown
Copy link
Author

@omarsoufiane

Thanks for reaching out. Note that I sent you an email. Looking forward to getting this in front of interested developers.

@bountyhub-bot
Copy link

🚀 Bounty Alert!

💰 A bounty of $300.00 has been created by palmtown on BountyHub for this issue.

🔗 Claim this bounty by submitting a pull request that solves this issue!

You can also increase the amount of the bounty if you think the issue is worth more.

Good luck, and happy coding! 💻

@Myestery
Copy link

Hi @palmtown
I'll like to work on this, can I be assigned?

@palmtown
Copy link
Author

Hello @Myestery,

Thanks for your interest in this bounty! I appreciate you looking into it. When you’ve had a chance to review the requirements, could you provide a rough estimate of the timeline? This will help me understand whether we’re looking at days or months for completion.

I’ve sent you a LinkedIn message with my email address for further communication. Looking forward to your thoughts!

@achingbrain
Copy link

If it helps someone, the connection failure log line:

libp2p:tcp:socket:error encrypting inbound connection from /ip4/X.X.X.X/tcp/58057 failed UnexpectedEOFError: unexpected end of input

...normally means that the remote closed the connection during opening. The thing to do would be to check the logs on the remote node to find out why it closed the connection.

@Myestery
Copy link

If it helps someone, the connection failure log line:

libp2p:tcp:socket:error encrypting inbound connection from /ip4/X.X.X.X/tcp/58057 failed UnexpectedEOFError: unexpected end of input

...normally means that the remote closed the connection during opening. The thing to do would be to check the logs on the remote node to find out why it closed the connection.

okay, this is helpful

@Myestery
Copy link

Hello @Myestery,

Thanks for your interest in this bounty! I appreciate you looking into it. When you’ve had a chance to review the requirements, could you provide a rough estimate of the timeline? This will help me understand whether we’re looking at days or months for completion.

I’ve sent you a LinkedIn message with my email address for further communication. Looking forward to your thoughts!

I can send a PR to fix it on or before Monday but I'm currently investigating it

@abuvanth
Copy link

let me deep dive

@abuvanth
Copy link

@Myestery
Copy link

I created a PR in #210 that should fix this, the tests ensure that the fix is also backward compatible for those who use the library

@abuvanth
Copy link

abuvanth commented Feb 25, 2025

I created a PR in #210 that should fix this, the tests ensure that the fix is also backward compatible for those who use the library

I tested the PR, react-native-tcp-socket side issue is cleared but i could not dial relay server.

facing the following error when try to dial

[NoValidAddressesError: The dial request has no valid addresses]

this time issue with libp2p-js side?

@Myestery
Copy link

I created a PR in #210 that should fix this, the tests ensure that the fix is also backward compatible for those who use the library

I tested the PR, react-native-tcp-socket side issue is cleared but i could not dial relay server.

facing the following error when try to dial

[NoValidAddressesError: The dial request has no valid addresses]

this time issue with libp2p-js side?

I'll like to see the code you ran but yeah, this error is not from this library

@abuvanth
Copy link

[NoValidAddressesError: The dial request has no valid addresses]

this error occurred because i try to dial wrong address(websocket multi addresss) now i change to tcp address this error gone.

@Myestery
Copy link

[NoValidAddressesError: The dial request has no valid addresses]

this error occurred because i try to dial wrong address(websocket multi addresss) now i change to tcp address this error gone.

great, looks like we're good to go 🚀

@abuvanth
Copy link

but i could not dial. it is not responding

@palmtown
Copy link
Author

Hello @Myestery

Thanks for getting this done. It is much appreciated. I will check it today and let you know my findings.

@palmtown
Copy link
Author

but i could not dial. it is not responding

Thanks for testing! We're you able to get it to work as expected. If not, what issues did you face?

@abuvanth
Copy link

but i could not dial. it is not responding

Thanks for testing! We're you able to get it to work as expected. If not, what issues did you face?

i need to check again. is it work for you?

@palmtown
Copy link
Author

palmtown commented Feb 25, 2025

Hello @Myestery

Thank you once again for your efforts on this issue. After reviewing your pull request, I have the following observations:

Acceptance Criterion #2: The pull request does not fully address "fix connection failures when a React Native client dials a relay: Ensure that React Native clients can successfully establish connections with relays without encountering errors such as UnexpectedEOFError." I have included additional logs from the relay, as suggested by @achingbrain, in Exhibit 1 below. If your pull request addresses this issue, could you please specify which parts of your code pertain to this fix?

Acceptance Criterion #1: Regarding Acceptance Criterion #1, you mentioned:

"2. Added proper ServerOptions type definition with support for noDelay, keepAlive, keepAliveInitialDelay, allowHalfOpen, pauseOnConnect."

While the type definitions for allowHalfOpen and pauseOnConnect are present, they do not appear to be supported, and passing these options seems to have no effect. Although implementing support for allowHalfOpen and pauseOnConnect is not required for this pull request—since libp2p doesn't seem to utilize these options—please consider adding support for them if you find it necessary to fulfill the acceptance criteria. Otherwise, they are not required.

If you have a working example of react-native-tcp-socket and js-libp2p functioning together, please share the repository, and I will review it. In the meantime, I kindly ask you to address the points mentioned above.

Exhibit 1
libp2p:tcp:listener new inbound connection /ip4/X.X.X.X/tcp/53371 +2m libp2p:tcp:socket inbound X.X.X.X:53371 socket end +0ms libp2p:tcp:socket:error encrypting inbound connection from /ip4/X.X.X.X/tcp/53371 failed UnexpectedEOFError: unexpected end of input at Object.read (file:///home/nodejs/libp2p/node_modules/it-byte-stream/dist/src/index.js:94:31) at process.processTicksAndRejections (node:internal/process/task_queues:105:5) at async Object.read (file:///home/nodejs/libp2p/node_modules/it-length-prefixed-stream/dist/src/index.js:45:37) at async read (file:///home/nodejs/libp2p/node_modules/@libp2p/multistream-select/dist/src/multistream.js:22:17) at async Module.readString (file:///home/nodejs/libp2p/node_modules/@libp2p/multistream-select/dist/src/multistream.js:33:17) at async Module.handle (file:///home/nodejs/libp2p/node_modules/@libp2p/multistream-select/dist/src/handle.js:63:26) at async DefaultUpgrader._encryptInbound (file:///home/nodejs/libp2p/node_modules/libp2p/dist/src/upgrader.js:458:42) at async DefaultUpgrader._performUpgrade (file:///home/nodejs/libp2p/node_modules/libp2p/dist/src/upgrader.js:173:21) at async DefaultUpgrader.upgradeInbound (file:///home/nodejs/libp2p/node_modules/libp2p/dist/src/upgrader.js:99:13) { code: 'ERR_UNEXPECTED_EOF' } +0ms libp2p:tcp:socket:error failed to upgrade inbound connection from /ip4/X.X.X.X/tcp/53371 - EncryptionFailedError: unexpected end of input libp2p:tcp:socket:error at DefaultUpgrader._encryptInbound (file:///home/nodejs/libp2p/node_modules/libp2p/dist/src/upgrader.js:474:19) libp2p:tcp:socket:error at process.processTicksAndRejections (node:internal/process/task_queues:105:5) libp2p:tcp:socket:error at async DefaultUpgrader._performUpgrade (file:///home/nodejs/libp2p/node_modules/libp2p/dist/src/upgrader.js:173:21) libp2p:tcp:socket:error at async DefaultUpgrader.upgradeInbound (file:///home/nodejs/libp2p/node_modules/libp2p/dist/src/upgrader.js:99:13) +0ms libp2p:tcp:listener:error inbound connection upgrade failed EncryptionFailedError: unexpected end of input at DefaultUpgrader._encryptInbound (file:///home/nodejs/libp2p/node_modules/libp2p/dist/src/upgrader.js:474:19) at process.processTicksAndRejections (node:internal/process/task_queues:105:5) at async DefaultUpgrader._performUpgrade (file:///home/nodejs/libp2p/node_modules/libp2p/dist/src/upgrader.js:173:21) at async DefaultUpgrader.upgradeInbound (file:///home/nodejs/libp2p/node_modules/libp2p/dist/src/upgrader.js:99:13) +2m libp2p:tcp:socket inbound X.X.X.X:53371 socket abort due to error - EncryptionFailedError: unexpected end of input libp2p:tcp:socket at DefaultUpgrader._encryptInbound (file:///home/nodejs/libp2p/node_modules/libp2p/dist/src/upgrader.js:474:19) libp2p:tcp:socket at process.processTicksAndRejections (node:internal/process/task_queues:105:5) libp2p:tcp:socket at async DefaultUpgrader._performUpgrade (file:///home/nodejs/libp2p/node_modules/libp2p/dist/src/upgrader.js:173:21) libp2p:tcp:socket at async DefaultUpgrader.upgradeInbound (file:///home/nodejs/libp2p/node_modules/libp2p/dist/src/upgrader.js:99:13) +1ms libp2p:tcp:socket inbound X.X.X.X:53371 socket close +0ms

Exhibit 1 - Image

Image

@abuvanth
Copy link

@palmtown can you please share the repo to test?

@Myestery
Copy link

Hi @palmtown
This is noted but I'll like to have a repo to test this too, thanks

@palmtown
Copy link
Author

palmtown commented Feb 25, 2025

Hello @Myestery,

Thank you for your efforts on this fix. I appreciate the work you've put in. I noticed that AC 2 specifies that a React Native client should be able to dial a relay without errors, and I'm a little unsure about the testing details used to confirm this. My testing has been part of a larger integrated app, so I don’t have a standalone repo ready to share. Could you please provide the repo you used to test this fix or how you verified that the issue is resolved? This will help us ensure that all criteria are fully met.

@abuvanth
Copy link

I created a test repo for testing libp2p tcp for react-native - https://github.com/abuvanth/react-native-libp2p-tcp-test

@Myestery
Copy link

Hello @Myestery,

Thank you for your efforts on this fix. I appreciate the work you've put in. I noticed that AC 2 specifies that a React Native client should be able to dial a relay without errors, and I'm a little unsure about the testing details used to confirm this. My testing has been part of a larger integrated app, so I don’t have a standalone repo ready to share. Could you please provide the repo you used to test this fix or how you verified that the issue is resolved? This will help us ensure that all criteria are fully met.

Hi @palmtown, for now I used the tests in the library to test the functionality but I'll take a further step with @abuvanth 's repo now to investigate further and get back.

@palmtown
Copy link
Author

palmtown commented Mar 3, 2025

Hello @Myestery,

How are you doing? I wanted to check in on the progress of this fix. Are there any challenges or blockers you're encountering?

Thanks!

@Myestery
Copy link

Myestery commented Mar 4, 2025

Hi @palmtown
I'm still working on this, I will have a final push by weekend, I had some personal delays

@vricosti
Copy link
Contributor

vricosti commented Mar 6, 2025

I am trying to centralized all improvements, I have already proposed a PR #208 where I have also included a fix about timeout and I will propose a new PR where I fix some exceptions not caught (for instance when there is a SSL certificate error an error is not emitted).
We need a robust library that is worthy of React Native because these past days I'm starting to regret choosing it.
If your PR works and Rapssito is too busy I will publish a @vricosti/react-native-tcp-socket as I already did with react-native-asset for instance.

@abuvanth
Copy link

abuvanth commented Mar 7, 2025

I am trying to centralized all improvements, I have already proposed a PR #208 where I have also included a fix about timeout and I will propose a new PR where I fix some exceptions not caught (for instance when there is a SSL certificate error an error is not emitted). We need a robust library that is worthy of React Native because these past days I'm starting to regret choosing it. If your PR works and Rapssito is too busy I will publish a @vricosti/react-native-tcp-socket as I already did with react-native-asset for instance.

your PR is not fix following

 (NOBRIDGE) LOG  [TypeError: The listener must be a function]

@vricosti
Copy link
Contributor

vricosti commented Mar 7, 2025

I am trying to centralized all improvements, I have already proposed a PR #208 where I have also included a fix about timeout and I will propose a new PR where I fix some exceptions not caught (for instance when there is a SSL certificate error an error is not emitted). We need a robust library that is worthy of React Native because these past days I'm starting to regret choosing it. If your PR works and Rapssito is too busy I will publish a @vricosti/react-native-tcp-socket as I already did with react-native-asset for instance.

your PR is not fix following

 (NOBRIDGE) LOG  [TypeError: The listener must be a function]

Can you give me more context...which listener ? what modification ?

@abuvanth
Copy link

abuvanth commented Mar 8, 2025

I am trying to centralized all improvements, I have already proposed a PR #208 where I have also included a fix about timeout and I will propose a new PR where I fix some exceptions not caught (for instance when there is a SSL certificate error an error is not emitted). We need a robust library that is worthy of React Native because these past days I'm starting to regret choosing it. If your PR works and Rapssito is too busy I will publish a @vricosti/react-native-tcp-socket as I already did with react-native-asset for instance.

your PR is not fix following

 (NOBRIDGE) LOG  [TypeError: The listener must be a function]

Can you give me more context...which listener ? what modification ?

read the issue description of this thread

@vricosti
Copy link
Contributor

You don't understand my PR is not supposed to fix this, since I am working on something else. I am just saying we need to centralize improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
7 participants