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

Mobilebackup2Service.Backup results in an exception with the message "InvalidService" #63

Closed
MarkFassett opened this issue Dec 10, 2024 · 8 comments · Fixed by #64
Closed

Comments

@MarkFassett
Copy link
Contributor

We're having trouble with doing a backup using 2.0. It throws an exception every time trying to create the AFC service.

using var lockdown = MobileDevice.CreateUsingUsbmux(_deviceSerial, logger: logger, pairingRecordsCacheDir: Paths.PairingRecordsCacheDir); using var backupJob = new MobileBackup2Service(lockdown, logger); ... set up the callbacks ... await backupJob.backup(true, backupPath)

Stack Trace: "error":"InvalidService","stacktrace":" at Netimobiledevice.Lockdown.LockdownClient.Request(String request, DictionaryNode options, Boolean verifyRequest) in ...\backupDevice\NetIMobileDevice\Netimobiledevice\Lockdown\LockdownClient.cs:line 162 at Netimobiledevice.Lockdown.LockdownClient.GetServiceConnectionAttributes(String name, Boolean useEscrowBag, Boolean useTrustedConnection) in ...\backupDevice\NetIMobileDevice\Netimobiledevice\Lockdown\LockdownClient.cs:line 128 at Netimobiledevice.Lockdown.LockdownClient.StartLockdownService(String name, Boolean useEscrowBag, Boolean useTrustedConnection) in ...\backupDevice\NetIMobileDevice\Netimobiledevice\Lockdown\LockdownClient.cs:line 531 at Netimobiledevice.Lockdown.LockdownService..ctor(LockdownServiceProvider lockdown, String serviceName, ServiceConnection service, Boolean useEscrowBag, ILogger logger) in ...\backupDevice\NetIMobileDevice\Netimobiledevice\Lockdown\LockdownService.cs:line 21 at Netimobiledevice.Afc.AfcService..ctor(LockdownServiceProvider lockdown, String serviceName, ILogger logger) in ...\backupDevice\NetIMobileDevice\Netimobiledevice\Afc\AfcService.cs:line 26 at Netimobiledevice.Afc.AfcService..ctor(LockdownServiceProvider lockdown, ILogger logger) in ...\backupDevice\NetIMobileDevice\Netimobiledevice\Afc\AfcService.cs:line 31 at Netimobiledevice.Backup.Mobilebackup2Service.Backup(Boolean fullBackup, String backupDirectory, CancellationToken cancellationToken) in ...\backupDevice\NetIMobileDevice\Netimobiledevice\Backup\Mobilebackup2Service.cs:line 381 at backupDevice.iOS.BackupiOS.Execute(String backupPath, String deviceIp) in ...\backupDevice\backupDevice\iOS\BackupiOS.cs:line 366","details":null}

When I look into it - even though we're doing USBMux (and not the remote one), it is using the AfcService constructor that uses the RSD_SERVICE_NAME, not LOCKDOWN_SERVICE_NAME. The other constructor has zero references.

@artehe artehe linked a pull request Dec 11, 2024 that will close this issue
@artehe
Copy link
Owner

artehe commented Dec 11, 2024

Good catch, and you're right I might have not been very smart about the way I put in the service name switching.

Could you test #64 for me and see if that works?

Let me know if there are still some other issues and I'll see what I can do about fixing them

@MarkFassett
Copy link
Contributor Author

I will try to get to it this afternoon - may be tomorrow morning before I can, though.

@MarkFassett
Copy link
Contributor Author

It got farther - this is probably a separate issue - but it failed to run the backup with this exception, now:

"error":"Unable to read data from the transport connection: An established connection was aborted by the software in your host machine..", stacktrace: at Netimobiledevice.Lockdown.ServiceConnection.ReceiveAsync(Int32 length, CancellationToken cancellationToken) in A:\clients\TEC\MemoThreeFile\backupDevice\NetIMobileDevice\Netimobiledevice\Lockdown\ServiceConnection.cs:line 153 at Netimobiledevice.Afc.AfcService.ReceiveData(CancellationToken cancellationToken) in A:\clients\TEC\MemoThreeFile\backupDevice\NetIMobileDevice\Netimobiledevice\Afc\AfcService.cs:line 161 at Netimobiledevice.Afc.AfcService.RunOperation(AfcOpCode opCode, AfcPacket packet, CancellationToken cancellationToken) in A:\clients\TEC\MemoThreeFile\backupDevice\NetIMobileDevice\Netimobiledevice\Afc\AfcService.cs:line 149 at Netimobiledevice.Afc.AfcService.Lock(UInt64 handle, AfcLockModes operation, CancellationToken cancellationToken) in A:\clients\TEC\MemoThreeFile\backupDevice\NetIMobileDevice\Netimobiledevice\Afc\AfcService.cs:line 266 at Netimobiledevice.Backup.BackupLock.<Dispose>b__5_0() in A:\clients\TEC\MemoThreeFile\backupDevice\NetIMobileDevice\Netimobiledevice\Backup\BackupLock.cs:line 27 at Netimobiledevice.Backup.BackupLock.Dispose() in A:\clients\TEC\MemoThreeFile\backupDevice\NetIMobileDevice\Netimobiledevice\Backup\BackupLock.cs:line 26 at Netimobiledevice.Backup.Mobilebackup2Service.Backup(Boolean fullBackup, String backupDirectory, CancellationToken cancellationToken) in A:\clients\TEC\MemoThreeFile\backupDevice\NetIMobileDevice\Netimobiledevice\Backup\Mobilebackup2Service.cs:line 424 at backupDevice.iOS.BackupiOS.Execute(String backupPath, String deviceIp) in A:\clients\TEC\MemoThreeFile\backupDevice\backupDevice\iOS\BackupiOS.cs:line 366"

If it helps, it's a 9th gen iPad with iOS 18.1.1 on it. I tried a couple different arguments, tried reauthorizing the device... still came up with the same issue each time.

@artehe
Copy link
Owner

artehe commented Dec 13, 2024

Hmm that's odd, it's like it's just closing the AFC connection for no reason.

One thing you could do to see if it will work is temporarily remove the InfoPlist creation which should be here, just replace it with new DictionaryNode()

I'll have to look on Monday as I'll have a few different iOS devices then to see what's going on.

@artehe
Copy link
Owner

artehe commented Dec 16, 2024

So a small update for you, I found some things and fixed them.

However it still seems to be doing the same error, when we reach this creating the info plist:

byte[] dataBuffer = await afc.GetFileContents(filePath, cancellationToken).ConfigureAwait(false) ?? [];```

The first time it runs and basically does what I expect, then the second time it comes to run the service has closed itself and I can't work out why yet.

@artehe
Copy link
Owner

artehe commented Dec 18, 2024

I fixed it 😄 turns out I'm stupid.

@MarkFassett could you give this a test when you get a moment and check that it's working properly for you please?

@MarkFassett
Copy link
Contributor Author

Oh - sorry for not seeing this - was working on a different project for a couple days :) I'll check it now.

@artehe
Copy link
Owner

artehe commented Dec 20, 2024

No worries, I did some more testing and it seems to be working properly now... I think

Feel free to re-open or create a new issue if it's still a problem or there's something new 😄

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.

2 participants