libusbmuxd icon indicating copy to clipboard operation
libusbmuxd copied to clipboard

Cannot find iPhone via network (idevice_id -n)

Open fosple opened this issue 5 years ago • 59 comments

I saw in https://github.com/libimobiledevice/libusbmuxd/blob/master/NEWS that network support was added to libusbmuxd and I'm super happy about that fact 👍

However, I don't get it working. I've compiled and installed the latest version of all the needed libraries (libimobiledevice, libplist, libusbmuxd, usbmuxd) from source on my Raspberry Pi 4 (OS: Debian Buster).

Via USB the IPhone shows up. So I connected the iPhone via USB and paired it (idevicepair pair) before I tried to connect via network.

However, after unplugging the iPhone from USB and trying to connect to it via the network I didn't get any result:

sudo usbmuxd -s -v
[19:56:08.141][3] usbmuxd v1.1.1 starting up
[19:56:08.141][4] Creating socket
[19:56:08.142][4] Initializing USB
[19:56:08.159][4] Registering for libusb hotplug events
[19:56:08.159][4] 0 devices detected
[19:56:08.159][3] Initialization complete
[19:56:08.159][3] Enabled exit on SIGUSR1 if no devices are attached. Start a new instance with "--exit" to trigger.                                                      
[19:56:11.902][4] New client on fd 11 (pid 16768)
[19:56:11.904][4] Client 11 connection closed
[19:56:11.904][4] Disconnecting client fd 11
idevice_id -n
# no result

Further infos:

  • avahi-daemon is started and running
  • ufw firewall is disabled (I thought maybe I blocked some ports accidentally)

Would be super nice if you can help me :) Or could it be that the open source version of usbmuxd does not support network connections and only the proprietary one from Apple (on Windows and MacOS) supports it which is used by libusbmuxd when available?

fosple avatar Feb 09 '20 20:02 fosple

I am working on network/mDNS capabilities for the open source usbmuxd. This will still take some time to get it done properly.

nikias avatar May 26 '20 20:05 nikias

I am working on network/mDNS capabilities for the open source usbmuxd. This will still take some time to get it done properly.

Hi, did you start your work on this? May I provide help and patches for it?

alexandre-janniaux avatar Aug 20 '20 13:08 alexandre-janniaux

Any update here? I'd love to get Wifi Sync working on Linux :)

reanimus avatar Nov 18 '20 19:11 reanimus

Any update here? I'd love to get Wifi Sync working on Linux :)

+1

cemizm avatar Dec 13 '20 13:12 cemizm

hi @nikias, any progress on network/mDNS capabilities? would love to support you on this topic, but don't know where to start... are there any developer documentations or at least a high level architecture overiew of libimobiledevice?

cemizm avatar Dec 24 '20 09:12 cemizm

May I confirm with wi-fi sync only works in Mac but not Linux?

mcdull avatar Jan 15 '21 19:01 mcdull

@mcdull WiFi sync works on Mac and Win, but not yet on Linux as there is no open source version of usbmuxd yet which supports WiFi sync.

fosple avatar May 11 '21 04:05 fosple

I have managed to get it working via WiFi sync on a rPi although a little flaky sometimes. I did install https://github.com/tihmstar/usbmuxd2 though. Not sure if I could have got it working without that.

bentumbler avatar May 26 '21 14:05 bentumbler

Wow, thanks @bentumbler for pointing out the re-implementation of usbmuxd by @tihmstar https://github.com/tihmstar/usbmuxd2 . Maybe @nikias can use it and include it in the original project 🥳

I'll give usbmuxd2 a try on the weekend.

fosple avatar May 26 '21 20:05 fosple

Hello guys,

@bentumbler - i tried to build usbmuxd2 on a rPi, but somehow i cannot make it work. I followed this tutorial: https://www.numerousnetworks.co.uk/uncategorized/untether-ios-step-by-step/

but when at the point of making usbmuxd2 i got following problem

Client.cpp:274:50: error: ‘plist_to_bin_free’ was not declared in this scope; did you mean ‘plist_to_bin’? 274 | safeFreeCustom(plistbin, plist_to_bin_free); | ^~~~~~~~~~~~~~~~~

Do you have some information how you got it to work? Or any other advice

Thanks

kozfogel avatar Dec 26 '21 22:12 kozfogel

