Author Topic: TCP Client socket exception  (Read 2057 times)

Joe Matkowski

  • Newbie
  • *
  • Posts: 47
    • View Profile
TCP Client socket exception
« on: January 17, 2019, 09:51:08 AM »
Attached is screenshot of exception I get when using generic tcp client.  I am just fooling around trying to send data back and forth between two laptops. I tried  using a timer to send data using "GenericTCPClient1.SendString("MyDataString")" got exception so I deleted timer and used a button click and got the same exception. Any ideas??

Jody

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5323
    • View Profile
    • AdvancedHMI
Re: TCP Client socket exception
« Reply #1 on: January 17, 2019, 10:38:20 AM »
What are you using for the server?

Joe Matkowski

  • Newbie
  • *
  • Posts: 47
    • View Profile
Re: TCP Client socket exception
« Reply #2 on: January 17, 2019, 10:47:55 AM »
Hercules / TCP Server tab, Hercules shows connection from the correct ip address, I have tried a clean copy of the latest AHMI and I just tried with 3.99w using your example from the forum post  https://www.advancedhmi.com/forum/index.php?topic=1982.msg11087#msg11087.  Also I have tried changing to different ports thinking my router might be blocking it internally but no luck.

jdm

Joe Matkowski

  • Newbie
  • *
  • Posts: 47
    • View Profile
Re: TCP Client socket exception
« Reply #3 on: January 17, 2019, 10:54:24 AM »
With the clean version of 3.99w I do not get the exception but I also do not get any data.

jdm

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5323
    • View Profile
    • AdvancedHMI
Re: TCP Client socket exception
« Reply #4 on: January 17, 2019, 11:25:25 AM »
The client does require a terminating characters so it knows where the end of the packet is. By default it is set to a carriage return. Does the server send a terminating character?

Joe Matkowski

  • Newbie
  • *
  • Posts: 47
    • View Profile
Re: TCP Client socket exception
« Reply #5 on: January 17, 2019, 12:00:53 PM »
I don't believe it does, I added <CR> as well as ##13 per the help popup still cannot receive data, however I can send a string to hercules

jdm

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5323
    • View Profile
    • AdvancedHMI
Re: TCP Client socket exception
« Reply #6 on: January 17, 2019, 12:58:59 PM »
In the GenericTCPClient.vb file, insert a break point at line 292

           While i < StateObject.CurrentIndex
 
then run the application to see if it goes to that break point. If it does, then hover over CurrentIndex to see what the value it.

Next move the breakpoint to line 295:

               If CurrentByte = m_TerminatingByteValue Then
 
Then press F5 and each time it hits the breakpoint, hover over CurrentByte to see what the value is. The last byte should equal the TerminatingByteValue, otherwise it will never process the packet.

Joe Matkowski

  • Newbie
  • *
  • Posts: 47
    • View Profile
Re: TCP Client socket exception
« Reply #7 on: January 18, 2019, 09:10:27 AM »
Archie Sorry for the delay I got tied up on another fire to put out.  It is not getting a terminating byte using hercules as server. I am going to try and setup two AHMI programs using this version I have that will at least send data and see if I can get it working that way.   

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5323
    • View Profile
    • AdvancedHMI
Re: TCP Client socket exception
« Reply #8 on: January 18, 2019, 01:39:20 PM »
Is there something you can key off of to know when the full packet is received such as a fixed packet length? Most Ethernet protocols have a packet length in the header that is used to determine when the full packet was received.

Joe Matkowski

  • Newbie
  • *
  • Posts: 47
    • View Profile
Re: TCP Client socket exception
« Reply #9 on: January 21, 2019, 10:19:38 AM »
I have tried two clean versions with your setup and I cannot get them to send back and forth, Not sure what you mean by "key off"  I am pretty much way over my head at this point.  The main goal of this project is to be able to send data to and from a proprietary scada platform, as all of the equipment we manufacture is rental equipment we have a customer that wants to fully integrate there system into ours for reporting, at the end of the day I need to be able to send a csv string to there system via tcp socket and receive and parse the string they send back.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5323
    • View Profile
    • AdvancedHMI
Re: TCP Client socket exception
« Reply #10 on: January 21, 2019, 11:20:39 AM »
When I say "key off", imagine 2 packets received back to back in a continuous stream. What could be used to know there were 2 packets and exactly where to split the stream?