react-native-esc-pos-printer icon indicating copy to clipboard operation
react-native-esc-pos-printer copied to clipboard

Printer unable to print after turning device screen off and back on or after switching apps

Open vincentiusadityas opened this issue 1 year ago • 11 comments

Hi, I'm having an issue where I think the printer connection is lost after I turned my device's screen off and then back on. This also happens after switching between apps. After that, it was not able to print anything. I have to reconnect again (calling the instantiate function).

I'm using the instantiate function to enable printing simultaneously and using multiple printers.

Is there any way to keep the connection of the printer without having to instantiate the printer again?

Thank you!

vincentiusadityas avatar Aug 27 '23 02:08 vincentiusadityas

I use Re-connect Instantiate again and it works for me

Savan-ITDEV avatar Sep 20 '23 14:09 Savan-ITDEV

I use Re-connect Instantiate again and it works for me

@Savan-ITDEV Could you please elaborate more or share the piece of code you use to do that? Thanks!

vincentiusadityas avatar Oct 05 '23 07:10 vincentiusadityas

Same issue

manage-some avatar Jan 03 '24 15:01 manage-some

Yes I got the same issue. Were you able to solve it? Any help would be appreciated

@vincentiusadityas @Savan-ITDEV

This is what i'm doing to connect once app is launched


    await EscPosPrinter.instantiate({
        target: printer.target,
        seriesName,
        language: 'EPOS2_LANG_EN',
      });

      await EscPosPrinter.connect(printer.target);


The above code connects the printer and this code is used to print


  await EscPosPrinter.instantiate({
      target: printer.target,
      seriesName,
      language: 'EPOS2_LANG_EN',
    });

    await EscPosPrinter.connect(printer.target);

    const printing = new EscPosPrinter.printing();

    const receipt = epsonReceipt(printing, receiptEngineObj);
    if (printer.drawer_connected && isCashGiven) {
      receipt.addPulse('EPOS2_DRAWER_2PIN');
    }

    await receipt.send({
      target: printer.target,
    });
    
The whole process works smoothly but if network drops and reconnects or we switch between the apps the printer stops responding and the above code does not work.
The printer shows as connected though and only starts to work again if restart the app

funkaarts avatar Jan 04 '24 23:01 funkaarts

Facing the exact issue. Can anyone help me here?

@vincentiusadityas @Savan-ITDEV @funkaarts

Waleed065 avatar Jan 06 '24 13:01 Waleed065

my solution solution 1

  • after switching the app or screen of => use AppState to detect an event to disconnect all printers or just disconnect by target printer by IP solution 2
  • every print disconnects first and then reconnects and print is done ^^ EZ

Hope this solution help you guys thanks, guys ^^

On Sat, Jan 6, 2024 at 8:50 PM Waleed Tariq @.***> wrote:

Facing the exact issue. Can anyone help me here?

@vincentiusadityas https://github.com/vincentiusadityas @Savan-ITDEV https://github.com/Savan-ITDEV @funkaarts https://github.com/funkaarts

— Reply to this email directly, view it on GitHub https://github.com/tr3v3r/react-native-esc-pos-printer/issues/115#issuecomment-1879693498, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM6ZFYCSXL2FJMCXHXHL3HDYNFJDBAVCNFSM6AAAAAA3772BC2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZZGY4TGNBZHA . You are receiving this because you were mentioned.Message ID: @.***>

Savan-ITDEV avatar Jan 10 '24 03:01 Savan-ITDEV

@Savan-ITDEV

But sometimes, i've notied that if internet turns off and then back on, The printer shows as connected but does not print. Similarly if print turns off and back on, it looses ability to print.

Any solution here?

Waleed065 avatar Jan 10 '24 16:01 Waleed065

Use this solution will help you,

solution 2

  • every print disconnects first and then reconnects and print is done ^^ EZ

On Wed, 10 Jan 2024 at 11:19 PM Waleed Tariq @.***> wrote:

@Savan-ITDEV https://github.com/Savan-ITDEV

But sometimes, i've notied that if internet turns off and then back on, The printer shows as connected but does not print. Similarly if print turns off and back on, it looses ability to print.

Any solution here?

— Reply to this email directly, view it on GitHub https://github.com/tr3v3r/react-native-esc-pos-printer/issues/115#issuecomment-1885170992, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM6ZFYCC6BYL4WODSAWIJ6DYN25SFAVCNFSM6AAAAAA3772BC2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBVGE3TAOJZGI . You are receiving this because you were mentioned.Message ID: @.***>

Savan-ITDEV avatar Jan 10 '24 16:01 Savan-ITDEV

