ippusbxd icon indicating copy to clipboard operation
ippusbxd copied to clipboard

eSCL is not advertised, if system booted with network cable unplugged

Open alexpevzner opened this issue 4 years ago • 58 comments

One of my users reported an issue, that eSCL is not advertised, if at the system boot time network cable is not plugged in:

https://github.com/alexpevzner/sane-airscan/issues/27

What is interesting, IPP printer is advertised, while eSCL scanner is not.

I've tried to investigate the problem by myself, but unfortunately, I was not able to reproduce it locally.

alexpevzner avatar May 15 '20 12:05 alexpevzner

Hi @alexpevzner I wonder if it has something to do with that. A tip didn't come through, so I'm jumping! https://github.com/OpenPrinting/ippusbxd/issues/32

ThierryHFR avatar May 15 '20 14:05 ThierryHFR

I'm not sure these bugs are related. IPP printer still advertised. When process crashes, Ahavi removes all advertisings made by the process.

The sane-airscan bug I've mentioned before contains output of the avahi-browse -rt -a command

alexpevzner avatar May 15 '20 14:05 alexpevzner

I really think it's related, issue #32 was planting ippusbxd. All I did was consider the mistake. If the value is zero, I'm out, so I invalidate the record. I will try to test this weekend on Canon IR C3250i hoping that it is close enough to the camera in question.

ThierryHFR avatar May 15 '20 15:05 ThierryHFR

Why it works differently when network cable is connected and when not connected?

alexpevzner avatar May 15 '20 15:05 alexpevzner

Indeed the question is excellent. Maybe avahi is looking for a network and takes more time (hypothesis).

ThierryHFR avatar May 15 '20 15:05 ThierryHFR

But IPP printer is advertised in both cases...

alexpevzner avatar May 15 '20 16:05 alexpevzner

ippusbxd serves for using the device via USB, this is fully independent of whether there is also a network connection available between your computer and your printer. Generally, it should be easier and more reliable to use your multi-function device via network, especially via wired ethernet. Also a network connection allows easy sharing of the device. Advanatage of the USB connection is the possibility to use the device without any network available (but note that some devices use Wi-Fi Direct and so are their own access point, allowing for using them without (W)LAN available) or if confidential data is supposed to be printed or scanned, so that spying on the network will be impossible.

tillkamppeter avatar May 15 '20 16:05 tillkamppeter

Hi @tillkamppeter,

in both cases, device connected to USB and accessed through localhost:60000. The difference is if the network cable connected to the computer at the boot time or not. If connected, eSCL service is advertised, if not connected, it is not advertised. IPP printer advertised in both cases.

alexpevzner avatar May 15 '20 16:05 alexpevzner

First, if the network cable is not connected to the computer, does the computer have any network interface (like Wi-Fi for example) or does it have no internet connection at all, leaving "lo" as the only network interface? Is there in this case any DNS-SD advertisement of the printer by Avahi? Is it only the printing part (-tcp._ipp) and not the scanning part (_tcp._uscan)? Is ipp-usb doing this correctly? @Ordissimo, you have added the advertising of the scanner part to ippusbxd, can you have a look? Thanks.

tillkamppeter avatar May 15 '20 16:05 tillkamppeter

I believe, if cable is not connected, there is only loopback interface, though I didn't ask explicitly. Yes, _ipp._tcp is advertised, _uscan._tcp is not.

And BTW, I requested user to send me a full dump of whatever Avahi discovers. Even if network cable is connected, everything Avahi reports in on loopback anyway.

About ipp-usb, I've asked to try with it, but have no response yet.

alexpevzner avatar May 15 '20 16:05 alexpevzner

@tillkamppeter, yeah, I'll take a look. Thank's @alexpevzner

ThierryHFR avatar May 15 '20 17:05 ThierryHFR

@alexpevzner it's the scanner detection that's not working. nothing to do with avahi. either the http request failed or the returned xml is invalid. we need to debug ippusbxd. you think that's possible?

ThierryHFR avatar May 15 '20 21:05 ThierryHFR

XML should be the same when network cable connected and when not.

I suggest to read source code very carefully and try to understand, what is the difference between _ipp._tcp and _uscan._tcp advertising. Actually, I've tried by myself and have not found anything seriously wrong, but you know this code better, plus functions/variables names are in French :-)

