Jump to content

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


 Share

Recommended Posts

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
Link to comment
Share on other sites

  • Developers

That doesn't look like it is the whole script and doesn't seem to contain anything wrong.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • Developers
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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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. 

Link to comment
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.

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

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

Link to comment
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).

Link to comment
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.

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

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

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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.

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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
 Share

×
×
  • Create New...