HPInc / jipp

A Java-compatible implementation of IPP
MIT License
153 stars 42 forks source link

Roam encountered an issue while parsing response of a create-job request #143

Closed KiranReddy-hp closed 1 year ago

KiranReddy-hp commented 1 year ago

Unable to parse the inputstream data to JIPP parse. It is throwing an exception that "com.hp.jipp.util.ParseError: Bad tag in collection: job-attributes"

Background of this issue

Printer details: Account: siv-whqxe+stg041801@outlook.com/Aio1test Stack: Stage Printer: Beam MFP FW: 6.15.0.1372 UUID: cb08c487-c415-4287-949b-fbf1d166e8a5 SN: CN1CE0M00N ios HP Smart: 12.0.0.2434

From Roam, we could see the Create-job was successful and receive the response body. Create-job request :

IPP Request :IppPacket(v=0x200, c=Create-Job(5), r=0x11a1ec0c) { operation-attributes {   attributes-charset = utf-8,   attributes-natural-language = en,   printer-uri = ipps://localhost:631/ipp/print,   job-name = "2022-08-29_064916.jpg" (name),   requesting-user-name =     "siv-whqxe+stg041801@outlook.com;c57d9b30-0204-4b9d-baf9-5311cf63a807" (name),   job-resource-id = eebe8538-f513-4028-aba9-91e741f4fd9a }, job-attributes {   copies = 1,   sides = one-sided,   print-color-mode = color,   printer-resolution = 300x300 dpi(3),   print-scaling = auto,   media-col =     { media-bottom-margin = 499, media-left-margin = 499, media-right-margin = 499, media-size = {  },     media-source = main, media-top-margin = 499, media-type = stationery } } }

Captured Input Stream: "\u0002\u0000\u0000\u0001Xi�Y\u0001G\u0000\u0012attributes-charset\u0000\u0005utf-8H\u0000\u001Battributes-natural-language\u0000\u0002en\u0005\u0010\u0000\u000Fjob-resource-id\u0000\u00004\u0000\tmedia-col\u0000\u0000J\u0000\u0000\u0000\nmedia-size7\u0000\u0000\u0000\u0000\u0002E\u0000\u0007job-uri\u0000\"ipp://localhost/ipp/print/job-0053!\u0000\u0006job-id\u0000\u0004\u0000\u0000\u00005#\u0000\tjob-state\u0000\u0004\u0000\u0000\u0000\u0004D\u0000\u0011job-state-reasons\u0000\u0015job-data-insufficientA\u0000\u0011job-state-message\u0000\u0015job-data-insufficient\u0003"

HPSudip commented 1 year ago

I believe the following might be the cause of this issue.

Roam app code -> It is wrongly sending the empty media-size in the media-col collection, the client should send a media size supported by the printer in its capabilities, else I believe we do not send that attribute, if we do not send mediaSize at all then the printer supposed to take the default media size as per capabilities for the printing, but if we send an empty mediaSize then we should receive an unsupported group with media-col collection attribute in the response and the printer may print with the default attribute or reject the job based on the status code it would send back.

Printer FW code -> The response IPP Packet may not be properly constructed as well, as the tag values like begCollection (0x34) and endCollection (0x37) may not be in place for the returned mediaCol collection in the unsupported attribute coming from the printer, that is the reason the JIPP code while reading the collection attribute encountered the next group tag which is jobAttributes tag before endCollection tag, as it throws the parsing exception there. Check the collection attribute tag syntax as per https://datatracker.ietf.org/doc/html/rfc3382#section-9

Next steps:

1> Send a create-job operation with a valid media-size in media-col collection. That should go through without error. 2> Send a create-job operation with no media-size in media-col collection. That should go through without error. The media-col should look like this at the time of sending..
media-col = { media-bottom-margin = 499, media-left-margin = 499, media-right-margin = 499, media-source = main, media-top-margin = 499, media-type = stationery } } }

3> If the above 2 passes then create an issue with the FW team to rectify their IPPPacket response.

HPSudip commented 1 year ago

Closing as this is not JIPP issue.