I tried to reproduce the problem, but without success. Please note, Avahi version there is 0.8, I tried with 0.7. Avahi behaviour may be slightly different, when there is no real network connections.

alexpevzner avatar May 15 '20 21:05 alexpevzner

This is where it fails, an http request and an xml parsing. I'm leaning towards the http request, but no guarantee.

if (is_scanner_present(scanner, g_options.real_port) == 0 || scanner == NULL)
     goto noscanner;

ThierryHFR avatar May 15 '20 21:05 ThierryHFR

I've given it multiple tries. I never reproduce the bug I mentioned. We'll need more information to understand the problem. With and without cable, with and without Wi-Fi

Version du serveur  : avahi 0.7 ; nom d'hôte  : thierry-Inspiron-5480.local
Domaine E Ifce Prot Nom                                           Type            
+     lo IPv4 DCP-L2530DW series                            Web Site             local
+     lo IPv4 DCP-L2530DW series                            _uscan._tcp          local
+     lo IPv4 DCP-L2530DW series                            Internet Printer     local
+     lo IPv4 DCP-L2530DW series                            UNIX Printer         local
=     lo IPv4 DCP-L2530DW series                            Web Site             local
   hostname = [thierry-Inspiron-5480.local]
   address = [127.0.0.1]
   port = [60000]
   txt = []
=     lo IPv4 DCP-L2530DW series                            _uscan._tcp          local
   hostname = [thierry-Inspiron-5480.local]
   address = [127.0.0.1]
   port = [60000]
   txt = ["txtvers=1" "vers=2.63" "rs=eSCL" "ty=Brother DCP-L2530DW series" "pdl=application/pdf,image/jpeg" "cs=binary,grayscale,color" "duplex=F" "adminurl=http://127.0.0.1:60000/net/net/airprint.html" "UUID=e3248000-80ce-11db-8000-c0b5d7e62277" "note=" "representation=http://127.0.0.1:60000/icons/device-icons-128.png"]
=     lo IPv4 DCP-L2530DW series                            Internet Printer     local
   hostname = [thierry-Inspiron-5480.local]
   address = [127.0.0.1]
   port = [60000]
   txt = ["rfo=ipp/faxout" "Fax=T" "Duplex=T" "PaperMax=legal-A4" "URF=W8,CP1,IS4-1,MT1-3-4-5-8,OB10,PQ3-4-5,RS300-600-1200,V1.4,DM1" "pdl=application/octet-stream,image/urf,image/pwg-raster" "product=(Brother DCP-L2530DW series[en])" "ty=Brother DCP-L2530DW series[en]" "note=" "Color=F" "kind=document,envelope,label,postcard" "mopria-certified=1.3" "UUID=e3248000-80ce-11db-8000-c0b5d7e62277" "adminurl=http://127.0.0.1:60000/net/net/airprint.html" "qtotal=1" "txtvers=1" "priority=60" "usb_MDL=DCP-L2530DW series" "usb_MFG=Brother" "rp=ipp/print"]

ThierryHFR avatar May 16 '20 11:05 ThierryHFR

My laptop has no Wi-Fi. May my scanner have some problem... Anyway, I will try another scanner and the ipp-usb next week.

tangyanli avatar May 16 '20 12:05 tangyanli

Could you be more specific? Your distribution and its version. The version of ippusbxd.

ThierryHFR avatar May 16 '20 14:05 ThierryHFR

Hi @Ordissimo,

I've already gathered all information here: https://github.com/alexpevzner/sane-airscan/issues/27 In short, this is Ubuntu 20.04 with ippusbxd_1.34-2.

There is also Debian 10 with the same ippusbxd version and Avahi 0.8, there _uscan._tcp is not advertised at all, regardless of network cable.

Please, follow the link above. There are also various logs, which I didn't duplicate here.

alexpevzner avatar May 16 '20 16:05 alexpevzner

Thank's @alexpevzner I saw him after I asked. I need ippusbxd's log. I know where the code fails, I don't know if it's the http request or if the content returned is wrong to be xml.

ThierryHFR avatar May 16 '20 17:05 ThierryHFR

