Closed muhammadn closed 2 years ago
This indicates that the printer does not respond with valid ipp. I assume this error is reproducable. I've updated the code for better logging and error analysis. The attached file looks incomplete. Some times value encodings are incorrect and one can guess or see what is missing. In such cases usually more bytes follow after end incorrect encoding - that's where I could try to implement a workaround.
Anyway, please update, build and try my latest source code. You should get a file getPrinterAttributesFailed.bin
which I kindly ask you to post here again including the new logs. I've added an operation that saves pure http content without trying to parse the ipp message.
@gmuth Will test the latest source code. Sorry for taking time as i was out of town.
I've also called Epson today and when i was troubleshooting for a macOS machine to print out (using generic postscript driver), it comes out garbage, the same thing happens when i make this library be less strict with ipp response.
Epson clarified that i would need their driver.
@muhammadn, what's the result/output concerning the lastest updates I have committed and pushed? You can always test with ipptool as well - e.g. https://github.com/apple/cups/blob/master/examples/get-printer-attributes.test.
Looking at the specs of the printer I can't see what output formats are supported for printing. Somewhere else they list: ESC/P-R, ESC/P Raster
From you logs I can see that the printer lists:
document-format-supported (1setOf mimeMediaType) = [application/octet-stream, image/pwg-raster, application/vnd.epson.escpr]
IPP can only be used to transmit printable documents to the printer in a format it supports.
@gmuth I forgot. I did ipptool before.
Here is the result for ipptool:
─$ ipptool -tv ipp://192.168.1.7/ipp/printer get-printer-attributes.test
"/usr/share/cups/ipptool/get-printer-attributes.test":
Get-Printer-Attributes:
attributes-charset (charset) = utf-8
attributes-natural-language (naturalLanguage) = en
printer-uri (uri) = ipp://192.168.1.7:631/ipp/printer
Get printer attributes using Get-Printer-Attributes [FAIL]
RECEIVED: 0 bytes in response
status-code = server-error-internal-error (No request sent.)
IPP request failed with status server-error-internal-error (No request sent.)
ipptool
doesn't show much information. I'm extracting the .bin
file at the moment, i've hacked parts of your code to allow to save the file on android (since android has strict permissions) and i am extracting that .bin
out.
Do note that i tested on a photocopier which is a Ricoh bizHub and prints perfectly, ipptool for the Ricoh bizHub also successfully provided me with printer attributes. I used your code for a flutter app (which uses a bridge to call your kotlin code)
Just this epson L3250 is giving problems. If this printer is giving problems then i'll try to find some compatible ones out there. But i'm unsure which could work though.
getPrinterAttributesFailed.bin.zip
Here is the file. Github doesn't allow .bin
extension so i had to zip it.
If the printer does not meet your requirements you should look into the specs when buying a new one. I prefer AirPrint printers because they implement IPP and more likely support PDF natively. Unfortunately manufacturers hardly document the supported pdls or document formats. Even via IPP sometimes they don't announce a full list of formats.
@gmuth Yeah, we got that printer for free (new) and now it's either i hack the code (is it because they never announce the pdls?) to ignore the pdl and continue printing.
I did see the pdl information in the bin file, most notably printer-device-id
printer-device-id��MFG:EPSON;CMD:ESCPL2,BDC,D4,D4PX,ESCPR1,END4,GENEP,PWGRaster
Printer does not seem to support PDF so i would have to use PWGRaster and one of the way to do with a library is to use https://github.com/HPInc/jipp to convert pdf to PWGRaster
Only problem is i would have to write java code.
Thank you for the extra bin-file update. The printer does not send a complete valid response. Without having the printer available it's difficult to look for workarounds. The idea is to exclude the invalid marker attributes from the response by not asking for all printer attributes.
I have enhanced the initialisation process. You can now limit the printer attributes requested. For details look into RFC 8011 section 4.2.5.
val ippConf = IppConfig().apply {
requestedAttributesOnInit = IppPrinter.printerClassAttributes
}
Or you can disable get-printer-attributes completely:
val ippConf = IppConfig().apply {
getPrinterAttributesOnInit = false
}
Maybe you can fetch the job-template attributes without issues:
IppPrinter(uri, ippConfig = ippConf).apply {
updateAttributes("job-template")
}
Please check if this solves the original issue "failed to decode ipp response"
Printers sometimes respond with invalid ipp responses. Disabling GetPrinterAttributesOnInit solves this issue. Generally the library should work without the printer attributes though I've not tested this special case a lot.
response output based in issueNo3.kt test file decoding_ipp_response.zip
Error trace