This is a migrated thread and some comments may be shown as answers.

[Solved] When 0 byte file.ContentLength reported randomly when multiple clients are uploading

9 Answers 191 Views
Upload
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Sebastian S
Top achievements
Rank 1
Sebastian S asked on 16 Dec 2011, 04:36 AM
Hi All,

We've been doing some load testing of our application - specifically utilizing the file uploader component, and we're seem some random strange things. When uploading multiple files (~100) on multiple clients (~3 browsers going), the server end sometimes sees files reported with .ContentLength as 0 even though all the test files are non-zero byte files. Works fine when single browser uploads a small number of files (~25). 

Hope someone can offer some insight on what is going on.
Cheers,
Sebastian

.cshtml side code is roughly as below:

@(Html.Telerik().Upload()
		.Name("files")
		.Multiple(true)
		.Async(async => async
			.Save("Save""Job"new { __RequestVerificationToken = "getAntiForgeryToken()" })
			.AutoUpload(true)
		)
		.ClientEvents(events => events
			.OnUpload("onUpload")
			.OnComplete("onUploadComplete")
			.OnSuccess("onUploadSuccess")
			.OnError("onUploadError")
			.OnCancel("onUploadComplete"))
)
<script type="text/javascript">
 function onUpload(e) {
		var files = e.files;
		$.each(files, function () {
			if (this.name === '') {
				e.preventDefault();
				return false;
			}
		});
	}
 
function onUploadComplete(e) {
		$('.t-upload-files').remove();
	}
 
function onUploadError(e) {
		if (e.operation == "upload") {
			var invalidSize = false, size = 0;
			for (var f in e.files) {
				if (f.size != null)
					size += f.size;
				else
					ivalidSize = true;
			}
 
if (!invalidSize) {
				if ((e.XMLHttpRequest.responseText == '')&&(size == 0))
					alert('@SmartResource.CantUploadZeroByteFile');
				else if (e.XMLHttpRequest.status == 200)
					alert(e.XMLHttpRequest.responseText);
				else
					alert(e.XMLHttpRequest.statusText + '(' + e.XMLHttpRequest.status + ') : ' + e.XMLHttpRequest.responseText);
 
				e.preventDefault();
			}
		}
	}
 
function onUploadSuccess(e) {
		if (e.response.Expired)
			location.reload();
		else if (e.response.Status != '')
			alert(e.response.Status);
	}
</script>

9 Answers, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 19 Dec 2011, 09:41 AM
Hello Sebastian,

I assume that you're using some load testing framework. Do you get such errors during normal use? What are the chances that it does not wait for the request to fully complete before navigating away from the page?

Also, do you also see the file size being reported as 0 in the onUpload event? If so, it might be a problem with the browser and the test automation.

By the way, the upload should pick up the anti-forgery token on its own. No need to put it in the Save action parameters.

Greetings,
Tsvetomir Tsonev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Sebastian S
Top achievements
Rank 1
answered on 19 Dec 2011, 09:33 PM
Hi Tsvetomir,

One of the guys here was testing a component on the backend manually via our web interface. What happened was two Chrome browsers were opened, one on the same machine as IIS, the other a remote client. Both browsers upload ~186 test files (1180KB-1KB in size) at the same time. The browsers both upload from the same folder. If we try uploading all 186 files with Firefox, the request does not get to the server.

If we do this with a single Chrome client it seems to work fine. However with multiple clients connected we occasionally get some of the files being reported as 0 byte server side.

I can't say for sure if the request did not time out (session could have expired). My own test with a Chrome browser seems to work ok. I'll try to test this error scenario myself today in the mean-time. 

We don't get it reported on the onUpload event (0 byte).

Anti-forgery stuff - Thanks for the tip!

Cheers,
Sebastian

P.S. Happy holidays!
0
T. Tsonev
Telerik team
answered on 20 Dec 2011, 05:10 PM
Hello,

My guess is that the Upload puts some extra strain on the web server and the network stack. It immediately opens a new connection for each selected file.

We have plans for implementing an upload queue with configurable size for the Q1 '12 release (or earlier). We should be able to keep a check on the number of concurrent connections with this in place.

Happy holidays!

Best Regards,

Tsvetomir Tsonev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Sebastian S
Top achievements
Rank 1
answered on 20 Dec 2011, 09:20 PM
Hi Tsvetomir,

As long as it fixes the problem I'm happy. Still doesn't explain the fact that Firefox isn't happy with the large number of files though.

Cheers,
Sebastian
0
T. Tsonev
Telerik team
answered on 22 Dec 2011, 09:10 AM
Hi,

We are hitting probably hitting a connection limit in Firefox. Limiting the number of concurrent uploads to 4-5 should fix this.

Best Regards,
Tsvetomir Tsonev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Sebastian S
Top achievements
Rank 1
answered on 22 Dec 2011, 09:33 PM
Thanks dude!
0
Sebastian S
Top achievements
Rank 1
answered on 04 Jan 2012, 12:01 AM
Hi Tsvetomir,

Should I log another issue about this? We're still looking at the file upload issues with Firefox. Our (about:config) settings are :

network.http.max-connections;48
network.http.max-connections-per-server;15
network.http.max-persistent-connections-per-proxy;8
network.http.max-persistent-connections-per-server;6
network.websocket.max-connections;200

It seems the number of files we can upload at any one time is arbitrarily limited to a maximum of 67 files (not 4-5) for Firefox. It would be nice to know the reason for this and/or a work around. This does not affect chrome.

Cheers,
Sebastian
0
T. Tsonev
Telerik team
answered on 05 Jan 2012, 09:35 AM
Hello,

I meant to say that the Upload should limit the number of connections internally. This is not yet implemented. I hope we'll be able to get it done soon.

Regards,
Tsvetomir Tsonev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Sebastian S
Top achievements
Rank 1
answered on 05 Jan 2012, 09:16 PM
Ok - thanks.
Tags
Upload
Asked by
Sebastian S
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Sebastian S
Top achievements
Rank 1
Share this question
or