When we manually downloaded these "bad" files from a web browser, the
files download in totality.
However, using the Winsock control (which has been very good to us
over the years), the Close event is fired before the last chunks of
data are downloaded, and thus the written file is incomplete.
As you can see in the examples below, we use the DataArrival method
(and bytestotal property) to track the % downloaded (for a progress
bar). Typically, one would expect a multitude of DataArrival triggers
for each chunk of data, followed by the close method. In the second
example, what we see is the close method trigger for storage/
processing and then the last pieces of data is being received AFTER
the fact (as noted by additional data arrival methods).
Any ideas as to why this is happening (and so sporadically)?
As a workaround I tried setting a loop in the Winsock Close event,
waiting for the remaining data, but it fails because the remaining
DataArrival events aren't fired until the Closed event is exited.
(inside wscHTTP_Close)
'Wait for download to complete or time out in 10 seconds
If bytesdownloaded <> bytesexpected then
Do Until bytesdownloaded = bytesexpected or (Timer - tmr) > 10
DoEvents
Loop
End If
Stumped!
Evan
Typical Good Data:
[snipped]
HTTP DataArrival Trigger - Downloading .\kcys\Level2\201006080238.kcys
( 660303 of 736307 bytes )
HTTP DataArrival Trigger - Downloading .\kcys\Level2\201006080238.kcys
( 668495 of 736307 bytes )
HTTP DataArrival Trigger - Downloading .\kcys\Level2\201006080238.kcys
( 676687 of 736307 bytes )
HTTP DataArrival Trigger - Downloading .\kcys\Level2\201006080238.kcys
( 684879 of 736307 bytes )
HTTP DataArrival Trigger - Downloading .\kcys\Level2\201006080238.kcys
( 693071 of 736307 bytes )
HTTP DataArrival Trigger - Downloading .\kcys\Level2\201006080238.kcys
( 701263 of 736307 bytes )
HTTP DataArrival Trigger - Downloading .\kcys\Level2\201006080238.kcys
( 709455 of 736307 bytes )
HTTP DataArrival Trigger - Downloading .\kcys\Level2\201006080238.kcys
( 717647 of 736307 bytes )
HTTP DataArrival Trigger - Downloading .\kcys\Level2\201006080238.kcys
( 725839 of 736307 bytes )
HTTP DataArrival Trigger - Downloading .\kcys\Level2\201006080238.kcys
( 734031 of 736307 bytes )
HTTP DataArrival Trigger - Downloading .\kcys\Level2\201006080238.kcys
( 736307 of 736307 bytes )
HTTP DataArrival Trigger - Downloading .\kcys\Level2\201006080238.kcys
( 736307 of 736307 bytes )
HTTP Close Trigger - WRITE AND PROCESS FILE 201006080238.kcys
PROCESSING SUCCESSFUL
Bad Data:
[snipped]
HTTP DataArrival Trigger - Downloading .\kcys\Level2\201006080024.kcys
( 3092001 of 3143474 bytes )
HTTP DataArrival Trigger - Downloading .\kcys\Level2\201006080024.kcys
( 3095473 of 3143474 bytes )
HTTP DataArrival Trigger - Downloading .\kcys\Level2\201006080024.kcys
( 3109361 of 3143474 bytes )
HTTP DataArrival Trigger - Downloading .\kcys\Level2\201006080024.kcys
( 3112833 of 3143474 bytes )
HTTP DataArrival Trigger - Downloading .\kcys\Level2\201006080024.kcys
( 3112833 of 3143474 bytes )
HTTP DataArrival Trigger - Downloading .\kcys\Level2\201006080024.kcys
( 3112833 of 3143474 bytes )
HTTP DataArrival Trigger - Downloading .\kcys\Level2\201006080024.kcys
( 3116305 of 3143474 bytes )
HTTP DataArrival Trigger - Downloading .\kcys\Level2\201006080024.kcys
( 3119777 of 3143474 bytes )
HTTP DataArrival Trigger - Downloading .\kcys\Level2\201006080024.kcys
( 3123249 of 3143474 bytes )
HTTP DataArrival Trigger - Downloading .\kcys\Level2\201006080024.kcys
( 3126721 of 3143474 bytes )
HTTP Close Trigger - WRITE AND PROCESS FILE 201006080024.kcys
**PROCESSING FAILED**
HTTP DataArrival Trigger - Downloading .\kcys\Level2\201006080024.kcys
( 3143474 of 3143474 bytes )
HTTP DataArrival Trigger - Downloading .\kcys\Level2\201006080024.kcys
( 3143474 of 3143474 bytes )
HTTP DataArrival Trigger - Downloading .\kcys\Level2\201006080024.kcys
( 3143474 of 3143474 bytes )
HTTP DataArrival Trigger - Downloading .\kcys\Level2\201006080024.kcys
( 3143474 of 3143474 bytes )
The Winsock control sucks. There are much better alterantive for
downloading information like this, specifically the wininet API.