You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

Reply
 
Thread Tools Display Modes
Old June 22nd, 2022, 02:17 PM   #1
rguimond
Lifetime Supporting Member
Canada

rguimond is offline
 
Join Date: Jul 2009
Location: Escuminac
Posts: 663
Help with my first TCP Socket program

I'm trying to set up a TCP Socket connection between a CompactLogix 1769-L16 and a printer that can receive external data through a TCP socket.

I know the printer IP address and port (192.168.25.112:10000) and I can send the printer a message using Hercules setup utility

I have a sample program from Rockwell (Socket TCP Client) imported into my program and I can get the "Delete All Socket Requests" and "Create Socket Request" messages status to change to DN

The next message block always fails with error code 16#0000_0046, which indicates that:

Connect Service message:
– Server IP exists, but port does not.
– Server IP and port exist, but it does not accept connection on this port.
– Service ‘timeout’ value in UDT set to 0 or low value

Since I know the IP address and port are correct, it leads me to think the timeout value is too low, but I have absolutely no idea how to increase it. Can anyone help?
__________________
"If you can't measure it, you can't manage it!"
  Reply With Quote
Old June 22nd, 2022, 02:33 PM   #2
L33er
Member
United States

L33er is offline
 
L33er's Avatar
 
Join Date: Feb 2021
Location: North
Posts: 168
1. printer OFF for a few seconds, then ON again.
2. Timeout in OpenConnection source
  Reply With Quote
Old June 22nd, 2022, 06:29 PM   #3
Contr_Conn
Member
United States

Contr_Conn is offline
 
Contr_Conn's Avatar
 
Join Date: Sep 2003
Location: Ohio
Posts: 2,376
Port 10000 looks very suspicious.
Did you try a Telnet connection to this port?
It’s typically port 9100.
There is a printer sample code in the Knowledgebase that I know works.
You can also do a wireshark trace and post it here.
  Reply With Quote
Old June 23rd, 2022, 05:44 AM   #4
rguimond
Lifetime Supporting Member
Canada

rguimond is offline
 
Join Date: Jul 2009
Location: Escuminac
Posts: 663
Quote:
Originally Posted by Contr_Conn View Post
Port 10000 looks very suspicious.
Did you try a Telnet connection to this port?
It’s typically port 9100.
There is a printer sample code in the Knowledgebase that I know works.
You can also do a wireshark trace and post it here.
Port 10,000 definitely works. I was able to send the message to the printer over this port using Hercules
__________________
"If you can't measure it, you can't manage it!"
  Reply With Quote
Old June 23rd, 2022, 08:53 AM   #5
Contr_Conn
Member
United States

Contr_Conn is offline
 
Contr_Conn's Avatar
 
Join Date: Sep 2003
Location: Ohio
Posts: 2,376
I don't know what the Hercules does, but if it works, can you do a Wireshark trace and post it here along with PLC traffic capture.
If you think that port 10000 is correct, why not to get a print sample code from the Knowledgebase and change port there from 9100 to 10000?
  Reply With Quote
Old June 23rd, 2022, 09:22 AM   #6
rguimond
Lifetime Supporting Member
Canada

rguimond is offline
 
Join Date: Jul 2009
Location: Escuminac
Posts: 663
Quote:
Originally Posted by Contr_Conn View Post
I don't know what the Hercules does, but if it works, can you do a Wireshark trace and post it here along with PLC traffic capture.
If you think that port 10000 is correct, why not to get a print sample code from the Knowledgebase and change port there from 9100 to 10000?
That's exactly what I did (sample code from knowledgebase). I figured that changing the tag values for the IP address and port would have done the trick, but I guess not.

Hercules setup utility - https://www.hw-group.com/software/he...-setup-utility
__________________
"If you can't measure it, you can't manage it!"
  Reply With Quote
Old June 23rd, 2022, 10:42 AM   #7
Contr_Conn
Member
United States

Contr_Conn is offline
 
Contr_Conn's Avatar
 
Join Date: Sep 2003
Location: Ohio
Posts: 2,376
Unfortunately, you are not giving us any information that can help.
Post wireshark traces and your ACD file upload in faulted state.

You are saying that you are using Socket Client Program (in the first post), I am telling you to get Printer Sample application.
  Reply With Quote
Old June 26th, 2022, 06:21 AM   #8
rguimond
Lifetime Supporting Member
Canada

rguimond is offline
 
Join Date: Jul 2009
Location: Escuminac
Posts: 663
Solved

I finally figured this out, and it was by pure luck…

As I mentioned previously, I was able to send a message to the printer using Hercules from my PC, but was unable to send it from a PLC.

Wireshark wasn’t an option due (stupid reason).

At the end of the day on Thursday, I happened to glance at the path to my PLC in RSLogix and noticed it was 10.250.1.11. This confused me, as the network diagram clearly indicated the PLC was assigned an address of 192.168.25.11.

I checked the network configuration on the PC and found it had three assigned IP addresses - 192.168.25.202, 10.250.1.202 and 10.172.216.202.

Upon further investigation, I found a NAT device in a control cabinet. The NAT converts devices from 192.168.25.xxx to 10.250.1.xxx

Because the PC was assigned an IP address in each subnet, I was able to ping and connect to the printer and PLC, but the printer was connected to the “public” side of the NAT, so the PLC couldn’t see it

I’ve since modified the sample code to cascade through the necessary MSGs and it works fine.

I hope someone takes something away from this.

I can’t say enough about as-built diagrams!
__________________
"If you can't measure it, you can't manage it!"
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Compactlogix TCP Socket OpenConnection to Zebra Printer radamson LIVE PLC Questions And Answers 5 June 18th, 2022 07:25 PM
TCP Socket Communication with A-B's between Logix Controllers Finnbliss LIVE PLC Questions And Answers 4 August 3rd, 2021 08:53 AM
Help me make this program more efficient. Issues with detecting sensors for... Brandon_K LIVE PLC Questions And Answers 7 September 11th, 2016 10:36 AM
TCP Socket Client Error 16#11 AndyEM LIVE PLC Questions And Answers 4 August 7th, 2016 01:01 PM
SCADAPack-334 Modbus TCP Sample Program halburgepramod LIVE PLC Questions And Answers 1 July 16th, 2010 09:57 AM


All times are GMT -4. The time now is 09:20 AM.


.