star-micronics / react-native-star-io10

react-native-star-io10 is a library for supporting application development for Star Micronics devices.
Other
89 stars 55 forks source link

Error 20001: StarIO10IllegalDeviceStateError #115

Open joarwilk opened 5 months ago

joarwilk commented 5 months ago

Description

When discovering, it fails with error 2001: StarIO10IllegalDeviceStateError.

When shipping a batch of, say, 5 terminals, this can happen on 1-5 of those. It seems to be random.

How can we debug this invalid state?

Your device where the bug occurs

Your printer

To Reproduce

Start discovery. An error is caught with error code 2001 and description StarIO10IllegalDeviceStateError. Sometimes its error 2000, with description "y"

Expected behavior

Printers are found

can-miki commented 4 months ago

I would like to ask you a few questions to confirm the situation.

My understanding is that there are 5 terminals (Castle S1F2) connected to 1 printer (mC-Print3) via LAN. Is that so? What API do you use for discovery?

Also, regarding StarIO10IllegalDeviceStateError I would like to check the following:

The flow when connecting the printer and device is "PortOpen → Status acquisition → PortClose".

joarwilk commented 4 months ago

My understanding is that there are 5 terminals (Castle S1F2) connected to 1 printer (mC-Print3) via LAN. Is that so? What API do you use for discovery? Correct, but not connected at the same time. For any action they open, , and close.

We use this library to discover. Using starDeviceDiscoveryManagerFactory.create([InterfaceType.Lan]);

Is there a problem with your network equipment? Is the printer turned on?

It works for some terminals and some not in the same network. This is consistent across different venues so it doesnt seem to be a local thing.

Is the application configured to communicate between the device and the printer after "PortClose"?

We dont even get to that state. It simply doesnt return any printers during discovery.

nuzayets commented 2 months ago

We're seeing this with 'Network Unavailable' even when the network is available (we observe traffic to our backend succeed, at the same time as this error). We see it across Android 12 and 13, on the latest version of star-io10. The devices are Lenovo YT-J706F and Lenovo TB125FU. The printer is TSP100iii on Bluetooth but this occurs during discovery. We also began seeing it in May '24, at the time on version 1.3.0.

The error is persistent. So far we have not found a solution.

can-miki commented 2 months ago

@joarwilk @nuzayets We apologize for the long wait. Error 2001 is Network Unavailable.

This SDK ver.1.7.0 fixed an issue where StarIO10IllegalDeviceStateError(message: "Network Unavailable.") could occasionally be thrown even though the device is actually connected to the network. Please update and see if the problem is resolved.

Thank you.

nuzayets commented 2 months ago

The fix there said it's only for iOS. We're on Android 12 & 13, no effect there (we did try 1.7.0 before I commented). I did find a workaround: if we get Network Unavailable we scan without LAN and that works. Of course that will only work if people don't genuinely need LAN printers -- lucky for us that scenario hasn't happened since we don't officially support LAN printers (though some customers do use them).

My thinking was their network is blocking UDP multicast or something since that's usually how printer autodiscovery works (for normal desktop printers anyway), it does seem to be specific to a customer location and we can't repro it in-house. Since the workaround (not scanning LAN if we get Network Unavailable) works, we haven't put resources into reproducing it in the lab as of yet.