Solved

Strange 20 MB file transfer limit using a web service

Posted on 2006-10-31
3
923 Views
Last Modified: 2012-06-21
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.

<WebMethod()> _

   Public Function getImageByPath(ByVal filePath As String) As [Byte]()

        Dim fs As FileStream

        Try

            ' 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))

            Return abytBuffer

        Catch exp As Exception

            Return Nothing

        Finally

            If Not fs Is Nothing Then

                fs.Close()

            End If

        End Try

    End Function

0
Comment
Question by:denverjaye
3 Comments
 
LVL 11

Expert Comment

by:kmartin7
ID: 17845552
We had a similar issue with an application we created for the military. The problem was they had several reverse proxies that limited the transfer to a pre-specified amount (varied depending on owner). The real problem was there were few people that knew of the problem and it was difficult to find since they all had a different size limitation. We had to re-develop the application so that it sent compressed, 5MB chunks of data that decompressed and recompiled at the receive site. Not exactly the same issue, but maybe it might help shed some light on your issue.
0
 
LVL 1

Expert Comment

by:rajeev1972
ID: 17850910
In place of giving
\\servername\sharename\filename.txt

put

\\ip address\sharename\filename.txt

0
 
LVL 1

Accepted Solution

by:
gderoeck earned 500 total points
ID: 17863916
I ran into an issue in a .NET application a while back where file transfers were getting terminated before the entire transfer was completed.  I was finally able to resolve the issue by using a FileStream, BinaryReader and BinaryWriter to perform the transfer, rather than just using the File.Open method you're using above.  The next step, as mentioned above, would be to buffer the transfer to smaller chunks to make the transfer more manageable.

Microsoft goes into some detail on Streams and how they interface with the Backing Store, whether it be a hard drive, network location, or memory.  You can find that article at:   http://msdn2.microsoft.com/en-us/library/e4y2dch9.aspx 
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question