Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am using the Flutter package flutter_esc_printer: ^0.1.0 to print to a thermal receipt printer.
Normally I expect the printer will be connected by Ethernet but it gives the error SocketException: OS Error: Connection timed out, errno = 110, address = 192.19.170.13, port = 47763.

What I have tried:

this is my code-

Future<Ticket> testTicket(PaperSize paper) async {
    final Ticket ticket = Ticket(paper);
//
uid = FirebaseAuth.instance.currentUser.uid;
      areaRef=FirebaseDatabase.instance
        .reference()
        .child('Area')
       .child(uid);
  areaRef.once().then((DataSnapshot snapshot){
     contactList .clear();
  Map<dynamic, dynamic> values = snapshot.value;
          values.forEach((key,values){
            values["key"]=key;
            // if(values[1]==uid)
            // {
          contactList.add(values);
          }); 
  });
//
    ticket.text(
       "Area Details",
        styles: PosStyles(align: PosAlign.center));
    ticket.text('Kissan Accounting',
        styles: PosStyles(align: PosAlign.center));
    ticket.hr();
    ticket.row([
      PosColumn(
          text: 'Area Name',
          width: 2,
          styles: PosStyles(align: PosAlign.left, bold: true)),
      PosColumn(
          text: 'Area/Unit',
          width: 2,
          styles: PosStyles(align: PosAlign.left, bold: true)),
      PosColumn(
          text: 'Source',
          width: 3,
          styles: PosStyles(align: PosAlign.center, bold: true)),
      PosColumn(
          text: 'IrrigatedType',
          width: 3,
          styles: PosStyles(align: PosAlign.center, bold: true)),
      PosColumn(
          text: 'Location',
          width: 2,
          styles: PosStyles(align: PosAlign.right, bold: true)),
    ]);
      for(int i=0;i<contactList.length;i++)
    ticket.row([
      PosColumn(text: contactList[i]["areaname"], width: 2),
      PosColumn(
          text:  contactList[i]["area"],
          width: 2,
          styles: PosStyles(
            align: PosAlign.left,
          )),
      PosColumn(
          text: contactList[i]["Source"],
          width: 3,
          styles: PosStyles(
            align: PosAlign.center,
          )),
      PosColumn(text: contactList[i]["IrrigatedType"], width: 3, styles: PosStyles(align: PosAlign.center)),
      PosColumn(text: contactList[i]["Location"], width: 2, styles: PosStyles(align: PosAlign.right)),
    ]);
    ticket.hr(ch: '=', linesAfter: 1);
     ticket.text('Thank you!',
        styles: PosStyles(align: PosAlign.center, bold: true));

    ticket.feed(2);
    ticket.cut();
    return ticket;
  }
  _testPrint() async {
    const PaperSize paper = PaperSize.mm80;
    String address =  "192.168.0.111"; // 192.168.10.10
    if(address.isIpAddress){
      //print vai ip address
      _printerNetworkManager.selectPrinter(address);
      final res = await _printerNetworkManager.printTicket(await testTicket(paper));
      
    }else if(address.isMacAddress) {
      //print vai mac address
      _printerBluetoothManager.selectPrinter(address);
      final res = await _printerBluetoothManager.printTicket(await testTicket(paper));
    
    }else{
      print("Error :e");
    }
  }
Posted
Updated 12-Apr-21 17:08pm
v3
Comments
Richard MacCutchan 15-Mar-21 5:00am    
Connection time out means something wrong with the connection between the application and the device. Not something that we can help with as it is local to your network.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900