ok
let me explain about this situation as I understand It I am going to post some real world examples.
I am dealing with eSCL protocol which you can find more info on here
https://mopria.org/spec-downloadI can see the following in phpinfo:
- Code: Select all
Max Requests Per Child: 0 - Keep Alive: on - Max Per Connection: 100
Timeouts Connection: 300 - Keep-Alive: 5
....
output_buffering 4096
Now I have not been able to change the Keep-alive connection or time-put settings no matter what I do.
The output buffering "off" or "4096" seems to make no difference at least with my code, and without the ability to change the keep-alive settings.
on the original ob_flush question , I ended up with this
- Code: Select all
<?php
header("Cache-Control: no-cache, no-store, must-revalidate");
header('HTTP/1.1 201 Created');
header('Location: http://'.$ipaddress.':'.$port.'/eSCL/ScanJobs');
$size = ob_get_length();
header_remove('X-Powered-By'); //removes the 'X-Powered-By' header
header('Content-Type:'); //removes the 'Content-Type' header
header("Content-Length: $size");
header('Connection: keep-alive'); //Connection: keep-alive
//header('Keep-Alive: timeout='.$keepalivetimeout.', max='.$keepalivemax);// this seemed to do nothing
ob_start();
ob_end_flush();
flush();
It took some time to come up with the above solution however I can confirm with CURL that it is working as expected.
I have an HP scanner that uses this protocol and can use it as a model to try to replicate. I can send a CURL request and get the response below:
- Code: Select all
curl -v -X POST -d @1inchoffset.xml http://192.168.0.250:80/eSCL/ScanJobs
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying 192.168.0.250...
* TCP_NODELAY set
* Connected to 192.168.0.250 (192.168.0.250) port 80 (#0)
> POST /eSCL/ScanJobs HTTP/1.1
> Host: 192.168.0.250
> User-Agent: curl/7.55.1
> Accept: */*
> Content-Length: 749
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 749 out of 749 bytes
< HTTP/1.1 201 Created
< Cache-Control: no-cache, no-store, must-revalidate
< Location: http://:80/eSCL/ScanJobs/0pvnag6j-8jcq-1adm-1001-c6lj2g43
< Server: gSOAP/2.7
< Content-Length: 0
< Connection: keep-alive
<
* Connection #0 to host 192.168.0.250 left intact
Now I have a Windows machine that I am trying to make emulate that behavior to share the Twain or WIA scanner. and I am 99% of a final working product, except for a connection issue that I think relates to keep-alives
When I send this or a similar command to the Windows server
- Code: Select all
curl -v -X POST -d @Platen75PNG2_5Doc.xml http://192.168.0.40:8000/eSCL/ScanJobs
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying 192.168.0.40...
* TCP_NODELAY set
* Connected to 192.168.0.40 (192.168.0.40) port 8000 (#0)
> POST /eSCL/ScanJobs HTTP/1.1
> Host: 192.168.0.40:8000
> User-Agent: curl/7.55.1
> Accept: */*
> Content-Length: 811
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 811 out of 811 bytes
< HTTP/1.1 201 Created
< Date: Wed, 08 Sep 2021 18:51:06 GMT
< Server: Apache/2.4.48 (Win64) OpenSSL/1.1.1k PHP/8.0.8
< Cache-Control: no-cache, no-store, must-revalidate
< Location: http://192.168.0.40:8000/eSCL/ScanJobs
< Content-Length: 0
< Connection: keep-alive
<
* Connection #0 to host 192.168.0.40 left intact
So it looks like so far I have the POST command replicated.
After sending that above POST command from a client such as Imaging on OSX, I can see that both the Windows server and the scanner later start to receive requests from the client to /eSCL/ScannerStatus , which is where the document count is located as well as repeating the same URL in the location header reply once the document is ready for download.
I can replicate this manually with curl to initiate the post and a browser to see /eSCL/ScannerStatus and also see what that Mac app sees and have seen it in wireshark traces.
The problem is that after about 50 to 60 seconds after initiating the scan on the Mac App (OSX 10.14 Mojave running on Virtualbox), it seems to fail when the spinning disc disappears, but the "scanning Document..." message remains. The scanned document(s) never appear in Imaging, unless it is single sheet which takes about 40 seconds to scan on the slow Dell 1355cn Scanner at 300 dpi )(with the scanner already "warmed up". I have seen similar results in Linux using the
https://github.com/alexpevzner/sane-airscan package but have not tested the latest version of my code with a Linux client lately.
Here is another factor to complicate matters: I have also tested with the 'Official" Mopria Scan for Android app. The Mopria Scan for Android app works 100% , even with a very slow sheetfeed scanner scanning multiple pages , it seems to patiently wait till the scan is done then downloads all the files.
So how do I adjust the Keep-alive timeout and keep-alive and connection time-outs? Unsure as to how these time - outs seem to relate to about 50 to 60 seconds and whether or not they are the cause, but i see many sites that say they should be increased for many different reasons. It seems waiting for a slow document scanner might be a good reason.
of course if anyone has a Windows 10 machine, windows scanner and a Mac and wants to help that is extremely helpful too.