Author Topic: Inconsistent results with TCPConnect  (Read 13840 times)

benhowdle89

  • Newbie
  • Posts: 2
  • I'm a llama!
    • View Profile
Inconsistent results with TCPConnect
« on: November 26, 2010, 01:59:09 AM »
Hi, we are using the Nano-10 PLC to monitor 4 pulse meters, then we have a custom function that opens a TCP connection to a php script i've written on our website, this php script takes the counter values and logs them to a mysql. The link is working fine and we have the custom function running every 10 minutes, however it will not send data maybe once every 4/5 times. So we have gaps in our trends. Is there anything anyone can think of that might be causing this?

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Inconsistent results with TCPConnect
« Reply #1 on: November 27, 2010, 06:24:49 AM »
Did you embed in your code a check for successful connection to the remote host? When you perform a <TCPCONNECT> your remote server would have sent some data back to the PLC (e.g. HTTP protocol data) and the PLC can analyze to determine if it has made a successful connection. If not it should repeat the data upload process and give a warning (e.g. log the result to a text file via the TLServer) and you can then analyze the text file to determine if there was any failed connection.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

benhowdle89

  • Newbie
  • Posts: 2
  • I'm a llama!
    • View Profile
Re:Inconsistent results with TCPConnect
« Reply #2 on: November 29, 2010, 01:18:14 AM »
We got the code off a software guy at Tri PLC so i presume he put all of the checks in there. The only thing we can put it down to is the network reliability we have at the PLC site. If its that then we have to deal with it, but i was just wondering if there were any obvious problems people were having!

gillecaluim

  • Newbie
  • Posts: 13
  • I'm a llama!
    • View Profile
Re:Inconsistent results with TCPConnect
« Reply #3 on: November 23, 2011, 03:05:24 PM »
I'd like to start logging to mysql server also but can't find any documentation for this capability.  Could you share please how this is done ;D

Rycon

  • Newbie
  • Posts: 1
    • View Profile
Re:Inconsistent results with TCPConnect
« Reply #4 on: November 18, 2012, 01:42:03 AM »
I'm trying to pass a sting to php script on server using <TCPCONNECT> but i can't get it to work. Can't find much info on using <TCPCONNECT>. Can someone please direct me to more info or give me a hint of the correct syntax???

PHP Server: 192.168.2.200

php script: test.php

I've tried the obvious:

PRINT #4 "<TCPCONNECT 192.168.2.200/test.php?id=string>"

I've tried quite a few combinations of things but can't get it working.

I've put 192.168.2.200/test.php?id=string into address bar of browser on another computer on network and works fine, certain server is set up ok. Any help would be appreciated.

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Inconsistent results with TCPConnect
« Reply #5 on: November 19, 2012, 11:47:48 AM »
<TCPCONNECT> is used to make a socket connection to a server. You must first establish a connection, then send the data in HTTP format. Since your PHP server appears to be at the default HTTP port (80), so you first do a connect:

<TCPCONNECT 192.168.2.200:80>

When this is successful, you can then use PRINT #4 to send the data to the webserver. In your case the actual data you are sending to the HTTP server should be the following:

PRINT #4 "GET /test.php?id=string"


These is the simplest HTTP request code. You can send more data if need be.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS