pymobiledevice3 icon indicating copy to clipboard operation
pymobiledevice3 copied to clipboard

Device is not connected

Open wangyu0305 opened this issue 1 year ago • 21 comments
trafficstars

Test environment

  • Host OS version - Mac 14.3
  • Target device model and iOS version - ios 17.2.1

Describe the bug A clear and concise description of what the bug is.

When I connect my iphone with usb and run this sudo python3 -m pymobiledevice3 remote start-tunnel I got this error: main[29471] ERROR Device is not connected

I can run pymobiledevice3 usbmux list [ { "BuildVersion": "21C66", "ConnectionType": "USB", "DeviceClass": "iPhone", "DeviceName": "-.-", "Identifier": "00008110-001978382E53801E", "ProductType": "iPhone14,5", "ProductVersion": "17.2.1" } ] and pymobiledevice3 mounter auto-mount pymobiledevice3.restore.tss[29154] INFO Sending TSS request... pymobiledevice3.restore.tss[29154] INFO response successfully received pymobiledevice3.cli.mounter[29154] INFO DeveloperDiskImage mounted successfully

sudo python3 -m pymobiledevice3 remote tunneld Password: INFO: Started server process [6253] uvicorn.error[6253] INFO Started server process [6253] INFO: Waiting for application startup. uvicorn.error[6253] INFO Waiting for application startup. INFO: Application startup complete. uvicorn.error[6253] INFO Application startup complete. INFO: Uvicorn running on http://127.0.0.1:5555 (Press CTRL+C to quit) uvicorn.error[6253] INFO Uvicorn running on http://127.0.0.1:5555 (Press CTRL+C to quit)

But can't run this sudo python3 -m pymobiledevice3 remote start-tunnel to get host and port. My goal is to set gps location with this command pymobiledevice3 developer dvt simulate-location set --rsd HOST PORT -- x y

I tried with a different USB and restart usbmux but nothing works, what else can I try and debug on this?

For community

⬇️ Please click the 👍 reaction instead of leaving a +1 or 👍 comment

wangyu0305 avatar Feb 29 '24 14:02 wangyu0305

Sounds like your device is not responding for the bonjour service. Please verify using:

sudo pymobiledevice3 remote browse

doronz88 avatar Feb 29 '24 15:02 doronz88

@doronz88 Yeah, I don't see any response from this command, is there a way to fix it?

sudo pymobiledevice3 remote browse []

wangyu0305 avatar Feb 29 '24 15:02 wangyu0305

Try to increase the command timeout for searching and see if this helps

doronz88 avatar Feb 29 '24 19:02 doronz88

You mean download pymobiledevice3 source code and increase timeout in source code? and not sure if increase command timeout would work, I have tried to restart bonjour service on mac, restart network router, reset network setting on iphone, restart both mac and iphone. None of the above worked. What should I check next?

wangyu0305 avatar Feb 29 '24 20:02 wangyu0305

https://github.com/doronz88/pymobiledevice3/blob/81b8ff407d0ede9868aec732d08159ae939f3c46/pymobiledevice3/remote/bonjour.py#L49 Try to change that timeout from 1 to 10 for example

doronz88 avatar Mar 01 '24 09:03 doronz88

Still no luck, I increased timeout to 60s but still got nothing. What is this option --pair-records for pymobiledevice3 bonjour browse ? It seems I don't get anything from this response https://github.com/doronz88/pymobiledevice3/blob/81b8ff407d0ede9868aec732d08159ae939f3c46/pymobiledevice3/bonjour.py#L71 No error message, don't know what's going on there, is this service name SERVICE_NAME: str = '_apple-mobdev2._tcp.local.' correct for ios 17.2.1 ?

wangyu0305 avatar Mar 01 '24 14:03 wangyu0305

Also facing this same exact issue

vijaymuralidhara avatar Mar 02 '24 01:03 vijaymuralidhara

The remote browse and bonjour browse are completely unrelated. I was talking about the first one

doronz88 avatar Mar 02 '24 11:03 doronz88

Yes @doronz88 I tried increasing timeout for remote browse as well, got nothing, I tried to print what's going on there in this function get_remoted_addresses

def get_remoted_addresses(timeout: float = 60) -> List[str]: print("get remote address") if sys.platform == 'win32': ips = [f'{adapter.ips[0].ip[0]}%{adapter.ips[0].ip[2]}' for adapter in get_adapters() if adapter.ips[0].is_IPv6] else: ips = [f'{adapter.ips[0].ip[0]}%{adapter.nice_name}' for adapter in get_adapters() if adapter.ips[0].is_IPv6] bonjour_queries = [query_bonjour(adapter) for adapter in ips] print(bonjour_queries) time.sleep(timeout) addresses = [] for bonjour_query in bonjour_queries: addresses += bonjour_query.listener.addresses bonjour_query.service_browser.cancel() bonjour_query.zc.close() return addresses

