SimulPiscator / AirSane

Publish SANE scanners to MacOS, Android, and Windows via Apple AirScan.
GNU General Public License v3.0
251 stars 26 forks source link

Not discovered by Image Capture BigSur #57

Closed utdrmac closed 3 years ago

utdrmac commented 3 years ago

Have HP a-i-o plugged into Ubuntu server. Mac client. Printer works via CUPS. Image Capture shows no scanners. Avahi is running and mac shows it can find the scanner via avahi:

[me@maclaptop]$ dns-sd -B _uscan
Browsing for _uscan._tcp
DATE: ---Thu 15 Apr 2021---
12:12:35.754  ...STARTING...
Timestamp     A/R    Flags  if Domain               Service Type         Instance Name
12:12:35.754  Add        2  11 local.               _uscan._tcp.         Hewlett-Packard Deskjet_2050_J510_series

Any thoughts on why Image Capture can't see it?

utdrmac commented 3 years ago

Reading other issues, I confirm that ipv6 is running on my Ubuntu box and that the interface bound to AirAsane has ipv6 address:

3: enp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:25:90:a0:21:2a brd ff:ff:ff:ff:ff:ff
    inet 10.10.10.3/24 brd 10.10.10.255 scope global enp4s0
       valid_lft forever preferred_lft forever
    inet6 fe80::225:90ff:fea0:212a/64 scope link
       valid_lft forever preferred_lft forever
SimulPiscator commented 3 years ago

I can confirm that AirSane works with Big Sur, and scanners are listed in Image Capture.

After stopping airsaned via systemctl, what is the output of

sudo -u saned airsaned --debug=true --access-log=-

?

utdrmac commented 3 years ago
$ sudo -u saned airsaned --debug=true --access-log=-
git commit: 6919551 (branch master, rev 168)
build date: 2021-04-15T16:39:56Z
reading device options from '/etc/airsane/options.conf'
enumerating local devices...
sane_init(nullptr, nullptr)
sane_get_devices() ...
... sane_get_devices() -> SANE_Status Success
sane_exit()
found: hpaio:/usb/Deskjet_2050_J510_series?serial=CN15O32N2905D1 (Hewlett-Packard Deskjet_2050_J510_series)
sane_init(nullptr, nullptr)
sane_open(hpaio:/usb/Deskjet_2050_J510_series?serial=CN15O32N2905D1) -> 0x7ff0f000ea10
[source] := "Flatbed" -> reload options
sane_close(0x7ff0f000ea10)
sane_exit()
stable unique name: hpaio:Hewlett-Packard Deskjet_2050_J510_series:1
uuid: 9e6e08dd-c988-59e9-914c-53da63d6a199
published as 'Hewlett-Packard Deskjet_2050_J510_series'
listening on listening on 127.0.0.1:8091
127.0.0.1:8090
listening on listening on 192.168.117.2:8091
192.168.117.2:8090
listening on 10.10.10.203:8091
listening on 10.10.10.203:8090
listening on 172.18.0.1:8091
listening on 172.18.0.1:8090
listening on 172.17.0.1:8091
listening on 172.17.0.1:8090
listening on 10.8.2.7:8091
listening on 10.8.2.7listening on :8090
[::1]:listening on 8091
[::1]:listening on 8090
[fe80::225:90ff:fea0:212b]:8091
listening on listening on [fe80::225:90ff:fea0:212b]:8090
[fe80::225:90ff:fea0:212a]:8091
listening on [fe80::225:90ff:fea0:212a]:8090
listening on listening on [fe80::42:6bff:fe61:784a]:8090
[fe80::42:6bff:fe61:784a]:8091
listening on listening on [fe80::42:5bff:fed1:b8f]:8090
[fe80::42:5bff:fed1:b8f]:listening on 8091
[fe80::5052:7fff:fe1f:9c10]:8090
listening on listening on [fe80::5052:7fff:fe1f:9c10][fe80::a88f:87ff:fed4:21af]::8091
8090
listening on [fe80::a88f:87ff:fed4:21af]:8091
listening on [fe80::d07c:7dff:fef5:eb8e]:8090
listening on listening on [fe80::d07c:7dff:fef5:eb8e]:8091
[fe80::8c21:d1ff:fef7:23f1]:8090
listening on [fe80::8839:f4ff:fe27:fcdd]:8090
listening on [fe80::8c21:d1ff:fef7:23f1]:8091
listening on [fe80::d2:a6ff:fefd:3b3]listening on [fe80::8839:f4ff:fe27:fcdd]:8091
:8090
listening on [fe80::d2:a6ff:fefd:3b3]:listening on 8091
[fe80::e159:95a0:8656:8148]:listening on [fe80::e159:95a0:8656:8148]:8091
8090
listening on [fe80::f808:36ff:fe84:e56b]:8091
listening on listening on [fe80::2402:bfff:fe89:a190]:8091
[fe80::f808:36ff:fe84:e56b]:8090
listening on [fe80::e88d:52ff:fe61:a412]:8091
listening on [fe80::2402:bfff:fe89:a190]:8090
listening on [fe80::e88d:52ff:fe61:a412]:8090

I then opened Image Capture. No additional output occurred. No devices shown.

utdrmac commented 3 years ago

Scanning worked fine using web interface

SimulPiscator commented 3 years ago

What is striking is the sheer number of addresses that your Ubuntu machine seems to have: 192.168.117.2 172.18.0.1 172.17.0.1 10.8.2.7 10.10.10.203 and their ipv6 counterparts.

What is the output of dns-sd -Z _uscan? Can your mac resolve .local?

utdrmac commented 3 years ago

Well, when you run docker instances, a VPN, and 2 local LANs, it adds up. In /etc/default/airsane I have it restricted to only 1 of the interfaces, the internal LAN which also has the mac laptop.

Yes, mac can resolve .local just fine.

$ dns-sd -Z _uscan
Browsing for _uscan._tcp
DATE: ---Fri 16 Apr 2021---
12:26:56.295  ...STARTING...

; To direct clients to browse a different domain, substitute that domain in place of '@'
lb._dns-sd._udp                                 PTR     @

; In the list of services below, the SRV records will typically reference dot-local Multicast DNS names.
; When transferring this zone file data to your unicast DNS server, you'll need to replace those dot-local
; names with the correct fully-qualified (unicast) domain name of the target host offering the service.

_uscan._tcp                                     PTR     Hewlett-Packard\032Deskjet_2050_J510_series._uscan._tcp
Hewlett-Packard\032Deskjet_2050_J510_series._uscan._tcp SRV     0 0 8091 ubuntusvr.local. ; Replace with unicast FQDN of target host
Hewlett-Packard\032Deskjet_2050_J510_series._uscan._tcp TXT     "txtvers=1" "vers=2.0" "pdl=application/pdf,image/jpeg,image/png" "ty=Hewlett-Packard Deskjet_2050_J510_series" "note=ubuntusvr" "uuid=9e6e08dd-c988-59e9-914c-53da63d6a199" "rs=eSCL" "cs=grayscale,color" "is=platen" "duplex=F" "adminurl=http://ubuntusvr.local:8091/" "representation=http://ubuntusvr.local:8091/ScannerIcon"
utdrmac commented 3 years ago
[me@maclaptop] $ ping ubuntusvr.local
PING ubuntusvr.local (10.10.10.203): 56 data bytes
64 bytes from 10.10.10.203: icmp_seq=0 ttl=64 time=1.998 ms
^C
utdrmac commented 3 years ago

And to clarify, no I'm not running airsane within docker. Running "raw" on the server.

SimulPiscator commented 3 years ago

Then everything seems ok. I have no idea why ImageCapture does not see the scanner. Is it available through the "Printers and Scanners" control panel?

Does telnet ubuntusrv.local 8091 from the mac establish a connection?

utdrmac commented 3 years ago

The control panel shows the AIO, yes, but shows it as a printer. The printing aspect is handled through cups. Is there something in CUPS I need to enable/configure?

Telnet works:

$ telnet blacklion.local 8091
Trying fe80::225:90ff:fea0:212a...
Connected to ubuntusrv.local.
Escape character is '^]'.
GET /     (<-- I typed this)
HTTP/1.1 200 OK
content-type: text/html
content-length: 256
connection: close
utdrmac commented 3 years ago

I scan like 1 page a month, so the web interface is good enough workaround for our needs. I was just wanting it all integrated. So if you can't think of anything, no worries.

ShadesJeff commented 3 years ago

If you completely disable the IPv6 interface on the Ubuntu server, what happens?

utdrmac commented 3 years ago

This must be an issue with my mac laptop. The other mac laptop can see both printer (CUPS) and a scanner (AirSane) in the control panel and is seen in Image Capture, though it said 'waiting on scanner' for 60s before erroring out and I haven't dug more into that.

ShadesJeff commented 3 years ago

I would bet both symptoms are due to an IPv6 routing issue. Disabling IPv6 on the server should resolve it by forcing AIC to fallback to IPv4. It is tricky on Ubuntu to disable IPv6 and have it survive reboots... adding a flag to the grub boot load command seems to be the most effective method.

cachrisman commented 3 years ago

I'm having the same issue. My server is a raspberry pi running Octopi 0.18.0 which is based on my most recent version of Raspbian with the linux kernel 5.10.17-v7+ and my client is a Macbook Pro running macOS Big Sur 11.4. I can see the published scanner using dns-sd as well as the Discovery app but Image Capture and Preview do not see it for some reason.

Here's the output of sudo -u saned airsaned --debug=true --access-log=-

