network printer "sleeps" for ages

I have installed network printer (Kyocera) configured to work with lpr (and with cups). The first print job goes almost immediately, but with each next job chance for a long lag is growing. So, if I send some fifth job to a queue I can be put waiting for several minutes! The job stays in queue, the printer is idle and the job is as simple as it was when it went immediately, and the network is working.
What can be wrong? Where to look?
 
You should not be using LPR/LPD and CUPS at the same time in a system (PC)

You can have enable LPR/LPD and CUPS in the printer at the same time (I recommend leaving only 1)

I can help with LPR/LPD, post your config in /etc/printcap for the printer
 
Code:
lp:\
    :lp=9100@192.168.1.35:\
    :sh:\
    :mx#0:\
    :if=/usr/local/libexec/psif:\
    :sd=/var/spool/lpd/lp:\
    :lf=/var/log/lpd-errs:
And psif:
Code:
#!/bin/sh

IFS="" read -r first_line
first_chars=`expr "$first_line" : '\(....\)'`
case $first_chars in
%!PS|%PDF)
    ( echo "$first_line" ; cat ) | /usr/local/bin/gs -dSAFER -dNOPAUSE -dBATCH -r600 -q -sDEVICE=pxlmono -sOutputFile=- - && exit 0
    exit 2
    ;;
*)
    echo "$first_line" && cat && exit 0
    exit 2
    ;;
esac
I do not use CUPS, but today's office suites like Libreoffice or Firefox want it or nothing usually. (More than that CUPS' driver for my Kyocera cannot use its 600 dpi etc.)
 
UPD. When I make printing via nc the situation is the same. The first attempt usually fast to execution, next ones more probably to "hang" longer.
So, may be it is more general network problem.
 
lpc status says
Code:
lp:
    queuing is enabled
    printing is enabled
    1 entry in spool area
    sending to 192.168.1.35 port 9100
lpq shows the task in queue
lpd-errs has only lines like this:
Code:
Dec 20 10:15:14 192 lpd[895]: lpd startup: logging=0
messages has nothing about lp apart from what is in lpr-errs
So, no obvious error messages, just up to tens of minutes waiting.
 
What option makes the printer work?

1.- Try restarting the daemon
Code:
lpc abort lp
lpc up lp

2.- Power off and on the printer and run lpc restart lp

If the problem persist, try with this printcap

Code:
lp:\
    :lp=:\
    :rm=192.168.1.35:\
    :rp=lp1:\
    :sh:\
    :mx#0:\
    :if=/usr/local/libexec/psif:\
    :sd=/var/spool/lpd/lp:\
    :lf=/var/log/lpd-errs:

What model of printer do you have?
The print server is internal o external (need model)?
 
Functionally, a spooler communicates with the printer by queuing the job until the printer is ready. It looks like the spool is waiting for a "printer ready" reply from the Kyocera. I've seen HP printers not fully reset after errors and needing a poweroff/restart. You can test this on your own printer by doing a poweroff/restart while your job is standing by. A newly started printer should indicate that it is ready.

If this is the case, one work around would be LPR direct printing (bypass spooler) via foomatic-rip. Also consider web searching Kyocera for spooling issues.
 
Last edited:
Thanks, I'll try next time problem persists. But as far as I remember, turning ON and OFF the printer doesn't work alone, may be it will with lpc restart lp.
 
Power off/on the printer is not enough, in your FreeBSD the print job can be in a wait state, so you need to lpc down/up to reinitialize (the connection) the print job

The configuration in your printcap is using JetDirect protocol (port 9100), mine is using printer (spooler or lpd) protocol (port 515), different code in your FreeBSD and your printer
 
Power off/on the printer is not enough, in your FreeBSD the print job can be in a wait state,

I do not know the details of the communication that occurs between spooler/printer, but either one is not talking or one is not listening.

lpc(8) has a restart option

