Repository navigation
Conversation
- Modify closeUdpSockets() to recreate socket objects after shutdown - Add defensive validation in createUdpSockets() to ensure clean state - Add comprehensive logging for debugging connection flow - Add unit tests to verify socket reconnection behavior - Fix RTSP connection timeout by removing unnecessary socket readiness check - Fix logging output to use juce::Logger::writeToLog This resolves the 'Failed to create UDP sockets' error on retry attempts by ensuring socket objects are properly recreated after shutdown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes the UDP socket binding issue described in #25 where connection attempts would fail with "Failed to create UDP sockets" on retry.
Problem
The original issue was that
closeUdpSockets()only calledshutdown()on socket objects but didn't recreate them. JUCE'sDatagramSocketobjects remain bound to their ports aftershutdown(), preventing subsequentbindToPort()calls from succeeding.Flow of the bug:
closeUdpSockets()is called, which only shuts down socketscreateUdpSockets()which tries to bind to same portsSolution
1. Fix Socket Cleanup (Primary Fix)
closeUdpSockets()to recreate socket objects usingstd::make_unique<juce::DatagramSocket>()after shutdown2. Add Socket State Validation (Defensive)
createUdpSockets()to ensure socket objects exist before binding3. Enhanced Debugging & Monitoring
juce::Logger::writeToLog()instead of undefinedDBGmacro4. Test Coverage
Files Modified
Source/AirPlay/RaopClient.cpp- Main socket management fixesSource/AirPlay/RaopClient.h- Made socket methods public for testingSource/AirPlay/AirPlayManager.cpp- Added connection debuggingSource/PluginEditor.cpp- Added UI connection debuggingSource/Discovery/DeviceDiscoveryMac.mm- Added device discovery debuggingTests/RaopClientTests.cpp- Added socket reconnection testsTesting
✅ Verified Working:
Current Status
The original UDP socket binding issue is completely resolved. The connection now proceeds to RTSP handshake, but there's a separate issue where AirPlay devices are not responding to RTSP requests (this will be addressed in a separate issue).
Related Issues
Fixes #25