It's possible some of the dependencies have moved on a version. Did you install them all, especially both the libplist dev dependencies

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: kozfogel @.> Sent: Sunday, December 26, 2021 10:41:01 PM To: libimobiledevice/libusbmuxd @.> Cc: Ben Toner @.>; Mention @.> Subject: Re: [libimobiledevice/libusbmuxd] Cannot find iPhone via network (idevice_id -n) (#88)

Hello guys,

@bentumblerhttps://github.com/bentumbler - i tried to build usbmuxd2 on a rPi, but somehow i cannot make it work. I followed this tutorial: https://www.numerousnetworks.co.uk/uncategorized/untether-ios-step-by-step/

but when at the point of making usbmuxd2 i got following problem

Client.cpp:274:50: error: ‘plist_to_bin_free’ was not declared in this scope; did you mean ‘plist_to_bin’? 274 | safeFreeCustom(plistbin, plist_to_bin_free); | ^~~~~~~~~~~~~~~~~

Do you have some information how you got it to work? Or any other advice

Thanks

— Reply to this email directly, view it on GitHubhttps://github.com/libimobiledevice/libusbmuxd/issues/88#issuecomment-1001250623, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AP4K3EN64D7HJUA5UXXGMNLUS6KX3ANCNFSM4KSEA5SA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you were mentioned.Message ID: @.***>

bentumbler avatar Dec 26 '21 22:12 bentumbler

i installed libplist-dev and libplist++-dev (via apt-get) and builded libplist from git (because version 2.2.1 is needed)

kozfogel avatar Dec 26 '21 22:12 kozfogel

Hi kozfogel,

installing the apt packages are unnecessary if you build libplist from git. the install step of the build process will install these.

had the same issue with the plist_to_bin_free function. it has been dropped a few days ago: https://github.com/libimobiledevice/libplist/commit/c31beaaec196c26990139e3fc4f89f996d7b86e9

In order to solve this issue you should checkout commit a9e34bd29ae9dcdae55bdf5fb8a23c9b1c02eee9

cemizm avatar Dec 27 '21 17:12 cemizm

Hi, i'm trying to build a docker image to run libimobiledevice and sync via Wifi every night.

I got some issues when I build usbmuxd2..

I also tried to follow these guide : https://www.numerousnetworks.co.uk/uncategorized/untether-ios-step-by-step/

Here's my dockerfile :

FROM ruby:2.3-slim
RUN apt-get update \
  && apt-get install -y \
    build-essential \
    checkinstall \
    git \
    autoconf \
    automake \
    libtool-bin \ 
    python-dev

RUN apt-get install -y \
  libplist-dev \
  libusbmuxd-dev \
  libimobiledevice-dev \
  libusb-1.0-0-dev \
  libplist++-dev \
  libssl-dev \
  usbmuxd \
  udev \
  libavahi-client-dev \
  avahi-utils \
  libatomic-ops-dev \
  libatomic1 \
  bluez-tools

ENV INSTALL_PATH /src
RUN mkdir -p $INSTALL_PATH

WORKDIR $INSTALL_PATH
RUN git clone https://github.com/libimobiledevice/libplist.git \
  && cd /src/libplist \
  && git checkout a9e34bd29ae9dcdae55bdf5fb8a23c9b1c02eee9 \
  && ./autogen.sh \
  && make \
  && make install
RUN ldconfig

WORKDIR $INSTALL_PATH
RUN git clone https://github.com/tihmstar/libgeneral.git \
  && cd libgeneral \
  # && git checkout 55  \
  && ./autogen.sh \
  # && make CFLAGS="-g -O2 -std=c11 -latomic" LDFLAGS=-latomic \
  && make install
RUN ldconfig

WORKDIR $INSTALL_PATH
RUN git clone https://github.com/tihmstar/usbmuxd2.git  \
  && cd /src/usbmuxd2 \
  && git submodule init \
  && git submodule update \
  && ./autogen.sh \
  && make \
  && make install
RUN ldconfig

WORKDIR $INSTALL_PATH
RUN git clone https://github.com/libimobiledevice/libimobiledevice.git \
  && cd /src/libimobiledevice \
  # && git checkout 1.3.0 \
  && ./autogen.sh \
  && make \
  && make install

RUN apt-get -y install ideviceinstaller

Do you know where I misunderstood something ?

juliienp avatar Dec 31 '21 11:12 juliienp

Do you know where I misunderstood something ?

  1. You have replied on an unrelated issue
  2. You have not posted an error message or problem

voltagex avatar Dec 31 '21 11:12 voltagex

I haven't tried to replicate your issue but I do see that you have not built libusbmuxd as per the instructions at https://www.numerousnetworks.co.uk/uncategorized/untether-ios-step-by-step/

Also, I found that to build usbmuxd2 with g++ 8.3 I needed to amend configure.ac with the following LDFLAGS+="-latomic -lstdc++fs"

Try those suggestions. Also follow the build order in the guide. If you still have issues, we need to see the build output.

bentumbler avatar Jan 02 '22 12:01 bentumbler

Here is my dockerfile which seems to work after a lot of fiddling and version matching..

https://gist.github.com/cemizm/07ed041d451c55e395856873f46f074f

It uses a small bash script as an entrypoint in order to start the required services. furthermore for the first usage you need to (re-)start usbmuxd a few times in order to create the SystemConfiguration.plist (see issue https://github.com/tihmstar/usbmuxd2/issues/6)

for the network usage of a device you need to connect the device at least once trough usb, which means you need to pass the usb bus to the container and run it in privileged mode. the public and private keys after the pairing process are stored in the data folder and are persisted between startups.

Usage:

#build the container
docker build -t usbmuxd2

#run in default mode
docker run -it --rm --name imobiledevice -v $(PWD)/data:/var/lib/lockdown/ --network host usbmuxd2

#run with usb support and privileged mode
docker run -it --rm --name imobiledevice -v $(PWD)/data:/var/lib/lockdown/ --network host --privileged -v /dev/bus/usb:/dev/bus/usb usbmuxd2

cemizm avatar Jan 02 '22 12:01 cemizm

@bentumbler @cemizm

Thanks a lot guys. I got it running on my PI4 now (i used the Docker script with some slightly changes for latomic)

It works when i connect via USB - but Wifi sadly not. Any idea where to look next? (logs, debuging, etc) usbmuxd output:

[16:28:02.685][3] TCP Connected to device [16:28:02.685][1] failed to recv_data on client -1 with error=graceful kill code=25165834 [16:28:02.686][3] killing client -1 [16:28:02.690][1] failed to recv_data on client 17 with error=client 17 disconnected! code=6946826 [16:28:02.690][3] killing client 17 [16:28:02.705][1] failed to recv_data on client 18 with error=client 18 disconnected! code=6946826 [16:28:02.705][3] killing client 18 [16:28:02.921][3] preflight_device: Finished preflight on device 00008101-00090DAE2881401D [16:28:02.923][3] killing TCP 16 [16:28:05.694][3] killing device 00008101-00090DAE2881401D [16:28:05.994][1] failed to recv_data on client 17 with error=client 17 disconnected! code=6946826 [16:28:05.994][3] killing client 17 [16:28:10.998][1] Failed to start WIFIDevice 00008101-00090DAE2881401D with error=4128790 ([WIFIDevice] Failed to start heartbeat service with error=-256) [16:28:10.999][3] killing device 00008101-00090DAE2881401D [libusbmuxd] device_info_from_plist: Failed to get EscapedFullServiceName! [16:28:11.004][1] Failed to start WIFIDevice 00008101-00090DAE2881401D with error=3997718 (assure failed) [16:28:11.004][1] failed to recv_data on client 14 with error=client 14 disconnected! code=6946826 [16:28:11.004][3] killing device 00008101-00090DAE2881401D [16:28:11.004][3] killing client 14 [16:29:27.704][1] failed to recv_data on client 15 with error=client 15 disconnected! code=6946826 [16:29:27.705][3] killing client 15 [16:29:27.705][3] Starting TCP connection [16:29:27.706][3] TCP Connected to device [16:29:27.707][1] failed to recv_data on client -1 with error=graceful kill code=25165834 [16:29:27.707][3] killing client -1 [16:29:27.711][1] failed to recv_data on client 14 with error=client 14 disconnected! code=6946826 [16:29:27.711][3] killing client 14 [16:29:27.712][1] failed to recv_data on client 15 with error=client 15 disconnected! code=6946826 [16:29:27.712][3] killing client 15 [16:29:27.719][1] failed to recv_data on client 16 with error=client 16 disconnected! code=6946826 [16:29:27.720][3] killing client 16 [16:29:27.967][3] killing TCP 10 [16:29:32.047][3] Device 1-5 RX aborted due to error or disconnect [16:29:32.048][3] Device 1-5 RX aborted due to error or disconnect

kozfogel avatar Jan 02 '22 15:01 kozfogel

@bentumbler @cemizm

Thanks a lot guys. I got it running on my PI4 now (i used the Docker script with some slightly changes for latomic)

it seems like you are not using the latest version (> 1.3.0) of libimobiledevice... please make sure that your are not using any packages (libimobiledevice, libplist, ...) from a package manager.

can you post your dockerfile?

cemizm avatar Jan 02 '22 15:01 cemizm

I am not running docker. I builded all directly on the Pi - Raspbian GNU/Linux 11 (bullseye) - fresh install.

if i am running somithing like this: ideviceinfo --version ideviceinfo 1.3.0

should it be a higher version?

kozfogel avatar Jan 02 '22 15:01 kozfogel

Did you follow the instructions related to avahi? Network connections require mDNS. Your network also needs to support mDNS. Most home networks do

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: kozfogel @.> Sent: Sunday, January 2, 2022 3:58:52 PM To: libimobiledevice/libusbmuxd @.> Cc: Ben Toner @.>; Mention @.> Subject: Re: [libimobiledevice/libusbmuxd] Cannot find iPhone via network (idevice_id -n) (#88)

I am not running docker. I builded all directly on the Pi - Raspbian GNU/Linux 11 (bullseye) - fresh install.

if i am running somithing like this: ideviceinfo --version ideviceinfo 1.3.0

should it be a higher version?

— Reply to this email directly, view it on GitHubhttps://github.com/libimobiledevice/libusbmuxd/issues/88#issuecomment-1003736965, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AP4K3EJNR5ZHNZ6W7Y2E6EDUUBY3ZANCNFSM4KSEA5SA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub. You are receiving this because you were mentioned.Message ID: @.***>

bentumbler avatar Jan 02 '22 19:01 bentumbler

I am not running docker. I builded all directly on the Pi - Raspbian GNU/Linux 11 (bullseye) - fresh install.

if i am running somithing like this: ideviceinfo --version ideviceinfo 1.3.0

should it be a higher version?

yes, it should be 1.3.1, version 1.3.0 is year and half old, and supports only devices up to ios 13

mexmer avatar Jan 03 '22 12:01 mexmer

V 1.3.0 works fine for my iOS 15 devices (at least for log capture, which is how I use it). You can move to a later version but I think you will need to ensure you build the libimobiledevice-glue library too.

bentumbler avatar Jan 03 '22 17:01 bentumbler

@bentumbler version 1.3.0 works only for limited set of features, some services changed their required protocol version (plus other minor changes), and those are updated in 1.3.1, screenshot is one of them, also backup, sync ... not sure what others. guess i should have written full support

mexmer avatar Jan 04 '22 07:01 mexmer

@kozfogel did you manage to resolve your issue? I'm having something similar:

[13:46:23.385][5] add_device 0000811000163D5A2684801E
[13:46:23.385][5] Muxer: adding device 0000811000163D5A2684801E assigning id 3
[13:46:23.385][5] [Client] initializing Client 16
[13:46:23.385][5] add_client 16
[13:46:23.385][5] Client command in fd 16 len 436 ver 1 msg 8 tag 2
[13:46:23.385][5] send_pkt fd 16 tag 2 msg 8 payload_length 946
[13:46:23.385][1] Failed to start WIFIDevice 0000811000163D5A2684801E with error=3801110 (assure failed)
[13:46:23.385][5] delete_device 0000811000163D5A2684801E
[13:46:23.385][5] delete_device 0000811000163D5A2684801E
[13:46:23.385][1] failed to recv_data on client 16 with error=client 16 disconnected! code=6750218

Looks like the device is recognized, but errors out anyway. At least it's the correct UDID.

@mexmer where can one obtain version 1.3.1?

ideviceinfo --version
ideviceinfo 1.3.0-164-gb5ce444

looks like the version string is set using git describe. I don't see a tag for 1.3.1.

dmitrym0 avatar Sep 06 '22 20:09 dmitrym0

Hi all, not sure if this issue is still actively observed, but I've also got the same issue @dmitrym0 is experiencing. I've got idevice_id version of 1.3.0-190-g6fc41f5 and successfully installed usbmuxd2 (@bentumbler I also had to do add LDFLAGS+="-latomic -lstdc++fs" to my configure.ac)

I am getting the same failed to recv_data on client 7 with error=client 7 disconnected! code=6750218

One thing I've noticed, even when I have usbmuxd running, with the below information:

[15:02:41.372][3] starting usbmuxd2 version: 0.46-753b79eaf317c56df6c8b1fb6da5847cc54a0bb0-RELEASE
[15:02:41.373][3] Loaded config
[15:02:41.373][3] starting usbmuxd2 version: 0.46-753b79eaf317c56df6c8b1fb6da5847cc54a0bb0-RELEASE
[15:02:41.374][3] Inited ClientManager
[15:02:41.374][3] USBDeviceManager libusb 1.0
[15:02:41.389][3] Registering for libusb hotplug events
[15:02:41.390][3] Inited USBDeviceManager
[15:02:41.398][3] Inited WIFIDeviceManager
[15:02:41.398][4] Initialization complete
... {usbmuxd is waiting here}

I get this when I run service usbmuxd status:

● usbmuxd.service - Socket daemon for the usbmux protocol used by Apple devices
     Loaded: loaded (/lib/systemd/system/usbmuxd.service; disabled; vendor pres>
     Active: inactive (dead)
       Docs: man:usbmuxd(8)

Is there anything we need to do with the client? I read somewhere that this might be an issue with Avahi-Client, but my Avahi is running ok, and I can confirm that when I do :

TriggeredBy: ● avahi-daemon.socket
   Main PID: 381 (avahi-daemon)
     Status: "Server startup complete. Host name is {DEVICE_NAME}.local. Local service cookie is 3412524750."
      Tasks: 1 (limit: 3933)
        CPU: 606ms
     CGroup: /system.slice/avahi-daemon.service
             └─381 avahi-daemon: running [DEVICE_NAME.local]

Jul 28 14:11:55 DEVICE_NAME systemd[1]: Started Avahi mDNS/DNS-SD Stack.
Jul 28 14:11:56 DEVICE_NAME avahi-daemon[381]: Server startup complete. Host name is DEVICE_NAME.local. Local service cookie is 3412524750.
Jul 28 14:11:57 DEVICE_NAME avahi-daemon[381]: Service "DEVICE_NAME" (/usr/local/etc/avahi/services/ssh.service) successfully established.
Jul 28 14:11:57 DEVICE_NAME avahi-daemon[381]: Service "DEVICE_NAME" (/usr/local/etc/avahi/services/sftp-ssh.service) successfully established.
Jul 28 14:12:02 DEVICE_NAME avahi-daemon[381]: Joining mDNS multicast group on interface wlan0.IPv6 with address [DEVICE_MAC_ADDRESS].
Jul 28 14:12:02 DEVICE_NAME avahi-daemon[381]: New relevant interface wlan0.IPv6 for mDNS.
Jul 28 14:12:02 DEVICE_NAME avahi-daemon[381]: Registering new address record for [DEVICE_MAC_ADDRESS] on wlan0.*.
Jul 28 14:12:07 DEVICE_NAME avahi-daemon[381]: Joining mDNS multicast group on interface wlan0.IPv4 with address [DEVICE_IP_ADDRESS].
Jul 28 14:12:07 DEVICE_NAME avahi-daemon[381]: New relevant interface wlan0.IPv4 for mDNS.
Jul 28 14:12:07 DEVICE_NAME avahi-daemon[381]: Registering new address record for [DEVICE_IP_ADDRESS] on wlan0.IPv4.

Thanks a lot and if we need any more information, please let me know and I'll find and provide it.

sepsky avatar Jul 28 '23 14:07 sepsky

@sepsky usbmuxd2 is reimplementation of usbmuxd with avahi support, so you need to direct any issue to author of usbmuxd2 https://github.com/tihmstar/usbmuxd2

mexmer avatar Aug 02 '23 07:08 mexmer

@mexmer Thanks for the message. I Have added it there too, the error is the same as the one here, so thought to add mine as well, in case the last commenter found the fix for their issue (so I can try as well. of course, if/when I receive an updates anywhere (here or for usbmuxd2), I'll update the other one too.

sepsky avatar Aug 02 '23 13:08 sepsky

on windows it works, so it's very likely something on usbmuxd2 side. although there have been some changes in source code, if you look at commits it's mostly cleanup, nothing that should cause communication break with usbmuxd (or usbmuxd2)

mexmer avatar Aug 02 '23 14:08 mexmer

Thanks @mexmer for the encouraging comment.

I think I have found the issue, but still not sure about the solution :(

So I think it's something to do with dns and socket configuration (either on pi, ATV or the network ?) I saw @bentumbler comment regarding the dns configuration, but given that my experience is apple-only (apple to apple devices, all "works" approach), I'm not well-versed in sockets and how to connect to apple devices with non-apple devices.

I'm learning about that, but if you (or @bentumbler ) have any hints / help you think would be useful for that topic, I'd greatly appreciate it.

sepsky avatar Aug 08 '23 15:08 sepsky