I'm using the following function to send a label to networked zebra printer. Everything works using android tablet retool mobile app but after the 6th request additional requests get delayed. Any thoughts on why this may be happening.
I'm able to printer from my PC using http POST requests using powershell multiple times without any delays.
if (response.ok) {
console.log('Print job sent successfully.');
} else {
// Read and log the response text if not OK
const errorText = response.text();
console.error('Failed to send print job. Status:', response.status, 'Response:', errorText);
}
That's weird! Is it always the 6th request? If you send 5 requests, wait 30 minutes, then send a 6th request, does it still occur? What kind of delay are we talking about?
I've found that the request is not "ending." After the 6th request, I can quit the retool mobile and and reopen and it works 6 more times. Alternatively, if I change the TCP/IP timeout on the printer to 1 second, I can keep printing without any issues. Testing this in flutterflow the API call would hang and reducing the timeout to 1 second would print but give me an error that headers could not be downloaded.
I've tried pstprnt and that doesn't seem to work on retool or flutterflow but it works in powershell. Additionally, I tried loading Zebra BrowserPrint libraries but they don't seem to work. Any thoughts?
It's interesting how Retool is promoted by Zebra but retool has the bare minimum and although this feature is available, they've chose to limit it to enterprise accounts only!
Instead of pinging to /printer/print try hitting a healthcheck endpoint instead. Does it also hang after 5 requests?
Try running your code from another device, or trying it from within the web editor.
What are the contents of zplCommand? Maybe they are problematic.
Try creating a REST query instead of using fetch() directly
Lastly, if you can share the code you're trying to run that may help also. This code you've shared doesn't seem to work at first glance, since it is async code with no awaits. So you must be running different code.
REST query doesn't work in retool.
flutterflow also hangs with setting up a REST API.
Everything prints ok when pushing the request using powershell.
I'll check on healthcheck endpoint.
It seems like for some reason the connection isn't closing after printing when sent as an API. the /printer/print is there but the IP address has port 9100 attached to it. Essentially RAW printing. I've tried without the port and it never prints through retool or flutterflow. It will print without port using powershell.
You likely have some sort of network configuration issue which is outside the scope of Retool. Try pinging your printer from a cloud service like replit, it will likely have the same connectivity issues as Retool REST query and Flutterflow REST API.
I’m confident it’s not a network issue. Quitting and reloading retool app lets me print again. Zebra has a JS library called browserprint that allows printing from browser as well. I’ve loaded these libraries in retool but I’m unable to access the functions. Any thoughts?
So using xmlhttprequest resolved the pausing issue.
Any suggestions on the browserprint JS library?
Additionally, the xmlhttprequest only works on android devices using the retool app. It does not work on iOS with error that xmlhttprequest can't be find and it doesn't work on PC with error 0.