michaelrsweet / lprint

A Label Printer Application
https://www.msweet.org/lprint
Apache License 2.0
219 stars 29 forks source link

More analysis on Issue #93 -- that is still present in v.1.3.1 on linux #139

Closed brianbarr closed 1 month ago

brianbarr commented 2 months ago

Recap -- dymo LabelWriter 400 Turbo connected to airport extreme via USB.

The airport serves as a USB bridge to the local lan and advertises the printer using DNSSD on the lan.

Lprint 1.3.1 installed on fresh debian 12. Adding the printer in lprint works fine. Lprint finds the printer and you can set and save printing defaults. When you try to print a test page, lprint stalls and marks the printer as stopped.

Installing lprint 1.3.1 on macos as a server works perfectly. No issues.

I was able to turn on debugging on the debian install using the instructions from a previous post.

Debug log output: E [2024-04-30T07:10:32.786Z] [Device] Unable to connect to \'AA-EXTREME-2.local:9103\': Connection timed out E [2024-04-30T07:10:32.786Z] [Printer test_lprint] Unable to open device 'dnssd://DYMO%5C032LabelWriter%5C032400%5C032Turbo._pdl-datastream._tcp.local/', pausing queue until printer becomes available

Output of lpinfo command: lpinfo --include-schemes dnssd -v

dnssd://DYMO%20LabelWriter%20400%20Turbo._pdl-datastream._tcp.local/

debian lprint on the other hand is trying to use this:

dnssd://DYMO%5C032LabelWriter%5C032400%5C032Turbo._pdl-datastream._tcp.local/'

There seems to be an issue in naming conventions somewhere or a parsing error -- %5C032 is an odd number of hex digits.

michaelrsweet commented 2 months ago

Keep in mind that LPrint/PAPPL device URIs don't always match what (legacy) CUPS backends report. In particular, "%5C032" maps to "\032" which would be the escaped form of a space in a DNS name - the CUPS backend unescapes the name but the PAPPL device doesn't.

This log message is the relevant one:

E [2024-04-30T07:10:32.786Z] [Device] Unable to connect to 'AA-EXTREME-2.local:9103': Connection timed out

That is the hostname that the DNS-SD service name resolves to, with port 9103 being reported for the socket port.

Can you run the following command to see what Avahi says:

avahi-browse -r _pdl-datastream._tcp

(You'll need to CTRL-C to break out once you see all of your printers)

brianbarr commented 2 months ago

As requested:

root@debian12:~# avahi-browse -r _pdl-datastream._tcp

= ens192 IPv4 DYMO LabelWriter 400 Turbo PDL Printer local hostname = [AA-EXTREME-2.local] address = [169.254.2.254] port = [9103] txt = ["ty=DYMO LabelWriter 400 Turbo" "usb_0503000009414945678" "usb_DESCRIPTION=DYMO LabelWriter 400 Turbo" "usb_CLASS=PRINTER" "usb_MDL=LabelWriter 400 Turbo" "usb_CMD= " "usb_MFG=DYMO" "priority=5" "pdl=U" "product=(DYMO LabelWriter 400 Turbo)" "note=AA-EXTREME-2" "qtotal=1" "txtvers=1"] = ens192 IPv6 DYMO LabelWriter 400 Turbo PDL Printer local hostname = [AA-EXTREME-2.local] address = [169.254.2.254] port = [9103] txt = ["ty=DYMO LabelWriter 400 Turbo" "usb_0503000009414945678" "usb_DESCRIPTION=DYMO LabelWriter 400 Turbo" "usb_CLASS=PRINTER" "usb_MDL=LabelWriter 400 Turbo" "usb_CMD= " "usb_MFG=DYMO" "priority=5" "pdl=U" "product=(DYMO LabelWriter 400 Turbo)" "note=AA-EXTREME-2" "qtotal=1" "txtvers=1"]

The ip address(s) of the airport device using the DNS-SD/Bonjour "Discovery app" I run on my mac are (under the _pdl-datastream_tcp:

AA-EXTREME-2.local 192.168.4.122:9103 169.254.2.254:9103

As I recall , this behavior was not present in lprint 1.1 ..also is this an avahi issue perhaps? On MacOS this problem does not exist

brianbarr commented 2 months ago

It looks like avahi can find an old laserjet 4100 jetdirect card properly so this appears to be an airport/avahi issue:

= ens192 IPv4 HP LaserJet 4100 Series [F00434] PDL Printer local hostname = [HP4100-CAVE.local] address = [192.168.4.42] port = [9100] txt = ["adminurl=http://HP4100-CAVE.local." "priority=40" "product=(HP LaserJet 4100 Series )" "ty=HP LaserJet 4100 Series " "pdl=application/postscript,application/vnd.hp-PCL,application/vnd.hp-PCLXL" "qtotal=1" "txtvers=1"]

brianbarr commented 2 months ago

Would it be possible at some point in the future (for this oddball edge case) to allow lprint to add a printer by specifying the ip address and a port..? The lprint web configurator does not allow this currently. Can you manually do this (add printer IP:PORT) with a config file? If I could bypass the avahi stuff and just add the printer manually with IP:PORT I could possibly make this work. As I have lprint working fine with macos on a mac mini as a host -- this avahi disconnect is more of a resource issue. I'm going to try to put macos 11 in a VM and see if it is a workable solution.

brianbarr commented 2 months ago

Discovered all of this is a known avahi bug:

https://bugs.launchpad.net/ubuntu/+source/avahi/+bug/896688

So apologies for this wild goose chase. If adding a printer with ip:port is possible that would be a workaround.

michaelrsweet commented 2 months ago

Use "socket://IP-ADDRESS:PORT".

The web interface currently only supports port 9100 for the "Network Printer" device. I'll file a bug for this in the PAPPL project.

michaelrsweet commented 2 months ago

PAPPL issue 360 is tracking the fix for this.

michaelrsweet commented 2 months ago

I've fixed the PAPPL issue. I'll bump the snap shortly.

brianbarr commented 2 months ago

Thanks for the fix.. it will certainly make configuring lprint for non-standard devices much easier.

I discovered a somewhat elegant solution to the problem. Without delving too deep into avahi vs airport devices and how they report link-local address vs dhcp assigned addresses via DNS-SD-- this fixes the unable to connect issue by adding a route to the link-local net on the lprint server:

route add -net 169.254.0.0 netmask 255.255.0.0 dev ens192 metric 99

This seems to have worked ok. Just need to set it up to be persistent on boot.

michaelrsweet commented 1 month ago

Changes are up on snapcraft...