@Ordissimo There are another infor that I didn’t mention in the alexpevzner/sane-airscan#27. Hope it’s helpful. (1) My scanner is always connected to the network. (2) On debian 10, the deamon process (Udev?) seems not to call the ippusbxd. So after OS startup, I invoke the ippusbxd manually (# ippusbxd —bus-device xx:xx —from-port 60000). And I still work out to find way to invoke ippusbxd by deamon process (Udev?)

At first, I think it’s only little issue for airscan-discover. Still now, I don’t know how to get ippusbxd log. So I may need more time ...

tangyanli avatar May 16 '20 22:05 tangyanli

ippusbxd -d

It will print a lot of debug output to stdout

Do you have both Debian and Ubuntu on a same machine?

alexpevzner avatar May 16 '20 22:05 alexpevzner

Yes, they are on the same machine. May my laotop have some problem...

tangyanli avatar May 16 '20 22:05 tangyanli

@tangyanli Added debug to the ippusbxd service

sed -i 's/ippusbxd --bus-device/ippusbxd -d --bus-device/g' /lib/systemd/system/[email protected]

Retrieve logs

cat /var/log/syslog | grep -i ippusbxd

ThierryHFR avatar May 17 '20 11:05 ThierryHFR

@Ordissimo Thanks a lot, I got it. The scanner is in my office. I will retrieve the log tomorrow morning. I am really sorry for not giving feedback as quick as possible on the weekend.

tangyanli avatar May 17 '20 12:05 tangyanli

@Ordissimo After adding "-d", the phenomenon on Ubuntu20.04 made me confused. But on Debian10, it's clear.

My laptop has no network cable plugged-in. The scanner is connected to laptop via USB. I plugged-in and removed the USB cable three times. Each time, I invoked the ippusbxd manually, the phenomenon are the same: Only IPP is advertised.

ippusbxd1.log ippusbxd2.log ippusbxd3.log

I plugged the network cable into my laptop for a while and then disconnected it. Connected the scanner via USB once again and invoked the ippusbxd manually. This time, both the IPP and eSCL are advertised.

ippusbxd4.log

Are these log useful? If not, I can summarize the phenomenon on Ubuntu20.04. It seems the "-d" influences the timeout.

tangyanli avatar May 18 '20 03:05 tangyanli

@tangyanli Thanks for the logs : Fails :

  1. ippusbxd1.log => ligne 24131 => Capabilites[(null)]
  2. ippusbxd2.log => ligne 1184 => Capabilites[(null)]
  3. ippusbxd3.log => ligne 1185 => Capabilites[(null)]

Ok :

  1. ippusbxd4.log => ligne 2202 => Capabilites[<?xml ver...]

The HTTP request always fails at startup with error 405. The problem can have several causes: 1 - The HTTP device initialization is not yet available. The solution is to postpone the launch of ippusbxd. 2 - cups for HTTP request was not a judicious choice. The solution is to use libcurl. 3 - I can't find the xml correctly.

@tillkamppeter and @alexpevzner, I'd like your opinion!

ThierryHFR avatar May 18 '20 07:05 ThierryHFR

I would start trying with (1), simply add some loop which repeats on failure and quites after a certain number of failed attempts.

tillkamppeter avatar May 18 '20 07:05 tillkamppeter

HTTP 405 is "Method not allowed".

GET unlikely to be not allowed. I'd put on uninitialized variable.

alexpevzner avatar May 18 '20 08:05 alexpevzner

Oh, now I see.

Failed attempt:

HEAD /eSCL/ScannerCapabilities HTTP/1.1
HTTP/1.1 405 Met hod Not Allowed

Successful attempt:

GET /eSCL/ScannerCapabilities HTTP/1.1
HTTP/1.1 200 OK

Somebody should understand, when libcups uses HEAD method instead of GET. Browsers use HEAD instead of GET to check if cache is still valid. But libcups is not browser...

alexpevzner avatar May 18 '20 09:05 alexpevzner

@alexpevzner, Thanks for the analysis! I'm still doing a GET request, the error is in the HTTP header.

@tillkamppeter I'm trying this approach to make sure we solve the problem. I think the problem lives of libcups as @alexpevzner suggests 1.

@tangyanli You will find ippusbxd for ubuntu-20.04 and debian buster. Can you test it? 1.34

ThierryHFR avatar May 18 '20 09:05 ThierryHFR