Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CANCEL_JOB Question #79

Closed
jpmsparks opened this issue Mar 5, 2024 · 1 comment
Closed

CANCEL_JOB Question #79

jpmsparks opened this issue Mar 5, 2024 · 1 comment
Assignees
Labels
question Further information is requested

Comments

@jpmsparks
Copy link

Describe the bug

Getting a 1024 error when submitting a cancel-job request on a job id generated by the "create-job" "send-document" operations. I get a legitimate job id via callback from "create-job", but then when I use that job (jobId) in the following snippet I will get a 1024 error (IPP_STATUS_ERROR_BAD_REQUEST = 0x0400) after the cupsDoRequest API. I had a similar issue with the "send-document" operation and it turned out I needed the "last-document" attribute, (apparently that needed to be added to documentation) hoping it is the same type of issue here. Note: change the jobId, printer, and pUser values below to suit test.

`
http_t* http;
ipp_t* request, * response;
ipp_status_t status;
const char* printer = "printer57";
const char* pUser = "aUser";
int jobId = 30;
char szUriTag[150] = { 0 };

sprintf_s(szUriTag, "%s%s%s%s", "ipp://", printer, "/printers/", printer);

http = httpConnect(printer, 631, NULL, AF_UNSPEC, HTTP_ENCRYPTION_IF_REQUESTED, 1, 30000, NULL);
if (http == NULL)
{
	printf("Could not connect to: %s", printer);
	return 0;
}

//canx the job
request = ippNewRequest(IPP_OP_CANCEL_JOB);

ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, szUriTag);
ippAddInteger(request, IPP_TAG_OPERATION, IPP_TAG_INTEGER, "job-id", jobId);
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, pUser);

//In request.c This function sends the IPP request to the specified server, 
//The request is freed with ippDelete
response = cupsDoRequest(http, request, "/jobs/");
status = ippGetStatusCode(response);

httpClose(http);
if (request)
	ippDelete(response);
if (response)
	ippDelete(response);
return status;

`

To Reproduce

  1. Get a job id from large document submitted to a printer via create-job and use the send-document.
  2. Try to cancel the job using the job id returned from create job via cancel-job API.

Expected behavior
I would expect to get as success if the job was not yet finished printing on the printer or another status code if the job had already
finished (on the target printer) prior to the cancel-job API.

System Information:

  • OS: Windows 11
  • Browser: MS Edge
    -Printer: HP MS608

Additional context
If I test the above code with a random (not generated on the printer) job Id, I will get a 1030 (IPP_STATUS_ERROR_NOT_FOUND) status which appears reasonable? as a response for a job number not created on the printer.

@michaelrsweet michaelrsweet self-assigned this Mar 17, 2024
@michaelrsweet michaelrsweet added the question Further information is requested label Mar 17, 2024
@michaelrsweet
Copy link
Member

OK, some quick feedback:

  1. client-error-bad-request isn't a valid response from the printer if the job is already completed - it should be successful-ok if the job is not in a terminating state (pending, pending-held, processing, or processing-stopped), client-error-not-possible if the job is terminated (aborted, canceled, completed), or client-error-not-found if the job-id is not found. A Wireshark trace might be useful to ensure everything is going across as expected.
  2. You don't delete the request after calling cupsDoRequest - that function deletes it for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants