News:

  • October 02, 2026, 06:56:43 AM

Login with username, password and session length

Author Topic: HTTPCMD Help  (Read 33120 times)

Bolt

  • Hero Member
  • *****
  • Posts: 598
HTTPCMD Help
« on: August 30, 2019, 11:14:18 AM »
I'm trying to implement the new HTTPCMD into my code.  I'm not having much luck.  My setup currently works with PING, OPENTCP, STREAMOUT, STREAMIN, STR2INT, etc in multiple stages.

I'm trying to replace the logic with the new HTTPCMD.  I'm starting small, just trying to replace the initial STREAMOUT with HTTTPCMD.  I've also tried keeping the existing OPENTCP for now.

My current request to server via STREAMOUT is along the lines of "GET http://" FmtInt(D300,ipaddr) "/post/lookup.php?c=" SL[V310] "$0D$0A".  This simply translates to "GET http://192.168.0.10/post/lookup.php?c=P-20..", which has worked for along time the old way.

I've tried many versions in the Request box, with and without GET and <CR><LF>, adding the <CR><LF> as Additional Request (help file says with single request Do-more adds it automatically) without all the pointers, without the FmtInt, just as text, etc.  No luck.  Some versions I get a 200 Response Code, others a 400.

How can I troubleshoot further?  Is there a way to get the HTTPCMD activities to log to Do-more Logger?  How do I proceed here?

Andrew S

  • Hero Member
  • *****
  • Posts: 144
Re: HTTPCMD Help
« Reply #1 on: August 30, 2019, 11:34:40 AM »
HTTPCMD is a standalone function - don't use OPENTCP with it. The URL is built by the command too - input the hostname (192.168.0.10) and the path (post/lookup.php?c=P-20) into the relevant fields. Select the command type (GET) from the dropdown - don't include it in the request.

Think of HTTPCMD as a wrapper for OPENTCP/STREAMOUT/CLOSE.




BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6176
  • Yes Pinky, Do-more will control the world!
Re: HTTPCMD Help
« Reply #2 on: August 30, 2019, 12:50:16 PM »
I'm trying to implement the new HTTPCMD into my code.  I'm not having much luck.  My setup currently works with PING, OPENTCP, STREAMOUT, STREAMIN, STR2INT, etc in multiple stages.

I'm trying to replace the logic with the new HTTPCMD.  I'm starting small, just trying to replace the initial STREAMOUT with HTTTPCMD.  I've also tried keeping the existing OPENTCP for now.

My current request to server via STREAMOUT is along the lines of "GET http://" FmtInt(D300,ipaddr) "/post/lookup.php?c=" SL[V310] "$0D$0A".  This simply translates to "GET http://192.168.0.10/post/lookup.php?c=P-20..", which has worked for along time the old way.

I've tried many versions in the Request box, with and without GET and <CR><LF>, adding the <CR><LF> as Additional Request (help file says with single request Do-more adds it automatically) without all the pointers, without the FmtInt, just as text, etc.  No luck.  Some versions I get a 200 Response Code, others a 400.

How can I troubleshoot further?  Is there a way to get the HTTPCMD activities to log to Do-more Logger?  How do I proceed here?

As was mentioned, HTTPCMD is standalone and doesn't require anything else.

HTTPCMD does output status messages to DMLogger when you set $EnableMsgDump(ST36).
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

Bolt

  • Hero Member
  • *****
  • Posts: 598
Re: HTTPCMD Help
« Reply #3 on: August 30, 2019, 12:56:06 PM »
It gives the option to use existing connection, so that's how I plugged it into my existing logic at first.  I removed it entirely, and I have it working now.  Only issue is, using HTTCMD the Server.Connected bit is active for ~15 seconds, using the old stages with OPENTCP, STREAMOUT, STREAMIN, CLOSE instructions, it was ~0.5 seconds.  What am I missing here, why is the new instruction so much slower than the old method?

Also, my return string seems to have <CR><LF>0<CR><LF> added to the end.  Is there a way I can prevent that, or do I manually have to parse it?  I was not looking for it before in my STREAMIN, I took the whole queue's contents.  What causes that to be added?

Thanks for the pointers!

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6176
  • Yes Pinky, Do-more will control the world!
Re: HTTPCMD Help
« Reply #4 on: August 30, 2019, 12:58:34 PM »
It gives the option to use existing connection, so that's how I plugged it into my existing logic at first.  I removed it entirely, and I have it working now.  Only issue is, using HTTCMD the Server.Connected bit is active for ~15 seconds, using the old stages with OPENTCP, STREAMOUT, STREAMIN, CLOSE instructions, it was ~0.5 seconds.  What am I missing here, why is the new instruction so much slower than the old method?

Also, my return string seems to have <CR><LF>0<CR><LF> added to the end.  Is there a way I can prevent that, or do I manually have to parse it?  I was not looking for it before in my STREAMIN, I took the whole queue's contents.  What causes that to be added?

Thanks for the pointers!

Are you using HTTPS? Secure is much slower.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

Bolt

  • Hero Member
  • *****
  • Posts: 598
Re: HTTPCMD Help
« Reply #5 on: August 30, 2019, 01:06:25 PM »
No, just a local HTTP port 80 on an Apache Server.  Much to Google Chrome's disappointment, it's not HTTPS  :P

Bolt

  • Hero Member
  • *****
  • Posts: 598
Re: HTTPCMD Help
« Reply #6 on: August 30, 2019, 01:10:18 PM »

As was mentioned, HTTPCMD is standalone and doesn't require anything else.

HTTPCMD does output status messages to DMLogger when you set $EnableMsgDump(ST36).

Ah, too many choices in the HTTPCMD box. It gave me the option to use existing OPENTCP...

That's what I was forgetting, ST36.  Thanks.  Here's a DMLog:

Code: [Select]
192.168.0.91  Port 29298(0x7272),08/30/19 11:56:37.476 ,"HTTP disconnected!"

192.168.0.91  Port 29298(0x7272),08/30/19 11:56:37.475 ,"Disconnecting HTTP..."

192.168.0.91  Port 29298(0x7272),08/30/19 11:56:37.474 ,"Server connection closed."

192.168.0.91  Port 29298(0x7272),08/30/19 11:56:22.423 ,"Accept-Encoding: identity.."

192.168.0.91  Port 29298(0x7272),08/30/19 11:56:22.423 ,"Host: 192.168.0.10.."

192.168.0.91  Port 29298(0x7272),08/30/19 11:56:22.420 ,"GET /post/lookup.php?c=P-10 HTTP/1.1.."

192.168.0.91  Port 29298(0x7272),08/30/19 11:56:22.420 ,"HTTP connected!"

192.168.0.91  Port 29298(0x7272),08/30/19 11:56:22.419 ,"Connecting to HTTP server..."

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6176
  • Yes Pinky, Do-more will control the world!
Re: HTTPCMD Help
« Reply #7 on: August 30, 2019, 01:16:48 PM »
Looks like one side or the other is waiting for something. After 15 seconds, the server gives up and closes the connection.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

Bolt

  • Hero Member
  • *****
  • Posts: 598
Re: HTTPCMD Help
« Reply #8 on: August 30, 2019, 04:50:22 PM »
Any ideas on what to look for?  As soon as the disconnect happens, the output string is populated with the same contents as before, with an extra <CR><LF>0<CR><LF> added to it.  So it's getting everything it needs, just not acknowledging it or something, and waiting for the 15 second timeout.  In that 15 seconds, I can't even force it to stop with a DEVCLEAR or CLOSE instruction.  I've cleaned up my code allot, but still it goes 15 seconds every time.  I've had to revert back to the old code to keep the speed up, 4 per minute is not adequate.

Andrew S

  • Hero Member
  • *****
  • Posts: 144
Re: HTTPCMD Help
« Reply #9 on: August 30, 2019, 07:08:53 PM »
You might try installing Wireshark to see what's actually coming in over the wire. Is it a new server application? - perhaps the issue is at the server?

Bolt

  • Hero Member
  • *****
  • Posts: 598
Re: HTTPCMD Help
« Reply #10 on: August 30, 2019, 09:10:07 PM »
I have not put wireshark on this network.

I doubt it's a server problem, it's an existing server, that's communicating well with the PLC via existing PING, OPENTCP, STREAMOUT, STREAMIN, CLOSE instructions.  <1/2 second connect, response, close.

Replace it all with HTTPCMD, connection dropped after 15 seconds, but still receives the expected response in that time.

While the connection is open for 15 seconds, I can send another OPENTCP, STREAMOUT, STREAMIN, CLOSE to the same server via another TCP Device on the BRX, and again, get a <1/2 second connect, response, close.

Andrew S

  • Hero Member
  • *****
  • Posts: 144
Re: HTTPCMD Help
« Reply #11 on: August 30, 2019, 09:24:34 PM »
Do you still have the trailing CRLF on your request? You'll want to get rid of that. Could you post the contents of SL3?

Bolt

  • Hero Member
  • *****
  • Posts: 598
Re: HTTPCMD Help
« Reply #12 on: August 30, 2019, 10:53:14 PM »
Code: [Select]
/post/lookup.php?c=P-10

Andrew S

  • Hero Member
  • *****
  • Posts: 144
Re: HTTPCMD Help
« Reply #13 on: August 31, 2019, 12:14:38 PM »
Do you have anything returned in D320?

Bolt

  • Hero Member
  • *****
  • Posts: 598
Re: HTTPCMD Help
« Reply #14 on: August 31, 2019, 02:23:30 PM »
I have 200 as a Response Status Code