Zepra label printer - print bulk labels via socket

Hi Team,
we have an issue with printing more labels at Zebra printers (ZTC ZT410 / ZTC 105SLPlus). When we sent few labels (up to ~30), it is workig, but when we need print in one action more then ~40/50 labels, it is printing some labels and after that printer returns "Connection refused" by socket_connect.

Do you have some recomendation how to fix it? I tried to set some delay, but did not help. I tried to have opened just 1 socket too.
Is it possible that buffer is full and printer is not possible to consume next data, or number of open sockets exceeded and printer refusing new sockets?

We are using on backend PHP and socket communication with printer like this:

foreach ($labels as $label) {

$socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$result = @socket_connect($socket, $host, $port);
$result = @socket_write($socket, $label);
socket_close($socket);
}

or

$socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$result = @socket_connect($socket, $host, $port);
foreach ($labels as $label) {
...
$result = @socket_write($socket, $label);
...
}
socket_close($socket);

Thanks for your any help.
Michal

Steven Si
Looks like you do not use

Looks like you do not use Link-OS SDK, which provides API to check the printer status. Label printers are considered slow accessories and takes time to print out a label. The printer has an input buffer, so that it can queue up certain number of labels, depending on the data size of each label. Sending labels blindly to the printer can cause the buffer overflow and result in many other issues. The getCurrentStatus() API in Link-OS SDK is recommended to be called prior to sending each label to the printer to ensure we only send the label to the printer when the printer is in ready state.

If you don't use Link-OS SDK, you will have to query the printer status each time before sending a label by sending ~HS (Host Status) and checking the return value to make sure that the printer is in ready state before sending the next label. Alternative, providing sufficient delay, for example a couple of seconds between sending the labels, can also avoid the buffer overflow. Hope this helps.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments