Opened on Sep 25, 2014 at 4:07:28 AM
Closed on Jul 25, 2020 at 9:36:34 AM
Last modified on May 25, 2022 at 5:32:09 PM
#2906 closed Bug (Duplicate)
TCPRecv can't detect closed client web browser sockets
| Reported by: | anonymous | Owned by: | |
|---|---|---|---|
| Milestone: | Component: | AutoIt | |
| Version: | 3.3.13.16 | Severity: | None |
| Keywords: | TCPRecv | Cc: |
Description
Last time I checked beta versions error detection was improved but still can't detect a client's web browser closed connection and must rely on other means to close the socket.
This problem has been well documented in a ticket that is now closed, but i'm hoping that somebody will consider re-opening it to solve the last remaining problem.
The last test I ran was on beta version 3.3.13.16 and the issue was still there. Last known working example is version 3.3.8.1.
Attachments (0)
Change History (12)
follow-up: 4 comment:2 by , on Oct 16, 2014 at 4:54:36 AM
This is the example that should show that web page sockets are not being closed when client closed their web browser where 3.3.8.1 had no problems in detecting the closed socket.
Start this script then use your web browser to navigate to 127.0.0.1:81, wait for the connection, then after the established connection, close the browser. 3.3.8.1 will detect the closed browser where further versions fail and must rely on alternate means to close the socket.
Thanks.
TCPStartup()
$serversock = TCPListen('127.0.0.1', 81)
If @error Then Exit ; we know this one.
While 1
Do
$hi = TCPAccept($serversock)
If @error Then Exit ; we know this one.
Until $hi <> -1
MsgBox(0,"Connected","A client has connected...")
$ti = TimerInit()
While 1
TCPRecv($hi,1500)
If @error Then
MsgBox(0,"Closed","Closing the connection: " & @error)
TCPCloseSocket($hi)
ExitLoop
EndIf
#cs ; alternate means for closing inactive sockets
If TimerDiff($ti) > 99 Then
TCPSend($hi, 'data')
If @error Then MsgBox(0,"SEND ERROR!",@error)
$ti = TimerInit()
EndIf
#ce
WEnd
WEnd
comment:3 by , on Oct 16, 2014 at 4:58:30 AM
If the previous script was not any help here is another example. The same principle applies here. Navigate to 127.0.0.1:81, wait for connection then close the browser.
#include <Date.au3>
$socket = -1
TCPStartup()
$srvsck = TCPListen("127.0.0.1",80)
If @error Then Exit
While 1
If $socket = -1 Then
Do
$socket = TCPAccept($srvsck)
If $socket <> -1 Then MsgBox(1,"Test","Connection was made")
Until $socket <> -1
EndIf
$rcvmsg = TCPRecv($socket,1000)
If Not @error And $rcvmsg <> "" Then
$P = "sending data"
$size = StringLen($P)
$cachehtml = ""
$sendwebhdrs = ""
$webstatsval = "HTTP/1.1 200 OK"
$webheadrval = "Cache-Control: " & $cachehtml
$webtrafdate = "Date: " & _NowCalc()
$webcontents = "Content-Type: text/html"
$webbodylens = "Content-Length: " & $size
$webpersisst = "";"Connection: close"
If $webstatsval <> "" Then $sendwebhdrs &= $webstatsval & @CRLF
If $webheadrval <> "" Then $sendwebhdrs &= $webheadrval & @CRLF
If $webtrafdate <> "" Then $sendwebhdrs &= $webtrafdate & @CRLF
If $webcontents <> "" Then $sendwebhdrs &= $webcontents & @CRLF
If $webpersisst <> "" Then $sendwebhdrs &= $webpersisst & @CRLF
If $webbodylens <> "" Then $sendwebhdrs &= $webbodylens & @CRLF
TCPSend($socket,$sendwebhdrs & @CRLF & $P)
MsgBox(1,"goal",$rcvmsg)
ElseIf @error Then
MsgBox(1,"close",$socket & @CRLF & @error)
TCPCloseSocket($socket)
$socket = -1
EndIf
WEnd
comment:4 by , on Oct 16, 2014 at 5:01:28 AM
Sorry this script was likely to showcase the @error problems which have since been fixed, see next example... Sorry about that.
comment:7 by , on Oct 18, 2014 at 8:59:40 AM
Looks like i aslo messed up in this scrip and the port is now 80...
So you would have to navigate your web broswser to 127.0.0.1 istead of 127.0.0.1:81.
Sorry about that.... geeze. i swear i'm not trying to mess up.
comment:8 by , on Aug 25, 2015 at 12:01:25 AM
Same problem with AutoIt v3.3.14.0 and beta3.3.15.0
This really needs to be fixed
Thanks
comment:9 by , on Jun 5, 2016 at 12:19:35 AM
Autit version 3.3.8 proves again to be a more reliable version when it comes to TCP functions. I was working with Autoit v3.3.14.0 for windows 10, when suddenly TCPsend started doing very strange things. It refused to send the entire picture and would always leave 1 bit left unsent. Rendering my server script useless for media content. I did all the common things a person might do to fix the problem and my final solution was to downgrade back to 3.3.8.
Thanks again for all your hard work created and maintaining Autoit3.
comment:10 by , on Jun 7, 2016 at 2:03:23 PM
Can you post a script showing the regresssion between 3.3.14.0 and 3.3.8?
Thanks for your cooperation
comment:11 by , on Jun 30, 2016 at 4:42:41 PM
I will have to write a compressed server that can respond to an html request with pictures on it. I'm not sure if I have the time or desire to complete that task. The server I was using is larger than it needs to be for a useful example. Good luck and I understand if you do not wish to pursue this without proper documentations.
comment:12 by , on Jul 25, 2020 at 9:36:34 AM
| Resolution: | → Duplicate |
|---|---|
| Status: | new → closed |
wait #2596 closing

Can you point/attached repro script which illustrate what you want to be solved?