1

I need to stream huge files (1GB) up to ServiceStack webservice which will be hosted on Nginx+FastCGI in Debian.

I am using IRequiresRequestStream DTO to support streaming.

I upload data from client with HttpWebRequest:

req.AllowWriteStreamBuffering = true;
req.SendChunked = true;
req.ContentType = "multipart/form-data;

All is good when deployed in IIS.

However, when the WS is hosted on NGinx+FastCGI, ServiceStack receives malformed (chunked) data, as described also here: Binary data corrupted when hosting ServiceStack in Mono + FastCGI which refers to this bug: https://bugzilla.xamarin.com/show_bug.cgi?id=10001

The pull request which provides a workaround (https://github.com/mono/mono/pull/752) is apparently merged in master branch of Mono, but despite this, I am still seeing the issue. I assume it has not been deployed in production version of Mono yet. If I understand the pull request correctly, it provides only a workaround and does not allow streaming.

The only workaround that works for me so far is to specify this:

req.ProtocolVersion = new Version("1.0");

and not send the data as streamed, but rather buffer it all before sending to the WS. This is not a viable option for huge files.

I tried setting this in nginx.conf but it does not change the behavior:

chunked_transfer_encoding on;
proxy_http_version 1.1;

Are there any other options how to stream huge files to ServiceStack webservice? Does XSP support chunked encoding? Does mod_mono on Apache support it? How about self-hosted console app? This needs to be stable enough for a big internet-facing application.

Community
  • 1
  • 1
Marek
  • 10,307
  • 8
  • 70
  • 106
  • What are the mono and xsp versions on the server? – miniBill Nov 21 '13 at 06:08
  • I have the latest versions installed via apt-get. I have not installed XSP. I am not sure how to find out mono version. Going to /usr/lib/mono lists 2.0 3.5 and 4.0 folders – Marek Nov 21 '13 at 08:24
  • not sure if this helps: mono -V returns Mono JIT compiler version 2.10.8.1 (Debian 2.10.8.1-8) – Marek Nov 21 '13 at 08:26
  • That version is ancient... could you try with a mono >= 3.0? – miniBill Nov 21 '13 at 16:40
  • mono 3.x (I do not remember now which it was) was even worse. It was failing to compile any views (razor and asp.net) http://stackoverflow.com/questions/20118595/httpcompileexception-external-exception-when-trying-to-access-razor-view-in-s This mono+apache/nginx experience has been a nightmare – Marek Nov 21 '13 at 21:23
  • I'm sorry but I don't know how to help you further. The only suggestion I have is: mono is open source, go and look at the code – miniBill Nov 22 '13 at 08:14
  • I (kind of) know why this does not work on nginx based on issues in mono. The question is how to upload big files to servicestack on linux, using any webserver. – Marek Nov 25 '13 at 09:54

0 Answers0