2.4 KiB
2.4 KiB
Task 7: WebSocket Signaling Server - Issues Encountered
Build System Issues
libspa-sysbuild script failed when running full cargo test due to missing PipeWire dev dependencies- Solution: Used
cargo test --no-default-featuresto skip PipeWire feature during testing
Compilation Errors
E0433: Unresolved Module tungstenite
- Error: Could not resolve
tungstenite::Errortype - Cause: Import statement only imported specific items, not the full module
- Solution: Added
Error as WsErrorto tokio_tungstenite imports - Pattern: Use type aliasing for frequently used imported types
E0599: No Method next
- Error:
WebSocketStreamdidn't havenext()method in scope - Cause: Missing
StreamExttrait from futures crate - Solution: Added
use futures::StreamExtto imports - Lesson: WebSocketStream implements Sink and Stream traits from futures, both needed
E0282: Type Annotations Needed
- Error: Compiler couldn't infer error types in closures
- Affected locations:
handle_clientmessage variable, multiple error closures - Solution: Added explicit type annotations:
let msg: Message,|e: WsError| - Pattern: Async WebSocket code frequently requires explicit type annotations
Missing Error Variant
- Error: Used
SignalingError::SessionNotFoundwhich doesn't exist - Root Cause: Error exists in
WebRtcErrorenum, notSignalingError - Solution: Changed to
SignalingError::ProtocolErrorwith descriptive format string - Alternative: Could add
SessionNotFoundvariant toSignalingErrorenum
Code Organization Issues
Duplicate Struct Definition
- Issue: Initially had both placeholder and complete
SignalingServerstruct definitions - Cause: Added new struct without removing old placeholder
- Detection: Compiler reported "unclosed delimiter" error
- Solution: Removed old placeholder struct definition
- Prevention: Always review file for duplicates before major edits
Testing Considerations
Port Conflicts
- Issue: Default port 8765 might conflict during concurrent test runs
- Solution: Used ephemeral ports (18765+) for test instances
- Pattern: Add test port offset (10000+) to default ports
Dependency Testing
- Issue: Full build requires PipeWire system libraries
- Solution: Test with
--no-default-featuresto test core functionality - Trade-off: Can't test integration with features disabled