Skip to content
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

Issue: Socket Not Connected Error During Video Processing #70

Open
gavin1818 opened this issue Jan 18, 2025 · 3 comments
Open

Issue: Socket Not Connected Error During Video Processing #70

gavin1818 opened this issue Jan 18, 2025 · 3 comments

Comments

@gavin1818
Copy link

Issue: Socket Not Connected Error Causing Download Failures

Description

Hi YouTubeKit team, first of all, thanks for putting this amazing project together—it’s great!

I’ve noticed constant download failures recently. The issue often comes with an error indicating that an error occurs when processing YouTube videos using YouTubeKit. The operation fails due to a “Socket is not connected” error, leading to download failures.

Steps to Reproduce

  1. Attempt to process or download a YouTube video using YouTubeKit.
  2. Observe that the process fails for specific video IDs.

Error Logs

Here are the detailed logs for reference:

Task <E5AC964D-D57B-4730-BC62-7D45EBA5F4C3>.<22> finished with error [57] 
Error Domain=NSPOSIXErrorDomain Code=57 "Socket is not connected" 
UserInfo={
    NSErrorFailingURLStringKey=https://youtubekit-remote.losjet.com/v1?videoID=Ur5APLuM_mA,
    NSErrorFailingURLKey=https://youtubekit-remote.losjet.com/v1?videoID=Ur5APLuM_mA,
    _NSURLErrorRelatedURLSessionTaskErrorKey=(
        "LocalWebSocketTask <E5AC964D-D57B-4730-BC62-7D45EBA5F4C3>.<22>"
    ),
    _NSURLErrorFailingURLSessionTaskErrorKey=LocalWebSocketTask <E5AC964D-D57B-4730-BC62-7D45EBA5F4C3>.<22>
}
Task <59D18972-65A7-44EB-9D58-520BA9E6A9B8>.<33> finished with error [57] 
Error Domain=NSPOSIXErrorDomain Code=57 "Socket is not connected" 
UserInfo={
    NSErrorFailingURLStringKey=https://youtubekit-remote.losjet.com/v1?videoID=ruTdhWgy5EI,
    NSErrorFailingURLKey=https://youtubekit-remote.losjet.com/v1?videoID=ruTdhWgy5EI,
    _NSURLErrorRelatedURLSessionTaskErrorKey=(
        "LocalWebSocketTask <59D18972-65A7-44EB-9D58-520BA9E6A9B8>.<33>"
    ),
    _NSURLErrorFailingURLSessionTaskErrorKey=LocalWebSocketTask <59D18972-65A7-44EB-9D58-520BA9E6A9B8>.<33>
}

Expected Behavior

The video should be processed/downloaded without encountering any errors.

Actual Behavior

The operation fails with a "Socket is not connected" error, and the download is not completed.

Environment

  • YouTubeKit Version: 0.2.5
  • OS/Platform: MacOS 15.2 and IOS 18.11
  • Network Conditions: stable Wi-Fi

Thank you for looking into this issue! Let me know if you need more information or additional logs.

@alexeichhorn
Copy link
Owner

Can you send the sample code you use to get the streams? Are you using remote only?

@gavin1818
Copy link
Author

Hi @alexeichhorn
my code is like this

    func start(_ url: URL, theChat: ChatSD) {
        currentState = .downloading
        currentConversation = theConversation
        Task {
            do {
                try await swiftDataService.updateChatState(theChat, to: .youtubeDownloading)
                let video = try await YouTube(url: url, methods: [.local, .remote])
                guard let audioStream = try await video
                    .streams
                    .filterAudioOnly()
                    .filter({ $0.fileExtension == .m4a })
                    .lowestAudioBitrateStream()
                else {
                    throw NSError(domain: "YouTubeTranscription", code: 1, userInfo: [
                        NSLocalizedDescriptionKey: "No suitable audio stream found",
                    ])
                }

                // Get audio URL
                let audioURL = audioStream.url
// ...

so the

guard let audioStream = try await video
                    .streams
                    .filterAudioOnly()
                    .filter({ $0.fileExtension == .m4a })
                    .lowestAudioBitrateStream()

was not able to get the audioStream, so the NSError got thrown, any clue thanks ?

@gavin1818
Copy link
Author

@alexeichhorn an update, I noticed that if I removed the .local in the YouTube(url: url, methods: [.local, .remote]), it worked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants