Strange 20 MB file transfer limit using a web service
Posted on 2006-10-31
We have created a web service that transfers files over http. It does this by reading the file and returning the file object via a soap message. This web service is installed on a windows 2003 server running IIS 6.0. The web service works well with smaller file sizes but as soon as you attempt to transfer a file larger than 20 MB, it downloads the first 20 MB and then stops with no errors. The web service learns the path to the file via a third party SQL database and then accesses the files via a windows file share, for example - \\servername\sharename\filename.txt. This web service is working without these issues in our staging and development environments. This only happens in production.
Now for some of the strangeness. First, we tried installing the web service on a windows XP Pro computer and it works fine with files larger than 20 MB. We then tried changing the path in the SQL database to use the local drive letter instead of a file share, for example - F:\folder\filename.txt. That seems to have solved the issue in production but we are not able to make that change permanently to the paths due to the third party app that uses them. This is making us think that the issue is in the method of transfer somehow but we are at a loss as to why.
Here is the code in the web service.
Public Function getImageByPath(ByVal filePath As String) As [Byte]()
Dim fs As FileStream
' Read file and return contents
fs = File.Open(filePath, FileMode.Open, FileAccess.Read)
Dim lngLen As Long = fs.Length
Dim abytBuffer(CInt(lngLen - 1)) As Byte
fs.Read(abytBuffer, 0, CInt(lngLen))
Catch exp As Exception
If Not fs Is Nothing Then