# How things work - ignition and TCP printer

**URL:** <https://forum.inductiveautomation.com/t/how-things-work-ignition-and-tcp-printer/59712>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [May 18, 2022, 10:22am UTC](https://forum.inductiveautomation.com/t/how-things-work-ignition-and-tcp-printer/59712 "2022-05-18T10:22:09Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![hewking32](https://avatars.discourse-cdn.com/v4/letter/h/b5ac83/32.png) [@hewking32](https://forum.inductiveautomation.com/u/hewking32)\
**Post date:** [May 18, 2022, 10:22am UTC](https://forum.inductiveautomation.com/t/how-things-work-ignition-and-tcp-printer/59712/1 "2022-05-18T10:22:09Z")

</div>

Hi All.  
If i would like to trigger label printing from TCP printer by pressing a button on ignition Vision client what would like have to consider to get it set up? Any gateway settings, anything other thoughts please? Sorry its a bit broad question.  
Regards

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [May 18, 2022, 11:11am UTC](https://forum.inductiveautomation.com/t/how-things-work-ignition-and-tcp-printer/59712/2 "2022-05-18T11:11:39Z")

</div>

Tag your question as _Vision_ or _Perspective_. It will matter.

---

<div class="post-metadata">

**Author:** ![hewking32](https://avatars.discourse-cdn.com/v4/letter/h/b5ac83/32.png) [@hewking32](https://forum.inductiveautomation.com/u/hewking32)\
**Post date:** [May 18, 2022, 11:24am UTC](https://forum.inductiveautomation.com/t/how-things-work-ignition-and-tcp-printer/59712/3 "2022-05-18T11:24:00Z")

</div>

i edited my question as Vision related

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [May 18, 2022, 11:32am UTC](https://forum.inductiveautomation.com/t/how-things-work-ignition-and-tcp-printer/59712/4 "2022-05-18T11:32:47Z")

</div>

That’s fine but some of the experts will be watching by tag and may miss your question. That’s why I suggested the tag.

---

<div class="post-metadata">

**Author:** ![hewking32](https://avatars.discourse-cdn.com/v4/letter/h/b5ac83/32.png) [@hewking32](https://forum.inductiveautomation.com/u/hewking32)\
**Post date:** [May 18, 2022, 11:48am UTC](https://forum.inductiveautomation.com/t/how-things-work-ignition-and-tcp-printer/59712/5 "2022-05-18T11:48:35Z")

</div>

good point - i just added Vision tag

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 18, 2022, 12:25pm UTC](https://forum.inductiveautomation.com/t/how-things-work-ignition-and-tcp-printer/59712/6 "2022-05-18T12:25:28Z")

</div>

Depends on how you generate your label. ZPL, perhaps?

A Vision client can open a socket, send the bytes of ZPL, and close the socket in one go. Since it is likely to execute in less than a tenth of a second, I would just call the function that does it in the button’s actionPerformed event.

---

<div class="post-metadata">

**Author:** ![hewking32](https://avatars.discourse-cdn.com/v4/letter/h/b5ac83/32.png) [@hewking32](https://forum.inductiveautomation.com/u/hewking32)\
**Post date:** [May 18, 2022, 12:40pm UTC](https://forum.inductiveautomation.com/t/how-things-work-ignition-and-tcp-printer/59712/7 "2022-05-18T12:40:54Z")

</div>

Thanks for your reply Phil.  
yes it is ZPL indeed and in the project the existing code does have socket transmission code which i can simulate on chrome ZPL simulator (using local address) to see what label will look like.

I am wondering what might go wrong 🙂 or what i need to consider when this label print command go to the TCP printer ?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 18, 2022, 1:07pm UTC](https://forum.inductiveautomation.com/t/how-things-work-ignition-and-tcp-printer/59712/8 "2022-05-18T13:07:00Z")

</div>

When driven by a button, I just tolerate any error dialogs that result from comms problems.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 18, 2022, 1:08pm UTC](https://forum.inductiveautomation.com/t/how-things-work-ignition-and-tcp-printer/59712/9 "2022-05-18T13:08:02Z")

</div>

If there is any chance of non-ASCII content, I would use the `java.net` classes, not python’s `socket` module.

---

<div class="post-metadata">

**Author:** ![hewking32](https://avatars.discourse-cdn.com/v4/letter/h/b5ac83/32.png) [@hewking32](https://forum.inductiveautomation.com/u/hewking32)\
**Post date:** [May 18, 2022, 1:09pm UTC](https://forum.inductiveautomation.com/t/how-things-work-ignition-and-tcp-printer/59712/10 "2022-05-18T13:09:40Z")

</div>

Good point regarding java classes. Thank you

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [May 18, 2022, 2:40pm UTC](https://forum.inductiveautomation.com/t/how-things-work-ignition-and-tcp-printer/59712/11 "2022-05-18T14:40:09Z")

</div>

> [@pturmel](#):
>
> If there is any chance of non-ASCII content, I would use the `java.net` classes, not python’s `socket` module.

Sidebar, I wonder if a `system.net.socket()` context manager would be used often enough to be worth inclusion. Might just cause more confusion in Perspective...

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 18, 2022, 2:47pm UTC](https://forum.inductiveautomation.com/t/how-things-work-ignition-and-tcp-printer/59712/12 "2022-05-18T14:47:38Z")

</div>

> [@paul-griffith](#):
>
> Might just cause more confusion in Perspective…

Nah, already maxed out. 😆

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [May 18, 2022, 2:48pm UTC](https://forum.inductiveautomation.com/t/how-things-work-ignition-and-tcp-printer/59712/13 "2022-05-18T14:48:28Z")

</div>

Opening and closing a socket isn’t the hard part about what most people are trying to do with sockets.

The hard part is it’s not easy to set up a long running / background task or anything that needs a more complicated lifecycle than when projects restart.

You need a PhD in Ignition’s obscure scripting implementation details to maybe not screw it up and have a memory leak.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 18, 2022, 2:50pm UTC](https://forum.inductiveautomation.com/t/how-things-work-ignition-and-tcp-printer/59712/14 "2022-05-18T14:50:03Z")

</div>

> [@paul-griffith](#):
>
> if a `system.net.socket()` context manager

More seriously, `java.net` and friends are not that difficult to use, and anyone trying to use advice from StackOverflow and such will want them as-is. I wouldn't bother.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 18, 2022, 2:52pm UTC](https://forum.inductiveautomation.com/t/how-things-work-ignition-and-tcp-printer/59712/15 "2022-05-18T14:52:05Z")

</div>

> [@Kevin.Herron](#):
>
> obscure scripting implementation details

I probably should encapsulate some of my techniques in my LifeCycle module to make this easier.