Use this solution will help you, solution 2 - every print disconnects first and then reconnects and print is done ^^ EZ On Wed, 10 Jan 2024 at 11:19 PM Waleed Tariq @.> wrote: @Savan-ITDEV https://github.com/Savan-ITDEV But sometimes, i've notied that if internet turns off and then back on, The printer shows as connected but does not print. Similarly if print turns off and back on, it looses ability to print. Any solution here? — Reply to this email directly, view it on GitHub <#115 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM6ZFYCC6BYL4WODSAWIJ6DYN25SFAVCNFSM6AAAAAA3772BC2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBVGE3TAOJZGI . You are receiving this because you were mentioned.Message ID: @.>

@Savan-ITDEV This can be a workaround but it's not a viable solution.

The android/ios SDK itself handles reconnectivity scenarios. It just needs to be added to this package as a built in feature

Waleed065 avatar Jan 10 '24 16:01 Waleed065

I suggest try my package : https://github.com/Savan-ITDEV/react-native-savanitdev-thermal-printer Hope will help you ^^ On Wed, 10 Jan 2024 at 11:26 PM Waleed Tariq @.***> wrote:

Use this solution will help you, solution 2 - every print disconnects first and then reconnects and print is done ^^ EZ … <#m_6840549305437100080_> On Wed, 10 Jan 2024 at 11:19 PM Waleed Tariq @.> wrote: @Savan-ITDEV https://github.com/Savan-ITDEV https://github.com/Savan-ITDEV https://github.com/Savan-ITDEV But sometimes, i've notied that if internet turns off and then back on, The printer shows as connected but does not print. Similarly if print turns off and back on, it looses ability to print. Any solution here? — Reply to this email directly, view it on GitHub <#115 (comment) https://github.com/tr3v3r/react-native-esc-pos-printer/issues/115#issuecomment-1885170992>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM6ZFYCC6BYL4WODSAWIJ6DYN25SFAVCNFSM6AAAAAA3772BC2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBVGE3TAOJZGI https://github.com/notifications/unsubscribe-auth/AM6ZFYCC6BYL4WODSAWIJ6DYN25SFAVCNFSM6AAAAAA3772BC2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBVGE3TAOJZGI . You are receiving this because you were mentioned.Message ID: @.>

@Savan-ITDEV https://github.com/Savan-ITDEV This can be a workaround but it's not a viable solution.

The android/ios SDK itself handles reconnectivity scenarios. It just needs to be added to this package as a built in feature

— Reply to this email directly, view it on GitHub https://github.com/tr3v3r/react-native-esc-pos-printer/issues/115#issuecomment-1885182504, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM6ZFYHCEGBCJKS5KJJBKH3YN26KPAVCNFSM6AAAAAA3772BC2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBVGE4DENJQGQ . You are receiving this because you were mentioned.Message ID: @.***>

Savan-ITDEV avatar Jan 10 '24 16:01 Savan-ITDEV

I suggest try my package : https://github.com/Savan-ITDEV/react-native-savanitdev-thermal-printer Hope will help you ^^ On Wed, 10 Jan 2024 at 11:26 PM Waleed Tariq @.> wrote: Use this solution will help you, solution 2 - every print disconnects first and then reconnects and print is done ^^ EZ … <#m_6840549305437100080_> On Wed, 10 Jan 2024 at 11:19 PM Waleed Tariq @.> wrote: @Savan-ITDEV https://github.com/Savan-ITDEV https://github.com/Savan-ITDEV https://github.com/Savan-ITDEV But sometimes, i've notied that if internet turns off and then back on, The printer shows as connected but does not print. Similarly if print turns off and back on, it looses ability to print. Any solution here? — Reply to this email directly, view it on GitHub <#115 (comment) <#115 (comment)>>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM6ZFYCC6BYL4WODSAWIJ6DYN25SFAVCNFSM6AAAAAA3772BC2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBVGE3TAOJZGI https://github.com/notifications/unsubscribe-auth/AM6ZFYCC6BYL4WODSAWIJ6DYN25SFAVCNFSM6AAAAAA3772BC2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBVGE3TAOJZGI . You are receiving this because you were mentioned.Message ID: @.> @Savan-ITDEV https://github.com/Savan-ITDEV This can be a workaround but it's not a viable solution. The android/ios SDK itself handles reconnectivity scenarios. It just needs to be added to this package as a built in feature — Reply to this email directly, view it on GitHub <#115 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AM6ZFYHCEGBCJKS5KJJBKH3YN26KPAVCNFSM6AAAAAA3772BC2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBVGE4DENJQGQ . You are receiving this because you were mentioned.Message ID: @.**>

Does this work with Epson Printers and both on IOS and Android?

Waleed065 avatar Jan 10 '24 16:01 Waleed065

Should work with the latest version

tr3v3r avatar Aug 16 '24 09:08 tr3v3r