sudo python3.9 ./pymobiledevice3/pymobiledevice3/main.py remote browse [BonjourQuery(zc=<zeroconf._core.Zeroconf object at 0x11d656310>, service_browser=<ServiceBrowser(zeroconf-ServiceBrowser-_remoted._tcp-3300038, started daemon 6127890432)>, listener=<pymobiledevice3.remote.bonjour.RemotedListener object at 0x11d67d7f0>), BonjourQuery(zc=<zeroconf._core.Zeroconf object at 0x11d67d820>, service_browser=<ServiceBrowser(zeroconf-ServiceBrowser-_remoted._tcp-3300041, started daemon 6161543168)>, listener=<pymobiledevice3.remote.bonjour.RemotedListener object at 0x11d67db80>), BonjourQuery(zc=<zeroconf._core.Zeroconf object at 0x11d68f280>, service_browser=<ServiceBrowser(zeroconf-ServiceBrowser-_remoted._tcp-3300043, started daemon 6195195904)>, listener=<pymobiledevice3.remote.bonjour.RemotedListener object at 0x11d68fa00>), BonjourQuery(zc=<zeroconf._core.Zeroconf object at 0x11d68f2b0>, service_browser=<ServiceBrowser(zeroconf-ServiceBrowser-_remoted._tcp-3300045, started daemon 6228848640)>, listener=<pymobiledevice3.remote.bonjour.RemotedListener object at 0x11d69a070>), BonjourQuery(zc=<zeroconf._core.Zeroconf object at 0x11d69a640>, service_browser=<ServiceBrowser(zeroconf-ServiceBrowser-_remoted._tcp-3300047, started daemon 6262501376)>, listener=<pymobiledevice3.remote.bonjour.RemotedListener object at 0x11d69abb0>), BonjourQuery(zc=<zeroconf._core.Zeroconf object at 0x11d69f040>, service_browser=<ServiceBrowser(zeroconf-ServiceBrowser-_remoted._tcp-3300049, started daemon 6296154112)>, listener=<pymobiledevice3.remote.bonjour.RemotedListener object at 0x11d69f7c0>), BonjourQuery(zc=<zeroconf._core.Zeroconf object at 0x11d69f0d0>, service_browser=<ServiceBrowser(zeroconf-ServiceBrowser-_remoted._tcp-3300051, started daemon 6329806848)>, listener=<pymobiledevice3.remote.bonjour.RemotedListener object at 0x11d69fb50>), BonjourQuery(zc=<zeroconf._core.Zeroconf object at 0x11d6ad400>, service_browser=<ServiceBrowser(zeroconf-ServiceBrowser-_remoted._tcp-3300053, started daemon 6363459584)>, listener=<pymobiledevice3.remote.bonjour.RemotedListener object at 0x11d6adb80>), BonjourQuery(zc=<zeroconf._core.Zeroconf object at 0x11d6ad430>, service_browser=<ServiceBrowser(zeroconf-ServiceBrowser-_remoted._tcp-3300055, started daemon 6397112320)>, listener=<pymobiledevice3.remote.bonjour.RemotedListener object at 0x11d6b71f0>)] []

can you take a look? where should I debug into?

wangyu0305 avatar Mar 02 '24 17:03 wangyu0305

This bonjour_query.listener.addresses https://github.com/doronz88/pymobiledevice3/blob/81b8ff407d0ede9868aec732d08159ae939f3c46/pymobiledevice3/remote/bonjour.py#L58 addresses are added from here https://github.com/doronz88/pymobiledevice3/blob/81b8ff407d0ede9868aec732d08159ae939f3c46/pymobiledevice3/remote/bonjour.py#L20 right? but I don't see where this add_service function got called.

wangyu0305 avatar Mar 02 '24 18:03 wangyu0305

I would verify the device is in dev mode

doronz88 avatar Mar 03 '24 06:03 doronz88

I would verify the device is in dev mode

Yes, it is in developer mode

wangyu0305 avatar Mar 03 '24 15:03 wangyu0305

Dunno, sounds like the OS doesn't yet see the device. Try either to reconnect or reboot the workstation/idevice

doronz88 avatar Mar 03 '24 15:03 doronz88

@doronz88 just checking if you tested this tool with ios 17.2 and macos 14.3? does it work for you?

wangyu0305 avatar Mar 06 '24 17:03 wangyu0305

yeah, works great - also for 17.4 with 14.3.1

doronz88 avatar Mar 06 '24 18:03 doronz88

I would recommand maybe trying to see if XCode can recognize your device for debugging specifically. Could be a hardware issue

doronz88 avatar Mar 06 '24 18:03 doronz88

@wangyu0305 Have you figured out this problem? Cause I just encountered it. Any suggestion?

onlyzyz avatar Apr 03 '24 06:04 onlyzyz

I'm seeing this for both iOS devices I have. Other commands work though still in the evaluation phase.

Windows 10 Pro 22H2

