-
Notifications
You must be signed in to change notification settings - Fork 191
feat: Enhance WebSocket transport with advanced features #964
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
base: main
Are you sure you want to change the base?
feat: Enhance WebSocket transport with advanced features #964
Conversation
- Introduced WebsocketListenerConfig for configurable listener settings including TLS, connection limits, and timeouts. - Implemented WebSocketConnectionManager to manage multiple connections with pooling, cleanup, and statistics tracking. - Added SOCKSConnectionManager for WebSocket connections through SOCKS proxies, supporting SOCKS4 and SOCKS5 protocols. - Refactored WebsocketTransport to utilize new configuration and connection management features, including proxy support and improved error handling. - Enhanced connection tracking and statistics gathering for better monitoring of active connections. - Updated listener and transport methods to support new configurations and improve overall robustness.
|
@acul71 I would like you to take the point on this PR I'm occupied next week, so I may not be able to put more work into it. I've raised the PR and implemented the WebSocket implementation. |
|
@yashksaini-coder : Great, thank you so much for sharing. Appreciate your wonderful efforts. @acul71 will collaborate with you to get this PR to a production stage. We need this PR ready for final review + merge before the next py-libp2p release in 2+ weeks. @yashksaini-coder : Wish to share that I re-ran the CI/CD pipeline and found important issues and tests failing. Please collaborate with @acul71 and @bomanaps to get this resolved. |
…multiple demo files
|
@yashksaini-coder : Thank you so much to you and @acul71 for your efforts. Appreciate it. It took me sometime to reach this PR as there were close to 12+ PRs in the review queue. Did re-run the CI/CD pipeline and important test cases are passing. Did notice some good number of test cases are failing too. Wish if you could collaborate with @acul71 and arrive at a good conclusion on this PR soon. Lets try and complete this before the next release of py-libp2p planned in 1.5+ weeks. |
…pdate assertions in tests
…t for better compatibility
…ini-coder/py-libp2p into Feat/WebSocket-Transport
|
@yashksaini-coder : Sure, I'll also request @sumanjeet0012, @Winter-Soren and @lla-dane to help you in this initiative. Please add them as collaborators. @acul71 will collaborate soon. @pacrob is already reviewing a good number of PRs with us. |
|
@yashksaini-coder : Appreciate your efforts. Not to worry :) |
Sorry @yashksaini-coder , I was unavailable for some time. |
|
@yashksaini-coder : Wish if you could collaborate with @asmit27rai and @acul71; resolve the CI/CD issues and remaining features. Re-ran the CI/CD pipeline. Quite a significant number of issues remaining. |
|
@yashksaini-coder : Appreciate your efforts. Looking forward to arriving at a good conclusion on the issue. |
- Updated the protobuf dependency version to >=5.0.0,<7.0.0 in pyproject.toml. - Removed unused parameter 'with_noise_pipes' from TransportUpgrader instantiation in websocket integration tests. - Cleaned up whitespace in the Yamux class implementation for better readability.
…ython CI pass - Updated the self-signed certificate generation in browser_wss_demo.py, websocket_comprehensive_demo.py, and wss_demo.py to use timezone.utc instead of datetime.UTC for better compatibility and clarity.
- Introduced X25519 key pair generation for Noise protocol compliance. - Updated peer store handling to add peer info before connection. - Increased sleep duration to ensure host fully starts before connection attempt.
|
@asmit27rai Hi could you please sign your commits, as it will help us in github ci action script checks |
|
@yashksaini-coder : Wish if the CI/CD issues could be resolved. |
|
@yashksaini-coder : Appreciate the efforts by you and @asmit27rai |
Yes sir working on it |
AI Pull Request Review: PR #964 - feat: Enhance WebSocket transport with advanced featuresPR: #964 1. Summary of ChangesThis PR implements comprehensive enhancements to the WebSocket transport implementation in py-libp2p, addressing issue #938 which tracks missing features compared to the Go implementation. The PR adds significant functionality including connection management, SOCKS proxy support, AutoTLS, advanced configuration options, and improved error handling. Key Components Added:
Files Changed:
Breaking Changes:None identified. This is a feature addition that maintains backward compatibility with existing WebSocket transport usage. 2. StrengthsArchitecture and Design
Implementation Quality
Feature Completeness
Testing
Documentation
3. Issues FoundCritical3.1 Missing Newsfragment (BLOCKER)
3.2 Type Checking Error
3.3 Integration Test Failures
Major3.4 Security Upgrade Failures (From PR Comments)
3.5 Listener Address Exposure Issues (From PR Comments)
3.6 Missing Error Documentation
3.7 Incomplete Connection Manager Implementation
Minor3.8 Incomplete TLS Config Validation
3.9 Missing Type Hints in Some Places
4. Security ReviewSecurity Considerations4.1 SOCKS Proxy Authentication
4.2 AutoTLS Certificate Management
4.3 TLS Configuration Validation
4.4 Connection Limits
4.5 Input Validation
Overall Security AssessmentThe implementation includes good security practices:
5. Documentation and Examples5.1 Documentation Quality
5.2 Missing Documentation
5.3 Example Code
6. Newsfragment RequirementCurrent Status
Required ActionCreate a newsfragment file following the format:
Suggested Newsfragment ContentEnhanced WebSocket transport with advanced features including SOCKS proxy support,
AutoTLS for browser integration, connection management, and comprehensive configuration
options. The implementation adds production-ready features like connection pooling,
statistics tracking, and advanced TLS configuration for improved reliability and
monitoring capabilities.Important: The file must end with a newline character to pass GitHub tox linting checks. 7. Tests and Validation7.1 Test Coverage
7.2 Build and Linting
7.3 Test Execution
7.4 Documentation Build
7.5 Edge Case Testing
8. Recommendations for ImprovementCritical (Must Fix Before Merge)
High Priority
Medium Priority
Low Priority
9. Questions for the Author
10. Overall AssessmentQuality Rating: Needs WorkThe PR implements comprehensive WebSocket transport enhancements with excellent architecture and feature completeness. The code is well-structured, has good test coverage (1,625 tests passing overall), and includes production-ready features. However, critical issues prevent immediate merge:
Security Impact: Low to MediumThe implementation includes good security practices (connection limits, TLS validation, proper error handling). AutoTLS should be documented as development-only. SOCKS proxy authentication is acceptable for current use case. Merge Readiness: Needs FixesThe PR requires fixes for:
After these fixes, the PR should be re-reviewed for:
Confidence: MediumThe implementation is well-architected and comprehensive, but the integration test failures and security upgrade issues suggest there may be deeper integration problems that need investigation. The code quality is high, but the functional issues need to be resolved. Review Checklist
References
Reviewer Notes:
|
…tter error handling and debugging. Improved error messages during security upgrades, protocol negotiations, and data reads. Added detailed logging for incomplete reads and protocol selection attempts.
Fixes: #938
Added WebSocket Transport Improvements
This PR improves the WebSocket transport implementation with better connection management,
configuration options, and monitoring capabilities.