Opened 7 years ago
Closed 4 years ago
#3572 closed Bug (Works For Me)
TCPSend can hang forever without returning an error
Reported by: | ferbfletcher | Owned by: | Jpm |
---|---|---|---|
Milestone: | Component: | AutoIt | |
Version: | 3.3.14.2 | Severity: | None |
Keywords: | Cc: |
Description
See this forum post for additional information:
https://www.autoitscript.com/forum/topic/190989-tcpsend-in-loop-eventually-causes-program-not-responding/
When TCPSend is called in a loop, (without closing the socket and opening it each time), TCPSend seems to hang forever after a certain amount of data has been sent. This seems to have no relationship to how fast or slow the data is sent, or how large the data is, other than the fact that if you send the data slower or at a lower amount of data, it will take longer to see the hang.
This was first discovered by sending data to a proprietary non-autoit 3rd-party tcp server, which I have no control over, and which I have no way to see how that server is configured. However, the autoit server code included here causes the same client hang.
Please note that the server code included here is not the code in question, and is only included so that the client will run and hang.
Server Code, make sure this is running before starting the client code. The server code and the client code can be ran on the same PC.
SERVER CODE:
TCPStartup() $iListenSocket = TCPListen("127.0.0.1", 500, 100) Do $iSocket = TCPAccept($iListenSocket) Until $iSocket <> -1 ;if different from -1 a client is connected. while 1 $sReceived = TCPRecv($iSocket,100) sleep(10) WEnd
CLIENT CODE:
TCPStartup() $iSocket = TCPConnect("127.0.0.1", 500) $x = 0 Local $mydata ;This is to make some data for testing purposes For $a = 1 to 100 $mydata &= "xxxxxxxxxxxxxxxxxxxx" Next While 1 $x += 1 TCPSend($iSocket, $mydata) If @error <> 0 Then MsgBox(0,"Error",@error) ToolTip($x) ;this is for a visual indication of program running Sleep(10) WEnd
If it appears that I am sending an unrealistic amount of data at an unrealistic speed, that's true, but it shows the hang faster. If you lower the data size and slow down the sending rate, the hang will still happen after the same amount of data has been sent but you will have to wait much longer for that amount of data to be sent.
The coding method may not be perfect, but the reason I am posting this as a bug is because TCPSend should NEVER hang forever. If there is an issue, it should instead return an error. However, there is no error returned, it just hangs. That makes it appear to be a bug within TCPSend, where some sending issue is not properly being caught. If caught, it could return an error and the program could deal with that error.
Attachments (0)
Change History (4)
comment:1 Changed 7 years ago by fer
comment:2 Changed 7 years ago by ferbfletcher
This seems to be specific to Windows 8 and Windows 10.
comment:3 Changed 7 years ago by Jpm
- Owner set to Jpm
- Status changed from new to assigned
comment:4 Changed 4 years ago by Jpm
- Resolution set to Works For Me
- Status changed from assigned to closed
Hi I think the problem is closed just try the TCPSend/ TCPRecv second example using a big file
Guidelines for posting comments:
- You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
- In-depth discussions should take place on the forum.
For more information see the full version of the ticket guidelines here.
I am currently using version 3.3.14.2 when the hanging happens.
This does NOT happen in 3.3.8.1
Here is what happens in 3.3.8.1: After it reaches that hanging point, it hangs for a few seconds, and then it continues for awhile, and then it hangs for a few seconds, and then it continues for awhile.
So, it seems that 3.3.8.1 is retrying after the server stops accepting data, and then it successfully continues sending when the server is ready again, while 3.3.14.2 simply hangs forever if the server stops accepting data for some reason (buffer full or whatever reason).
It should either return an error, or successfully retry like 3.3.8.1 does. Hanging forever is not good.