## Bug in ipp-usb
I own an Epson ET-2850 printer. I often get prints that cancel themselves 1/3 through being printed. I thought that wifi might have been the issue. Unfortunately, the ET-2850 doesn't come with an ethernet port.
The issue is hard to reproduce. I found that around 1/10 of the prints of photos made using an AirPrint on iPhones get cancelled.
ipp-usb is a project that allows you to turn any IPP-capable USB printer into an IPP network printer with capabilities such as mDNS, which make the printer AirPrint-capable. I plugged my printer to a Raspberry Pi and installed ipp-usb, and configured it to listen to `0.0.0.0` rather than localhost so that I could use AirPrint from my iPhone.
Unfortunately, ipp-usb doesn't work with my printer: when selecting the printer in AirPrint from my iPhone, it would would immediately unselect itself. Also, the printer shows as "offline" in AirPrint. Fortunately, I can easily man-in-the-middle the IPP traffic to see what's going on. When running Wireshark from the Pi, I noticed that AirPrint does two consecutive requests using the method `Get-Printer-Attributes`:

Something caught my eye: somehow, the `printer-uri` was using an unusual hostname: `pi.local.`. Although the ending dot is a valid domain name, it is not always well supported.
The response from the Pi is weird, too.
```
printer-strings-uri (uri): 'http://pi.local.\002/LANGUAGES/IPP?LANG=fr'
```

This `\002` was suspecious enough. And sure enough, looking at the iPhone logs using Apple Configurator confirmed my doubts:
> Exception during reading: Invalid UTF8 bytes
```
Dec 22 14:18:59 iPhone-Mael com.apple.PrintKit.PrinterTool(CFNetwork)[36639] <Notice>: Task <3F686887-7D29-4DDB-B528-4074CF9D967E>.<10> summary for task success {transaction_duration_ms=301, response_status=200, connection=193, reused=1, reused_after_ms=0, request_start_ms=0, request_duration_ms=0, response_start_ms=299, response_duration_ms=1, request_bytes=1425, request_throughput_kbps=1553, response_bytes=2651, response_throughput_kbps=2446, cache_hit=false}
Dec 22 14:18:59 iPhone-Mael com.apple.PrintKit.PrinterTool(CFNetwork)[36639] <Notice>: Task <3F686887-7D29-4DDB-B528-4074CF9D967E>.<10> finished successfully
Dec 22 14:18:59 iPhone-Mael com.apple.PrintKit.PrinterTool(PrintKit)[36639] <Error>: IPPIOReader: Failure on line 91: Invalid UTF8 bytes - Invalid UTF8 bytes
Dec 22 14:18:59 iPhone-Mael com.apple.PrintKit.PrinterTool(PrintKit)[36639] <Notice>: Exception during reading: Invalid UTF8 bytes
Dec 22 14:18:59 iPhone-Mael com.apple.PrintKit.PrinterTool(PrintKit)[36639] <Notice>: Couldn't convert data to ipp
Dec 22 14:18:59 iPhone-Mael com.apple.PrintKit.PrinterTool[36639] <Notice>: device_http<0xd3605d560>: Received response async: <http HTTP_STATUS_ERROR, ipp status (nil) 500>
Dec 22 14:18:59 iPhone-Mael com.apple.PrintKit.PrinterTool[36639] <Notice>: Can't create a printer for ipp://pi.local.:60000/ipp/print
```
I don't have a solution yet.
ipptool -tv ipp://pi.local:60000/ipp/print /usr/share/cups/ipptool/get-printer-attributes.test | bat