mitchelwb

why is my TCP Send creating 1000's of requests?

13 posts in this topic

#1 ·  Posted (edited)

I'm having issues getting a TCPSend/TCPRecv to work.  I'm creating the socket ok, but when I send my XML request over the first time, I get a response that it was invalid.  Subsequent requests after that, I get no response from the server at all. I spoke to the sysAdmin for the server and he said that it locked out my port because it received 1000's of requests.  But there are no loops in my code and the total time to process the script was 0.94 seconds.  Any ideas?

createTCP()

Func createTCP()

    TCPStartup() ; Start the TCP service.

    ; Register OnAutoItExit to be called when the script is closed.
    OnAutoItExitRegister("OnAutoItExit")

    Opt("TCPTimeout", 10000)

    Local $sIPAddress = TCPNameToIP("the.server.com")
    $iPort = 60008 ; this port is assigned to this app

    Local $iSocket = TCPConnect($sIPAddress, $iPort)
    if @error Then
        Exit
    EndIf

    ;get xml request contents
    $XMLData = GetXMLReq("mydata", "mydata", "mydata", "mydata")

    ;send xml request
    TCPSend($iSocket,$XMLData)

    $Response = TCPRecv($iSocket, 1024)

EndFunc


Func OnAutoItExit()
    TCPShutdown() ; Close the TCP service.
    logit("TCP Shutdown")
EndFunc   ;==>OnAutoItExit

 

 

 

Edited by mitchelwb

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Agreed.  It may be something intrinsic on the server-side; I certainly don't see anything in the snippet you posted that would cause the thousands of requests your sysAdmin "saw".

Edited by spudw2k

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

You guys caught me... it's not the whole script.  I removed the getXMLReq function because it contained some lightly sensitive information.  But it is a function that literally takes a few parameters and inserts them in to a simple XML string.  I also cleaned up my consoleWrite statements to make the script more compact for the site.  But otherwise, this is it.

Edited by mitchelwb

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

8 minutes ago, mitchelwb said:

But otherwise, this is it.

Nah ... there is also a logit() function there, but guess that is for logging the process steps. ;)

Either way, this script shouldn't trigger the many packets as state unless the $XMLData contains a real big ass string. 

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
9 minutes ago, Jos said:

Nah ... there is also a logit() function there, but guess that is for logging the process steps. ;)

Either way, this script shouldn't trigger the many packets as state unless the $XMLData contains a real big ass string. 

Jos

Doh!  I thought I stripped those all out!  In the interest of completeness, here's is the logit function.  I hate concatting name/val pairs for consolewrite

Func logIt($desc = "", $val = "")
    ConsoleWrite(@crlf & $desc & ": " & @crlf & $val & @crlf)
EndFunc

And the request is pretty simple.  A header, a <Request> tag that contains 4 child tags that provide an account number, bill information, and the name of the report I'm requesting.  It's not even 200 characters.

The resulting XML report i expect to get back is MUCH larger, and I know I'm not looping to capture it all, but just to test the process and get it to work so I can implement it in to the larger project, I just wanted to grab enough to verify I was getting the report. 

Share this post


Link to post
Share on other sites

from the Help about the OPT() command:
TCPTimeout: Defines the time before TCP functions stop if no communication.
            Time in milliseconds before timeout (default=100).

I think that the value 10000 for the TCPTimeout that you are using is a bit high (default is 100)
this should mean that your fuction insists on calling for 10 seconds (!) before giving up.
Pheraps this cause a lot of requests against the server.


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites
6 hours ago, Chimp said:

from the Help about the OPT() command:
TCPTimeout: Defines the time before TCP functions stop if no communication.
            Time in milliseconds before timeout (default=100).

I think that the value 10000 for the TCPTimeout that you are using is a bit high (default is 100)
this should mean that your fuction insists on calling for 10 seconds (!) before giving up.
Pheraps this cause a lot of requests against the server.

This timeout sets how long my script runs.. if it doesn't receive a response in those 10 seconds the script exits.  And that makes sense in terms of listening and receiving... but are you saying you think it is sending the request file repeatedly in those 10 seconds?  I'm not real familiar with sockets, but it seems that sending it repeatedly like that would be a lot like a DDOS (minus the distributed part).

Share this post


Link to post
Share on other sites

my was just wild guess...
I thought that while waiting for the timeout, TCP can make more connection attempts.
By better reading around ( https://technet.microsoft.com/en-us/library/cc739819%28WS.10%29.aspx --> TcpMaxConnectRetransmissions) seems that the TCP parameter that determines how many retransmission attempt are performed on an initial TcpConnect is the TcpInitialRtt registry value. So maybe my thought is wrong... sorry.


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites
7 minutes ago, Chimp said:

So maybe my thought is wrong... sorry.

No need to apologize.  I'm appreciative of any conversation that helps to narrow it down.

Share this post


Link to post
Share on other sites

You could use a tool like Wireshark to check what exactly goes on.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
1 hour ago, water said:

You could use a tool like Wireshark to check what exactly goes on.

I would if I could... I'm using a Linux machine to connect to one VPN, then a windows VM to connect to another VPN... I've not tried it, but some of the guys on my team said that it blows Wiresharks mind.

Share this post


Link to post
Share on other sites

Can your admins tell you which kind of packets they get (session open, retransmit etc.)?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • mitchelwb
      By mitchelwb
      This is a followup question to my previous thread about TCP requests, but since it's a different question, I wanted to start a new thread.
      I spoke to the sysAdmin today, and they also looked over my code. What they pointed out was that I was missing a few values that I'm going to call "environment variables" but I'm not really sure exactly what they are.  I've not been able to find any kind of option or indication in the AutoIt documentation that fits the bill, so I'll ask here.
      They are telling me that the request needs to include a ClientId = 4 and an AppType = 2.  These are values that they sent to me when they sent me the IP and the port, so I was aware of them, but maybe got off course on a wild goose chase with the 1000's of requests hitting their server.  I've asked the server admins if they can send me a block of example code that shows these variables being used in any language (I assume they'll send me java) so that I might get some clues on how they fit in, but in the mean time, I'm still lost.
      I've searched a lot but so far, I've been unable to find any kind of example in any language that utilizes these types of "environment variables" in making a TCP or UDP request.  What am I missing?