Code:
restart { all | printer }
             Attempt to start a new printer daemon.  This is useful when some
             abnormal condition causes the daemon to die unexpectedly, leaving
             jobs in the queue.  lpq(1) will report that there is no daemon
             present when this condition occurs.  If the user is the supe‐
             ruser, try to abort the current daemon first (i.e., kill and
             restart a stuck daemon)
 
And restart of lp do not help.
If you read carefully what "restart" does, it doesn't help in your case since you have a daemon running/working, you should use lpc abort lp and lpc up lp to kill the daemon and start a new one.

So, may be it is more general network problem.
With a ping you can confirm if there is a network problem (packet loss?)

Did you try with my printcap?

What are you printing (existing file/type of file) and how (from application/command line)?

Your filter psif only work with PS and PDF files, what happen with the other types?

Try reconfiguring LPD with the following options and see if something is logged

Code:
Available options:

-c       By    default, if some remote    host has a connection error while try-
         ing to send a print request to lpd    on a local host, lpd will only
         send error    message    to that    remote host.  The -c flag causes lpd
         to    also log all of    those connection errors    via syslog(3).

-d       Turn on SO_DEBUG on the Internet listening    socket (see
         setsockopt(2)).

-l       The -l flag causes    lpd to log valid requests received from    the
         network.  This can    be useful for debugging    purposes.

The Kyocera ECOSYS FS-6525MFP supports the following PDLs (Page Description Language ) / Emulations:
PRESCRIBE, PCL6 (PCL XL and 5e), KPDL3 (PostScript 3 compatible), XPS

You don't need to use gosthscript to convert to PCL (DEVICE=pxlmono)

What emulation do you have active (System menu / Printer / Emulation)?
 
If you read carefully what "restart" does, it doesn't help in your case since you have a daemon running/working, you should use lpc abort lp and lpc up lp to kill the daemon and start a new one.
O.K. Haven't noticed that.
With a ping you can confirm if there is a network problem (packet loss?)
It may happen, but the ping restores much faster than lp job.
Did you try with my printcap?
Not yet. The problem is the laggs start not immediately after reboot, and I do not print that much every day.
What are you printing (existing file/type of file) and how (from application/command line)?

Your filter psif only work with PS and PDF files, what happen with the other types?
Mostly, PDF files, but also some TIFFs, and PSes occasionally. And mostly from command line.
Try reconfiguring LPD with the following options and see if something is logged
...
I'll try that, thanks.
The Kyocera ECOSYS FS-6525MFP supports the following PDLs (Page Description Language ) / Emulations:
PRESCRIBE, PCL6 (PCL XL and 5e), KPDL3 (PostScript 3 compatible), XPS

You don't need to use gosthscript to convert to PCL (DEVICE=pxlmono)

