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

DeviceDisconnected Exception when trying to run backup using Netimobiledevicedemo.exe #65

Closed
MarkFassett opened this issue Dec 20, 2024 · 7 comments · Fixed by #69
Closed

Comments

@MarkFassett
Copy link
Contributor

So this is just an extension of my previous issue (which, that one seems fixed). I tried the update in our project, and it failed, and so I thought, just to be sure it's not "us", I pulled a fresh version of the repo and just ran it via the demo app.

The output:

Press Ctrl+C to cancel the operation.
info: NetimobiledeviceDemo[0]
      Hello World! Logging is fun.
dbug: NetimobiledeviceDemo[0]
      There's 2 devices connected
Device found: 4 - 00008030-000909063CA3XXXX
Device found: 3 - 00008030-000909063CA3XXXX
dbug: NetimobiledeviceDemo[0]
      Using usbmuxd pair record for identifier: 00008030-000909063CA3XXXX
BackupJob_PasscodeRequiredForBackup
BackupJob_Progress
    <lots of BackupJob_Progress>
BackupJob_Progress
BackupJob_BeforeReceivingFile
BackupJob_FileReceiving
BackupJob_FileReceived
BackupJob_Status
Unhandled exception. Netimobiledevice.Exceptions.DeviceDisconnectedException: Device disconnected
   at Netimobiledevice.DeviceLink.DeviceLinkService.UploadFiles(ArrayNode msg, CancellationToken cancellationToken) in A:\clients\TEC\Netimobiledevice-main\Netimobiledevice\DeviceLink\DeviceLinkService.cs:line 628
   at Netimobiledevice.DeviceLink.DeviceLinkService.DlLoop(CancellationToken cancellationToken) in A:\clients\TEC\Netimobiledevice-main\Netimobiledevice\DeviceLink\DeviceLinkService.cs:line 672
   at Netimobiledevice.Backup.Mobilebackup2Service.Backup(Boolean fullBackup, String backupDirectory, CancellationToken cancellationToken) in A:\clients\TEC\Netimobiledevice-main\Netimobiledevice\Backup\Mobilebackup2Service.cs:line 424
   at NetimobiledeviceDemo.Program.Main() in A:\clients\TEC\Netimobiledevice-main\NetimobiledeviceDemo\Program.cs:line 66
   at NetimobiledeviceDemo.Program.<Main>()

Process finished with exit code -532,462,766.

In our own app, it seems to get info.plist and a status.plist, creates all the folders, and disconnects - which seems to be mirrored here.

@artehe
Copy link
Owner

artehe commented Dec 26, 2024

I tried a couple of devices I had and seemed to work fine for me.

Might be a stupid suggestion but have you tried restarting your iOS device(s) and then running it again?

@oneo-me
Copy link

oneo-me commented Dec 31, 2024

I tried restarting the device, still the same error.
system: macOS 15.2

@artehe
Copy link
Owner

artehe commented Jan 4, 2025

I did try on my Mac as well but didn't seem to have any issues.

Will try again on Monday and see if I can find anything.

@artehe
Copy link
Owner

artehe commented Jan 6, 2025

I did update my Mac to Sequoia (MacOS 15.2) and haven't run into the issue mentioned, however instead I have run into something new so will be looking into that.

This was the error I was getting in case anyone has some insights:

Exception has occurred: CLR/Interop.AppleCrypto.AppleCommonCryptoCryptographicException

