HeligPfleigh / react-native-thermal-receipt-printer

A RN library for thermal printer
157 stars 102 forks source link

Mannually Set Timeout on Connecting Printer #78

Open nguyen-vo opened 2 years ago

nguyen-vo commented 2 years ago

Summary 💡

Currently, I think when we call NetPrinter.connectPrinter(ipAddress, portNumber) the default timeout is too long. If I the current print is out of paper, it return a timeout connection error. Although I have pinged the printer and make sure it response , it still return a timeout error. But it is not the main issue. the main issue here is the default timeout is too long. Since the connectPrinter() function is a async/await it will block the whole app.

Examples 🌈

Screen Shot 2021-09-08 at 12 48 54 PM

Motivation 🔦

Allow to overwrite the default timeout on connectPrinter() for Net printer and Bluetooth printer

hoanganhnh2009 commented 2 years ago

Same issues

hoanganhnh2009 commented 2 years ago

You can use modules: react-native-ping await Ping.start(ipAddress, { timeout: timeout }); await NetPrinter.connectPrinter(