Jump to content

TCPSend in loop eventually causes "program not responding"


Recommended Posts

6 hours ago, ripdad said:

I have been giving this some more thought.

RTFC in post #8 is absolutely right.

Even if you wind up using v3.3.8.1 as your client, it will eventually run into a buffer overflow.

The problem is with the TCP server.
For whatever reason, it's not accepting data in a timely manner.

Since there's no way around this, some kind of work-around is needed, like a timeout,
so the server can catch up. Something like a 5 second timeout at every 200 sends.
You might have to play around with it a bit.
 

TCPStartup()

Local $iSocket = TCPConnect("127.0.0.1", 500)

Local $iError, $mydata = ''
Local $x = 0

For $a = 1 To 100
    $mydata &= "xxxxxxxxxxxxxxxxxxxx"
Next

For $i = 1 To 300
    TCPSend($iSocket, $mydata)
    $iError = @error
    If $iError Then
        MsgBox(0, "Error", $iError, 5)
        ExitLoop
    ElseIf $i > 200 Then
        $i = 1
        For $j = 1 To 320; <-- pause for 5 seconds
            Sleep(10)
        Next
    EndIf
    $x += 1
    ToolTip($x)
    Sleep(10)
Next

ToolTip('')
TCPCloseSocket($iSocket)
TCPShutDown()



--Edit--

It would be a good idea to check if you have actual data to send rather than sending blanks in the loop. This will reduce the traffic sent to the server, which will definitely help.

I could not duplicate your issue with either versions of AutoIt. I tried all kinds of ways.

I don't know whats going on with that server, but you should not have to put up with this situation. Perhaps if you had a talk with tech support concerning that linux server, you could work something out with them.

It's also possible that some weird thing is going on with your box or connection as well.

For instance, an anti-virus has detected what it thinks is malicious behavior.

 

I'm not sending blanks in the loop.  I'm sending a ton of x characters.  You should see where $mydata is populated with x's at the top.

My samples here are not using that linux server.  I can duplicate this with autoit code, as shown above.

I can duplicate this on every computer I try it on, using your scripts (your autoit client + your autoit server) or my scripts.  All you have to do is either run both of my scripts, or run both of your own scripts after changing 8192 to 100.  Again, slowing down the data will not help.  A 5 second delay will not help.  It will just make it take longer to hang. 

It doesn't matter if there is anything wrong with the server or not, tcpsend should return an error if it needs to.  There probably is nothing wrong with the server.  There are many things that can cause a server or connection to be slow or not respond for a while (congestion, busy doing other things, etc). 

It is not the job of the client to try to work around issues.  So, even if you do work around this one specific issue, you could run into it again in the future under other circumstances.  Just the fact that it is possible for it to happen makes it unacceptable.

Talking to the developer of the server is definitely not a solution.  There are millions of servers out on the Internet, and someone else is bound to run across this issue as well and either report it here, or not report it and just stop using autoit.  So, fixing 1 server to workaround the tcpsend issue only pushes away the incentive to actually fix the real problem inside of tcpsend.

 

Edited by ferbfletcher
Link to comment
Share on other sites

3 hours ago, ferbfletcher said:

I'm not sending blanks in the loop.  I'm sending a ton of x characters.  You should see where $mydata is populated with x's at the top.

In my last post, I was referring to a real world situation, not these test scripts.

 

3 hours ago, ferbfletcher said:

My samples here are not using that linux server.  I can duplicate this with autoit code, as shown above.

I used your original scripts with no modifications, on two different computers. I used v3.3.14 with both AutoIt 32Bit and AutoIt 64Bit. I ran them each to 10,000 cycles and didn't experience your issue with hanging.

 

3 hours ago, ferbfletcher said:

I can duplicate this on every computer I try it on...

What operating system?

 

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Link to comment
Share on other sites

1 minute ago, ripdad said:

In my last post, I was referring to a real world situation, not these test scripts.

 

I used your original scripts with no modifications, on two different computers. I used v3.3.14 with both AutoIt 32Bit and AutoIt 64Bit. I ran them each to 10,000 cycles and didn't experience your issue with hanging.

 

What operating system?

 

They are all Windows 10, 64-bit.  I just tried it, just now, on someone else's computer to make sure again, it hung as well.

Link to comment
Share on other sites

I don't have a Windows 10 machine. Perhaps, someone here on the forum can test and verify the issue.

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...