An exception of type 'Interop.AppleCrypto.AppleCommonCryptoCryptographicException' occurred in System.Security.Cryptography.dll but was not handled in user code: 'The specified item is no longer valid. It may have been deleted from the keychain.'
   at Interop.AppleCrypto.X509CopyWithPrivateKey(SafeSecCertificateHandle certHandle, SafeSecKeyRefHandle privateKeyHandle, SafeKeychainHandle targetKeychain)
   at System.Security.Cryptography.X509Certificates.AppleCertificatePal.CopyWithPrivateKey(SafeSecKeyRefHandle privateKey)
   at System.Security.Cryptography.X509Certificates.AppleCertificatePal.CopyWithPrivateKey(RSA privateKey)
   at System.Security.Cryptography.X509Certificates.RSACertificateExtensions.CopyWithPrivateKey(X509Certificate2 certificate, RSA privateKey)
   at System.Security.Cryptography.X509Certificates.X509Certificate2.ExtractKeyFromPem[TAlg](ReadOnlySpan`1 keyPem, String[] labels, Func`1 factory, Func`2 import)
   at System.Security.Cryptography.X509Certificates.X509Certificate2.CreateFromPem(ReadOnlySpan`1 certPem, ReadOnlySpan`1 keyPem)
   at Netimobiledevice.Lockdown.ServiceConnection.StartSSL(Byte[] certData, Byte[] privateKeyData) in /Users/artehe/Downloads/Netimobiledevice-main/Netimobiledevice/Lockdown/ServiceConnection.cs:line 275
   at Netimobiledevice.Lockdown.LockdownClient.ValidatePairing() in /Users/artehe/Downloads/Netimobiledevice-main/Netimobiledevice/Lockdown/LockdownClient.cs:line 307
   at Netimobiledevice.Lockdown.LockdownClient.HandleAutoPair(Boolean autoPair, Single timeout) in /Users/artehe/Downloads/Netimobiledevice-main/Netimobiledevice/Lockdown/LockdownClient.cs:line 329
   at Netimobiledevice.Lockdown.PlistUsbmuxLockdownClient.Create(ServiceConnection service, String identifier, String systemBuid, String label, Boolean autopair, Nullable`1 pairTimeout, String localHostname, DictionaryNode pairRecord, String pairingRecordsCacheFolder, UInt16 port, String usbmuxAddress, ILogger logger) in /Users/artehe/Downloads/Netimobiledevice-main/Netimobiledevice/Lockdown/PlistUsbmuxLockdownClient.cs:line 54
   at Netimobiledevice.MobileDevice.CreateUsingUsbmux(String serial, String identifier, String label, Boolean autopair, Nullable`1 connectionType, Nullable`1 pairTimeout, String localHostname, DictionaryNode pairRecord, String pairingRecordsCacheDir, UInt16 port, String usbmuxAddress, ILogger logger) in /Users/artehe/Downloads/Netimobiledevice-main/Netimobiledevice/MobileDevice.cs:line 48
   at NetimobiledeviceDemo.Program.<Main>d__1.MoveNext() in /Users/artehe/Downloads/Netimobiledevice-main/NetimobiledeviceDemo/Program.cs:line 45

@artehe
Copy link
Owner

artehe commented Jan 7, 2025

@oneo-me and @MarkFassett could you check out this PR #69 for me please?

I think I worked out what was happening for you and this should fix it, let me know if there's any other problems.

One other issue I've found with backups is there's an error thrown right at the end but doesn't seem to be any issues with the actual backup. Will investigate this separately as #68.

@artehe artehe linked a pull request Jan 7, 2025 that will close this issue
@oneo-me
Copy link

oneo-me commented Jan 8, 2025

@artehe I tested this PR #69 and it can be backed up normally, but I cannot start debugging directly on the Demo, which will cause problems, the program will still start the backup.

image

@artehe
Copy link
Owner

artehe commented Jan 8, 2025

@artehe I tested this PR #69 and it can be backed up normally, but I cannot start debugging directly on the Demo, which will cause problems, the program will still start the backup.

I'm fairly sure that you should be able to just continue past that, as it should be handled.

I'll admit it's not the best written section and could be much improved, but at least it works again so I'll merge the changes

@artehe artehe closed this as completed in #69 Jan 8, 2025
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

Successfully merging a pull request may close this issue.

3 participants