# How to connect to and read from a Moxa NPort IA5150A

**URL:** <https://forum.inductiveautomation.com/t/how-to-connect-to-and-read-from-a-moxa-nport-ia5150a/77232>\
**Category:** Ignition\
**Created:** [August 1, 2023, 3:50pm UTC](https://forum.inductiveautomation.com/t/how-to-connect-to-and-read-from-a-moxa-nport-ia5150a/77232 "2023-08-01T15:50:56Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![john\_hall](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@john\_hall](https://forum.inductiveautomation.com/u/john_hall)\
**Post date:** [August 1, 2023, 3:50pm UTC](https://forum.inductiveautomation.com/t/how-to-connect-to-and-read-from-a-moxa-nport-ia5150a/77232/1 "2023-08-01T15:50:56Z")

</div>

Hello, we have a Moxa hooked up to a scale serving on a TCP/IP when I try to read from socket I get...

Caused by: org.python.core.PyException: \_socket.error: [Errno 10061] Connection refused

or when I try adding as a device I get...

...drivers.TCPDriver[Moxa].TCPConnection[49 Error connecting to 192.168.98.233:4990. Cannot assign requested address: bind: /192.168.98.233:4990

---

<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:** [August 1, 2023, 3:53pm UTC](https://forum.inductiveautomation.com/t/how-to-connect-to-and-read-from-a-moxa-nport-ia5150a/77232/2 "2023-08-01T15:53:03Z")

</div>

> [@john\_hall](#):
>
> Cannot assign requested address: bind: /192.168.98.233:4990

Did you mistakenly put the Moxa IP address into the "Local Address" of the TCP Device settings?

---

<div class="post-metadata">

**Author:** ![john\_hall](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@john\_hall](https://forum.inductiveautomation.com/u/john_hall)\
**Post date:** [August 1, 2023, 3:54pm UTC](https://forum.inductiveautomation.com/t/how-to-connect-to-and-read-from-a-moxa-nport-ia5150a/77232/3 "2023-08-01T15:54:02Z")

</div>

I have the gateway as local

---

<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:** [August 1, 2023, 3:55pm UTC](https://forum.inductiveautomation.com/t/how-to-connect-to-and-read-from-a-moxa-nport-ia5150a/77232/4 "2023-08-01T15:55:15Z")

</div>

Try removing it. It's almost never necessary, generally only used to specify a specific NIC to make the connection from in a multi-NIC host when your routing tables are broken.

That said, it probably still won't work, because it looks like you have a plain ol' network/firewall/configuration error. (TCP connection refused)

---

<div class="post-metadata">

**Author:** ![john\_hall](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@john\_hall](https://forum.inductiveautomation.com/u/john_hall)\
**Post date:** [August 1, 2023, 3:55pm UTC](https://forum.inductiveautomation.com/t/how-to-connect-to-and-read-from-a-moxa-nport-ia5150a/77232/5 "2023-08-01T15:55:16Z")

</div>

Would tcp driver be the correct driver?

---

<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:** [August 1, 2023, 3:55pm UTC](https://forum.inductiveautomation.com/t/how-to-connect-to-and-read-from-a-moxa-nport-ia5150a/77232/6 "2023-08-01T15:55:35Z")

</div>

Yes. Maybe. Depends what you have on the other side of this thing.

---

<div class="post-metadata">

**Author:** ![john\_hall](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@john\_hall](https://forum.inductiveautomation.com/u/john_hall)\
**Post date:** [August 1, 2023, 3:56pm UTC](https://forum.inductiveautomation.com/t/how-to-connect-to-and-read-from-a-moxa-nport-ia5150a/77232/7 "2023-08-01T15:56:52Z")

</div>

I'm thinking its a firewall issue as well. I can write to socket to send zpl code to a printer. But I get connection refused when trying to read from socket.

---

<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:** [August 1, 2023, 3:58pm UTC](https://forum.inductiveautomation.com/t/how-to-connect-to-and-read-from-a-moxa-nport-ia5150a/77232/8 "2023-08-01T15:58:02Z")

</div>

You sure you're not opening a second socket without closing the first or something?

Connection refused happens when you open it, not when you read. If you were actually able to write you already opened it.

Share some code, maybe take a Wireshark capture.

---

<div class="post-metadata">

**Author:** ![john\_hall](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@john\_hall](https://forum.inductiveautomation.com/u/john_hall)\
**Post date:** [August 1, 2023, 3:58pm UTC](https://forum.inductiveautomation.com/t/how-to-connect-to-and-read-from-a-moxa-nport-ia5150a/77232/9 "2023-08-01T15:58:53Z")

</div>

import socket   
s = socket.socket()  
s.connect(('192.168.98.233',4990))

it hangs up and connection refused

---

<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:** [August 1, 2023, 3:59pm UTC](https://forum.inductiveautomation.com/t/how-to-connect-to-and-read-from-a-moxa-nport-ia5150a/77232/10 "2023-08-01T15:59:28Z")

</div>

Right, so that's where the plain network/firewall/whatever issue is. But then you mentioned you can write...

---

<div class="post-metadata">

**Author:** ![john\_hall](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@john\_hall](https://forum.inductiveautomation.com/u/john_hall)\
**Post date:** [August 1, 2023, 4:00pm UTC](https://forum.inductiveautomation.com/t/how-to-connect-to-and-read-from-a-moxa-nport-ia5150a/77232/11 "2023-08-01T16:00:24Z")

</div>

I can write to a different address the printer on. Maybe IT added a rule? They haven't been helpful.

---

<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:** [August 1, 2023, 4:00pm UTC](https://forum.inductiveautomation.com/t/how-to-connect-to-and-read-from-a-moxa-nport-ia5150a/77232/12 "2023-08-01T16:00:44Z")

</div>

Also, FWIW, if you search "ZPL" on the forum you'll find a few different posts where people have done this via scripting. It's probably better than trying to use the TCP driver. But you still have to figure out the network or configuration problem first.

---

<div class="post-metadata">

**Author:** ![john\_hall](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@john\_hall](https://forum.inductiveautomation.com/u/john_hall)\
**Post date:** [August 24, 2023, 2:29pm UTC](https://forum.inductiveautomation.com/t/how-to-connect-to-and-read-from-a-moxa-nport-ia5150a/77232/13 "2023-08-24T14:29:03Z")

</div>

Alright. So we got it hooked up and receiving data. Now I am coming across this issue.

 ![Moxa Read out](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/f/af7d8836786671450241e0e14cdf2aae1e2f74c2.jpeg)

The value keeps cycling through each portion in the opc tag.value  
S... T... +... 188...lb... etc

 ![serial out](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/2/8225bc9e5fb9dda577de2e4a2b47ccb45deae510.png)

Is there a way to grab just the data section?

---

<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:** [August 24, 2023, 2:35pm UTC](https://forum.inductiveautomation.com/t/how-to-connect-to-and-read-from-a-moxa-nport-ia5150a/77232/14 "2023-08-24T14:35:57Z")

</div>

What message and delimiter settings did you configure the TCP driver with?

---

<div class="post-metadata">

**Author:** ![john\_hall](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@john\_hall](https://forum.inductiveautomation.com/u/john_hall)\
**Post date:** [August 24, 2023, 2:38pm UTC](https://forum.inductiveautomation.com/t/how-to-connect-to-and-read-from-a-moxa-nport-ia5150a/77232/15 "2023-08-24T14:38:49Z")

</div>

None? lol. taking a look now

---

<div class="post-metadata">

**Author:** ![john\_hall](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@john\_hall](https://forum.inductiveautomation.com/u/john_hall)\
**Post date:** [August 24, 2023, 2:40pm UTC](https://forum.inductiveautomation.com/t/how-to-connect-to-and-read-from-a-moxa-nport-ia5150a/77232/16 "2023-08-24T14:40:45Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/6/8616972ac46bc4ab246670a3e56fa37484e76f3d.png)

I left it as default

---

<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:** [August 24, 2023, 2:41pm UTC](https://forum.inductiveautomation.com/t/how-to-connect-to-and-read-from-a-moxa-nport-ia5150a/77232/17 "2023-08-24T14:41:39Z")

</div>

Switch to Message Based with a delimiter of “\r\n”.

You’ll get the whole message as the value and you can split or process it up in Ignition with a value change script or expression.

---

<div class="post-metadata">

**Author:** ![john\_hall](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@john\_hall](https://forum.inductiveautomation.com/u/john_hall)\
**Post date:** [August 24, 2023, 2:44pm UTC](https://forum.inductiveautomation.com/t/how-to-connect-to-and-read-from-a-moxa-nport-ia5150a/77232/18 "2023-08-24T14:44:12Z")

</div>

Thank you so much!  
trying it now.

---

<div class="post-metadata">

**Author:** ![john\_hall](https://avatars.discourse-cdn.com/v4/letter/j/f9ae1b/32.png) [@john\_hall](https://forum.inductiveautomation.com/u/john_hall)\
**Post date:** [August 24, 2023, 2:47pm UTC](https://forum.inductiveautomation.com/t/how-to-connect-to-and-read-from-a-moxa-nport-ia5150a/77232/19 "2023-08-24T14:47:07Z")

</div>

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/d/dd72fe0d084addedd271c1655c930f207d0221e1.png)

I dont see messageBased on here.

CharacterBased with the \r\n in the Field Delimiter?

---

<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:** [August 24, 2023, 2:48pm UTC](https://forum.inductiveautomation.com/t/how-to-connect-to-and-read-from-a-moxa-nport-ia5150a/77232/20 "2023-08-24T14:48:57Z")

</div>

Oops, I guess I meant Character Based.

I think leave the Field settings alone.

[Next page](https://forum.inductiveautomation.com/t/how-to-connect-to-and-read-from-a-moxa-nport-ia5150a/77232.md?page=2)