What emulation do you have active (System menu / Printer / Emulation)?
I'll say the type of emulation next time I'll get to the printer (it's on my working place, now we have some kind of holidays).
But without my psif the printer gives raw PDF file
Code:
%PDF-1.5...
on output, but understands (most of) TIFFs anf JPEGs.
So, this KPDL3 is not quite PostScript (?). But I can print PDFs directly (not PSes) from flash sticks inserted into the printer.
 
The Kyocera ECOSYS FS-6525MFP supports the following PDLs (Page Description Language ) / Emulations:
PRESCRIBE, PCL6 (PCL XL and 5e), KPDL3 (PostScript 3 compatible), XPS

It is possible to use the PostScript3 compatible Kyocera driver with a foomatic-rip filter.

OpenBSD foomatic-rip howto
The Kyocera ppd may be available online
The later MAC or Linux downloads should have the ppd.
Kyocera Downloads - see end of page

It is also possible to write a complex filter for PDF, PS and txt files
DaemonForums thread
 
When you print a file and the lag occur, the file is always printed?

It may happen, but the ping restores much faster than lp job.
For me, a network problem has to do with the components between the 2 computers that communicate, in your case the wiring and switch, to test the network, you can simulate the traffic of a print job of 5 MB (5,242,880 Bytes) by sending 3,496 packets of 1,500 Bytes each with ping -c 3496 -s 1500 192.168.1.35.

If the problem is in FreeBSD it has to be with the filter psif, for me, it only handles PS correctly (PDF I am not so sure, are you using print/ghostscript9-agpl?)

Try to identify the type of file you print when the lag occur and when not occur

Your psif is sending the TIFF and JPEG directly to the printer (raw print), maybe is when the lag occur.

So, this KPDL3 is not quite PostScript (?).
Been strict: NO, but for me "PostScript 3 compatible" mean that a third-party PostScript interpreter is running inside your printer (not the official from Adobe).

But I can print PDFs directly (not PSes) from flash sticks inserted into the printer.
According to the manual, you can print PDF, TIFF, JPEG and XPS from USB stick, but I suspect that they transform the file internally before printing it
 
When you print a file and the lag occur, the file is always printed?
Yes, but sometimes I even forget about it, still it is printed may be after 20 minutes.
<...>If the problem is in FreeBSD it has to be with the filter psif, for me, it only handles PS correctly (PDF I am not so sure, are you using print/ghostscript9-agpl?)
On the contrary, this psif is totally correct for PDFs, but PSes may not have any '%PS' header (and still be correct PostScript files), so it would not work for them. psif can be tested easily without network, and it gives no lags and nice PCL (or should they be called PXL?) files. Yes, it is print/ghostscript9-agpl.
Try to identify the type of file you print when the lag occur and when not occur

Your psif is sending the TIFF and JPEG directly to the printer (raw print), maybe is when the lag occur.
The lag can occur during any kind of file. It occurred before I put this psif in place and when I mixed CUPS and direct printing, when I print ASCII files etc...
Been strict: NO, but for me "PostScript 3 compatible" mean that a third-party PostScript interpreter is running inside your printer (not the official from Adobe).


According to the manual, you can print PDF, TIFF, JPEG and XPS from USB stick, but I suspect that they transform the file internally before printing it
Surely they transform somehow internally, but for now I could not make the printer to understand PDFs or PSes from my network. (Also, I was not able to print PSes from flash sticks, what extension it expect? XPS? Is it some variant of PS or just PS?)
 
Maybe the problem of the lag is not with you, maybe someone in your office is using a driver that is documented to cause slow printing on Kyocera printers

On UNIX, magic numbers are used to identify files, for PostScript files is %!PS, more info in file(1)

How did you test psif without network?

Try printing by the usb port lp=/dev/unlpt0 and see if the lag occur

The files XPS is like a PDF (can be viewed anywhere) but from Microsoft
 
My older HP5L used PCL5 and would discern, .txt/.pdf/*.ps files using the ljet4 driver from ghostscript. My newer printer uses BR-script3 which is Brothers Postscript compatible driver. On my initial setup, using BR-script3 with lpr would not print pdf's. Using plxmono would print postscript level 1 and 2 files and PDF <= version 1.4 Postscript printing is usually faster (No pre-processing with ghostscript). The script I linked above essentially looks the first line to see if the file is a pdf or ps. If ID'd as ps, it passes it directly to the printer. The second option, ID'd as pdf, is to convert it to ps using pdf2ps. Lastly, if neither PS or PDF, it assumes a txt file and runs it through enscript.

I wonder if you are not making this overly complex. The handbook has a filter similar to yours in section 9.5.3.4. The only difference is that it utilizes enscript for "pretty" text output and avoids converting a postscript file to PCL
FreeBSD handbook, LinePrinterDaemon

If you get rid of the plxmono driver, and tell you printer to expect postscript emulation, will it print a *.ps file? Postscript printing should be faster (No pre-processing with ghostscript). If that is the case, test a pdf converted to postscript with pdf2ps(1).

Another issue may be the image processing in postscript level 3/pdf v1.7. Ghostscript uses ImageMagick for image processing. You can do this manually with tiff2ps(1) It is also possible to correct change the ps level with ps2ps(1)
Postscript Wikipedia
Do you know if the files ps file that get hung up in the queue are level 3?
 
Last edited:
Maybe the problem of the lag is not with you, maybe someone in your office is using a driver that is documented to cause slow printing on Kyocera printers

On UNIX, magic numbers are used to identify files, for PostScript files is %!PS, more info in file(1)
Hardly so, the problem is present even when I am alone in the office. Although when someone from notebook loses WiFi connection during printing, he has a problem.
How did you test psif without network?
Easily. Put PDF or PS from standard input from command line, write standard output to file and find some utility to view .PCL files. (the last one may be less trivial) )
Try printing by the usb port lp=/dev/unlpt0 and see if the lag occur

The files XPS is like a PDF (can be viewed anywhere) but from Microsoft
I even do not have USB cable for the printer (and long enough to reach it) )))
 
My older HP5L used PCL5 and would discern, *.txt/*.pdf/*.ps files using the ljet4 driver from ghostscript. My newer printer uses BR-script3 which is Brothers Postscript compatible driver. On my initial setup, using BR-script3 with lpr would not print pdf's. Using the plxmono would print postscript level 1 and 2 files and PDF <= version 1.4 Postscript printing is usually faster (No pre-processing with ghostscript). The script I linked above essentially looks the first line to see if the file is a pdf or ps. If ID'd as ps, it passes it directly to the printer. The second option, ID'd as pdf, is to convert it to ps using pdf2ps. Lastly, if neither PS or PDF, it assumes a txt file and runs it through enscript.

I wonder if you are not making this overly complex. The handbook has a filter similar to yours in section 9.5.3.4. The only difference is that it utilizes enscript for "pretty" text output and avoids converting a postscript file to PCL
FreeBSD handbook, LinePrinterDaemon
Yes, your are right, the start script was from that script from The Handbook, and I've said in #15 and #18 that sending PDF or PS to printer make it consider it is text file and print all these '%PDF...' or '%!PS...' until I stop it by hand. And I do not know (yet?) how to set “the right” emulation. I still shall try the #14 menu.
If you get rid of the plxmono driver, and tell you printer to expect postscript emulation, will it print a *.ps file? Postscript printing should be faster (No pre-processing with ghostscript). If that is the case, test a pdf converted to postscript with pdf2ps(1).

Another issue may be the image processing in postscript level 3/pdf v1.7. Ghostscript uses ImageMagick for image processing. You can do this manually with tiff2ps(1) It is also possible to correct change the ps level with ps2ps(1)
Postscript Wikipedia
Do you know if the files ps file that get hung up in the queue are level 3?
The hang is with PDFs, TIFFS, PSes etc. Everything it prints. More that that, it can print most of TIFFs without conversion to anything. And, by the way printer processor is slower than CPU on a desktop, so making conversion on desktop is not slower (anyway, a laser printer will do it, the rasterization thing, right?).
Also, I've said that producing .PCLs by my psif is very fast comparing to printer waiting time (even without lags it warm-up longer :) ).
 
@YuriG if the hang/lag continues, you can diagnose the problem by capturing the packets with tcpdump(1).

Start capturing, then send the print job, when the job gets printed you stop the capture with Ctrl-C.

You will need 2 captures: (1) when the print job hang and (2) when not.

Assuming that your interface is "fxp0" then run the command tcpdump -s 0 -n -i fxp0 host 192.168.1.35 -w filename.pcap

-s 0 = full packet capture
-n = no DNS lookup
-i fxp0 = interface to capture traffic from
-w = name of the file to save the capture to

If you want something with GUI, you can use net/wireshark to analize/examine the files
 
Back
Top