git commit: 701d5d3 (branch master, rev 171)
build date: 2021-07-02T12:00:48Z
reading device options from '/etc/airsane/options.conf'
enumerating local devices...
sane_init(nullptr, nullptr)
sane_get_devices() ...
... sane_get_devices() -> SANE_Status Success
sane_exit()
found: hpaio:/usb/Officejet_4620_series?serial=CN2CO230R005S1 (Hewlett-Packard Officejet_4620_series)
sane_init(nullptr, nullptr)
sane_open(hpaio:/usb/Officejet_4620_series?serial=CN2CO230R005S1) -> 0x7520de68
[source] := "Flatbed" -> reload options
[source] := "ADF" -> reload options
sane_close(0x7520de68)
sane_exit()
stable unique name: hpaio:Hewlett-Packard Officejet_4620_series:1
uuid: de6c812f-7e2d-55f9-92d1-0acf7c9b3d30
/etc/airsane/options.conf: regex 'hpaio:.*' matches device name 'hpaio:/usb/Officejet_4620_series?serial=CN2CO230R005S1'
published as 'Hewlett-Packard Officejet_4620_series'
listening on 127.0.0.1:8090listening on 127.0.0.1:8091

listening on 192.168.0.5:8091
listening on 192.168.0.5:8090

and I have dns-sd -B _uscan running on my macbook before I started airsaned and it shows the service being registered when airsaned starts:

➜  ~ dns-sd -B _uscan                                                                             
Browsing for _uscan._tcp
DATE: ---Mon 05 Jul 2021---
10:58:50.337  ...STARTING...
Timestamp     A/R    Flags  if Domain               Service Type         Instance Name
10:58:56.100  Add        2  13 local.               _uscan._tcp.         Hewlett-Packard Officejet_4620_series

I get the same results when IPv6 is enabled, but I've also disabled IPv6 on both the client and the server and confirmed that the client is connecting via IPv4 by running telnet octopi.local 8091 which gives me this output on the client:

Trying 192.168.0.5...
Connected to octopi.local.
Escape character is '^]'.
GET /                                         <--- I typed this line
HTTP/1.1 200 OK
content-type: text/html
content-length: 256
connection: close

<!DOCTYPE HTML>
<html>
<head>
<meta charset='utf-8'/>
<title>Error 400: Bad Request</title>
<style>body { font-family:sans-serif }
</style>
</head>
<body>
<h1>Error 400: Bad Request</h1>
<p>when processing request: </p>

<p>GET / <br>
</p>
</body>
</html>
Connection closed by foreign host.

and this output on the server:

192.168.0.50 - - [05/Jul/2021:11:03:12 +0200] "GET /" 200 256 "" ""

Here is the output of dns-sd -Z _uscan:

Browsing for _uscan._tcp
DATE: ---Mon 05 Jul 2021---
11:04:48.050  ...STARTING...

; To direct clients to browse a different domain, substitute that domain in place of '@'
lb._dns-sd._udp                                 PTR     @

; In the list of services below, the SRV records will typically reference dot-local Multicast DNS names.
; When transferring this zone file data to your unicast DNS server, you'll need to replace those dot-local
; names with the correct fully-qualified (unicast) domain name of the target host offering the service.

_uscan._tcp                                     PTR     Hewlett-Packard\032Officejet_4620_series._uscan._tcp
Hewlett-Packard\032Officejet_4620_series._uscan._tcp SRV     0 0 8091 octopi.local. ; Replace with unicast FQDN of target host
Hewlett-Packard\032Officejet_4620_series._uscan._tcp TXT     "txtvers=1" "vers=2.0" "pdl=application/pdf,image/jpeg,image/png" "ty=Hewlett-Packard Officejet_4620_series" "note=octopi" "uuid=de6c812f-7e2d-55f9-92d1-0acf7c9b3d30" "rs=eSCL" "cs=grayscale,color" "is=platen,adf" "duplex=F" "adminurl=http://octopi.local:8091/" "representation=http://octopi.local:8091/ScannerIcon"

My macbook can resolve .local names using mdns. I ran sudo killall -HUP mDNSResponder;sudo killall mDNSResponderHelper;sudo dscacheutil -flushcache to flush my DNS cache and then I ran dns-sd -G v4v6 octopi.local with the v4v6 option just to check that it wasn't getting an IPv6 address and got this output:

DATE: ---Mon 05 Jul 2021---
11:06:20.350  ...STARTING...
Timestamp     A/R    Flags if Hostname                     Address                            TTL
11:06:20.351  Add 40000002 13 octopi.local.                192.168.0.5                        120

Airsane is running properly on the server, from my mac I'm able to properly find and query the scanner published using CLI tools, but Image Capture and Preview don't see it.

Any ideas or further troubleshooting that I can do? 🙏

SimulPiscator commented 3 years ago

It seems you have not enabled IPv6 on your Raspberry Pi. Enabling it might help.

cachrisman commented 3 years ago

I've tried it with IPv6 enabled and without IPv6 enabled and I get the same result

cachrisman commented 3 years ago

But rebooting my MacBook fixed the problem. I can now see the scanner from the File menu in Preview and scan remotely. There must be some process/daemon in macOS that needs to be restarted to update the scanners listed, but a reboot does the trick.

Thanks for the help and thanks for the software!!