c:\Users\jjensen\source\repos\pymobiledevice3>python3 -m pymobiledevice3 developer dvt sysmon process single [?] choose device: <PlistUsbmuxLockdownClient ID:00008110-000225AC0A52801E VERSION:17.0.3 TYPE:iPhone14,2 PAIRED:True> ❯ <PlistUsbmuxLockdownClient ID:00008110-000225AC0A52801E VERSION:17.0.3 TYPE:iPhone14,2 PAIRED:True> <PlistUsbmuxLockdownClient ID:00008101-001C29243630001E VERSION:17.0.2 TYPE:iPhone13,2 PAIRED:True>

2024-04-15 15:04:04 SEA-WSWN main[19636] ERROR Device is not connected

I'm running the tunnel in another CMD window and for command execution I see a "200 ok" issued. c:\Users\jjensen\source\repos\pymobiledevice3>python3 -m pymobiledevice3 remote tunneld --usb 2024-04-15 14:43:56 SEA-WSWN-00659 wintun[4016] INFO WetestUsbFilter driver use current version: 11.36.33.666, [11.36.33.666] tested. 2024-04-15 14:43:56 SEA-WSWN-00659 wintun[4016] INFO WeTestUsbNcm driver use current version: 11.36.59.886, [11.36.59.886] tested. 2024-04-15 14:43:56 SEA-WSWN-00659 wintun[4016] INFO use existing WeTestUsbFilter driver. 2024-04-15 14:43:56 SEA-WSWN-00659 wintun[4016] INFO use existing WeTestUsbNcm driver. INFO: Started server process [4016] INFO: Waiting for application startup. INFO: Application startup complete. INFO: Uvicorn running on http://127.0.0.1:49151 (Press CTRL+C to quit) INFO: 127.0.0.1:59866 - "GET / HTTP/1.1" 200 OK INFO: 127.0.0.1:59966 - "GET / HTTP/1.1" 200 OK INFO: 127.0.0.1:60341 - "GET / HTTP/1.1" 200 OK

I did also re-enable each phone in debug mode and restarted.

jjensen554git avatar Apr 15 '24 22:04 jjensen554git

Looks like the WeTest drivers don't do their job. I recommend updating to iOS 17.4+ and even removing these drivers:

pymobiledevice3 remote uninstall-wetest-drivers

doronz88 avatar Apr 16 '24 13:04 doronz88

"pymobiledevice3 remote uninstall-wetest-drivers" - am I missing something? - running this as a command produces "no such command..." I have updated to 17.4.1 as well. Thx

jjensen554git avatar Apr 16 '24 20:04 jjensen554git

Make sure you are on latest pymobile's release. You can verify using pymobiledevice3 version

doronz88 avatar Apr 16 '24 20:04 doronz88

I have encountered a similar issue on Windows where the Bonjour service cannot discover devices. For a device with iOS 17.3, when executing python -m pymobiledevice3 usbmux list, the output is as follows:

[
    {
        "BuildVersion": "21D50",
        "ConnectionType": "USB",
        "DeviceClass": "iPhone",
        "DeviceName": "BD's iPhone",
        "Identifier": "00008130-001A75222EE0001C",
        "ProductType": "iPhone16,2",
        "ProductVersion": "17.3",
        "UniqueDeviceID": "00008130-001A75222EE0001C"
    }
]

After changing the bonjour_timeout to 60 in win_util.py and executing python -m pymobiledevice3 remote start-tunnel, the error message is: "Device is not connected".

Executing python -m pymobiledevice3 remote browse returns the following result:

{
    "usb": [],
    "wifi": []
}

Even after trying different Windows computers and devices with lower iOS versions, python -m pymobiledevice3 remote browse still cannot discover devices.

However, when executing python -m pymobiledevice3 remote tunneld, everything is correct.

INFO:     Started server process [17712]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
INFO:     Uvicorn running on http://127.0.0.1:49151/ (Press CTRL+C to quit)
INFO:     [127.0.0.1:64773](http://127.0.0.1:64773/) - "GET /hello HTTP/1.1" 200 OK
INFO:     [127.0.0.1:64774](http://127.0.0.1:64774/) - "GET /hello HTTP/1.1" 200 OK
INFO:     [127.0.0.1:64787](http://127.0.0.1:64787/) - "GET /hello HTTP/1.1" 200 OK

ruokbb avatar Jun 03 '24 10:06 ruokbb

@ruokbb Looks like tunneld also doesn't see any connected device as expected on a windows platform with a connected device with iOS < 17.4 and no additional driver installed

Also, this thread was for macOS and completely unrelated to your issue

doronz88 avatar Jun 03 '24 13:06 doronz88

  • I'm closing this issue since pymobile has made a lot of changes since then.
  • Also, the implementation for tunnels is very different on each platform and therefore should be discussed in seperate issues if anything occrs.
  • Feel free to create new issues with your precise setup if you need any help

doronz88 avatar Jun 03 '24 13:06 doronz88