Ok a problem has arisen today with FineUploader, it was working ok yesterday, and nothing has changed for the file upload part of the code.
The site is running on Windows Server 2008 R2, with IIS7 and all the service packs, and is running in MVC .Net 4.5.
The web.config has the required settings:
httpRuntime targetFramework="4.5" maxRequestLength="2147483647"
and
requestLimits maxAllowedContentLength="2147483647"
to allow large uploads, and it works on a local machine in Visual Studio no problem.
I can also run it on a local machines IIS and it works perfect also. The only problem is when its run from the actual live website. Unfortunately I cannot give out the live site.
When it fails in FF I get 'XHR returned response code 0'
The code for the uploader (excluding the on error/complete etc.. events) is:
manualuploader = $('#uploader').fineUploader({
request: {
endpoint: '/File/UploadFile',
} });
So I do not limit anything of type/size etc... in the code.
As I say it will work 100% of the time for files under about 350kb, anything over and it always freezes at around the 350-400kb mark (based on the percentage it stops at). After a few minutes it goes to the error call of fineuploader with the XHR 0 code.
It works every time ok in Chrome, works sometimes in IE but sometimes freezing at about 1.5MB and gives same error code, and freezes 100% of the time in FF with that error.
Oh and I don't think its a timeout as it takes about 1 or 2 seconds to get the the 400kb even on a slow connection, and then just hangs before crashing. Any ideas?
Request Header:
Accept text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
Accept-Encoding gzip, deflate
Accept-Language en-US,en;q=0.5
Cache-Control no-cache
Connection keep-alive
Content-Length 1861415
Content-Type multipart/form-data; boundary=---------------------------170602977010532
Cookie __RequestVerificationToken=zL6gveyPJ9FY-KvAQq9xHAdrdKTlezzuzwTXfMLETYbXCgFS9XJKRonvJ7vebBK1f9YCueXq8td33cX_10Xx_hfseiaszXq76PGgCKmHE0M1
Host REMOVED
Pragma no-cache
Referer REMOVED
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0
X-Requested-With XMLHttpRequest
[FineUploader] Error when attempting to parse xhr response text (SyntaxError: JSON.parse: unexpected end of data)
Then the POST part is this (excluding the garbage at the end which is presumably just the file data):
-----------------------------170602977010532 Content-Disposition: form-data; name="path" null -----------------------------170602977010532 Content-Disposition: form-data; name="qqpartindex" 0 -----------------------------170602977010532 Content-Disposition: form-data; name="qqpartbyteoffset" 0 -----------------------------170602977010532 Content-Disposition: form-data; name="qqchunksize" 1860320 -----------------------------170602977010532 Content-Disposition: form-data; name="qqtotalparts" 1 -----------------------------170602977010532 Content-Disposition: form-data; name="qqtotalfilesize" 1860320 -----------------------------170602977010532 Content-Disposition: form-data; name="qqfilename" 2013-04-21 19.05.30.jpg -----------------------------170602977010532 Content-Disposition: form-data; name="qquuid" e2732d70-3247-4555-bcbd-399aaa471d58 -----------------------------170602977010532 Content-Disposition: form-data; name="qqfile"; filename="blob" Content-Type: application/octet-stream
Seems pretty clear that this is a server-side issue. Also, you've stated that it worked fine yesterday, so something must have changed in your server-environment. According to the log message, something is likely interfering with the request. You'll need to spend some time looking at your server logs and code and examining any devices between your endpoint and your browser to figure out what is going wrong. Either your endpoint is not properly handling the request or something is interfering with the request before it hits your endpoint code. There's not much help I can offer as I don't know anything about your server environment. You'll need to do some troubleshooting.
Related
I am trying to consume a REST service using TRestClient but I believe there is an issue with the boundary string for multipart content.
I am capturing the body of the request I am sending, and this is the content type header:
Content-Type: multipart/form-data; boundary=-------Embt-Boundary--07CC944C29DA577E
Then, this is the first section of the multipart form:
-----------Embt-Boundary--07CC944C29DA577E
Content-Disposition: form-data; name="file"; filename="ce.csv"
Content-Type: text/csv
And this is how it ends:
---------Embt-Boundary--07CC944C29DA577E--
I don't think this is an issue on the server, as even my proxy is not able to parse the body:
When I compare this same request vs postman, I notice that the starting and ending boundaries do not match!
Starting: -----------Embt-Boundary--07CC944C29DA577E
Ending: ---------Embt-Boundary--07CC944C29DA577E--
I found that the boundary generation is done in TMultipartFormData.GenerateBoundary() from System.Net.Mime:
When checking the starting and ending boundaries from postman, they match, so I am almost sure this is the issue. I don't think it is related to my code, but let me know if you need it.
I encountered a problem with Mediator (9.7 with Fix 11) package, and I would like to know if you have encountered the same thing or if you have some ideas to correct or get around it ?
The problem is : I have a http REST-like request, which is in fact a multipart/form-data page. When I call it by Mediator (virtualized with Centrasite), the multipart payload is transformed in xml format. The endpoint is not able to respond correctly with that format.
Why mediator do this transformation and how can we prevent it ?
In Mediator input, we have this :
Content-Type: multipart/form-data; boundary=---- WebKitFormBoundaryiBMdnONIEM1rPnWp\r\n
------WebKitFormBoundaryiBMdnONIEM1rPnWp
Content-Disposition: form-data; name="typeEnvoi"
99
------WebKitFormBoundaryiBMdnONIEM1rPnWp
Content-Disposition: form-data; name="prenom"
hhhh
------WebKitFormBoundaryiBMdnONIEM1rPnWp
Content-Disposition: form-data; name="fileVisualExam1"; filename="Mezer_Stamp.png"
Content-Type: image/png
?PNG
The endpoint recieve that :
Content-Type: application/xml; charset=UTF-8
<?xml version='1.0' encoding='UTF-8'?><tns:POST_AppMobile
xmlns:tns="http://namespaces.compagny.com/wsdl">
<typeEnvoi>99</typeEnvoi>
<fileVisualExam1>iVBORw0KGgoAAAANSUhEUgAAAF4AAABZCAYAAAC315PWAAAAAXNSR0IArs
4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAARZSURBVHja7NAJAQAwEAIg+5
[...] Wp70lgEAafIxtwjUN/HS1B12VkNYiYm0i9wcjG1+yo+S9ZjauIsIDRm5RobKkeQoQ2fYxx9DUmU5S9Kx
T8QwYfynJcRoSFgt6mVKqxBdehf4bx9B7G0A+Y6r6ra9R1VdvI=</fileVisualExam1>
<prenom>hhhh</prenom></tns:POST_AppMobile>
I have made some attemps by modifying the content-types.xml config file for mediator (adding multipart or binary for that mime), but without success.
Please install the latest Mediator 9.7 Fix (currently fix 18). As of Fix 15, the following issue has been resolved:
SMGME-5868 (Fix 15)
Mediator transforms rest request of type multipart/form-data to XML.
When requests with multipart/form-data are sent to Mediator, Mediator converts
the request to application/xml. This issue is resolved
This should resolve your issue.
Hi we have a Ruby on Rails server application on Heroku, but when I send a post request to it, I always get a 400 Bad Request response. I have searched other 400 errors, but none are related to our issue. The HTTP response that we receive looks like this below:
HTTP/1.1 400 Bad Request
Server: Cowboy
Date: Fri, 14 Aug 2015 21:55:25 GMT
Content-Length: 0
The post request that I am sending looks like this below:
POST http://ourapp.herokuapp.com/api/v1/requests HTTP/1.0
Accept-Language: en-us
Accept: text/plain
Content-Type: application/x-www-form-urlencoded
Content-Length: 38
Connection: Close
request=600&key=&newKey=danasecretkey&
Sorry, I had to put blank lines after each header or it would all show up on one line.
If I create an HTML form to send the data, there is no issue. It's when I then try to send the same request from our file server, that I get the errors. I tried using a preflight request with all of the correct request headings, but received the same 400 Bad Request error.
Does anyone have any suggestions as to what I might be doing wrong?
Well, just guessing from what you've said:
request=600&key=&newKey=danasecretkey&
It's likely that you have something like params.require(:key) in your controller. And your request is missing that parameter.
Rails will respond with 400 status in case you missed some require'd params.
What fixed it was switching from HTTP1.0 to HTTP1.1, adding the host header and changing the uri.
The logs didn't tell us anything, and the params were ok. The problem was not fully grasping the HTTP header requirements.
i'm facing a strange problem with apache benchmark post file.
I need to stress a feature that handles file upload. So, I googled about, and found a post describing how to build a post file properly. Its contents looks like:
--1234567
Content-Disposition: form-data; name="user_id"
3
--1234567
Content-Disposition: form-data; name="file"; filename="cf_login.png"
Content-Type: image/png
[base64 encoded file content]
--1234567--
The ab line is this:
$ ab -c 1 -n 5 -v 4 -T 'multipart/form-data; boundary=1234567' -p post_file.txt http://localhost:3000/files
When ab make the requests the generated header is the following:
INFO: POST header ==
---
POST /files.json/ HTTP/1.0
Content-length: 229
Content-type: multipart/form-data; boundary=simpleboundary
Host: localhost:3000
User-Agent: ApacheBench/2.3
Accept: */*
---
LOG: header received:
HTTP/1.1 500 Internal Server Error
Content-Type: text/html; charset=utf-8
Content-Length: 13265
X-Request-Id: 9ad57d19cd71886a1bb817d00fac651b
X-Runtime: 0.015504
Server: WEBrick/1.3.1 (Ruby/1.9.3/2012-04-20)
Date: Tue, 25 Sep 2012 13:54:29 GMT
Connection: close
The expected return is a raise params.inspect, that let me see if the data is arriving to the other side. If I remove the boundary I can see data received in params, but this is not what I want. I want to get a file upload.
Anyone has a tip? I will really appreciate it.
I found the answer, and decided to share with you.
After some struggle with the post file, I decided to create a php script just to output the $_FILES and $_REQUEST variables to see if the file was built correctly. Indeed, apache receive the file perfectly and I could see the file data, and other request params.
With Rails the same doesn't occur, and after reading the documentation of HTTP 1.1 multipart topic, I realize that the problem was related to the post file format.
When you built this kind of file, you need to build it in details, and this means include all the special characters like \r and \n in the right place. The multipart does now work with "\n" at all, it needs "dos" line ending "\r\n".
So the correct post file looks like this (the \r\n is for illustration, but should be there, you know?):
--boundary_hash\r\n
Content-Disposition: form-data; name="your_form_field";\r\n
Content-Type: text/plain\r\n
\r\n
your form field data\r\n
--boundary_hash\r\n
Content-Disposition: form-data; name="another_field";\r\n
Content-Type: text/plain\r\n
\r\n
another field data\r\n
--boundary_hash\r\n
Content-Disposition: form-data; name="filename"; filename="cf_login.png"\r\n
Content-Type: image/png\r\n
\r\n
base64 file content\r\n
--boundary_hash--\r\n
When you open this file you see this actually:
--boundary_hash
Content-Disposition: form-data; name="your_form_field";
Content-Type: text/plain
your form field data
--boundary_hash
Content-Disposition: form-data; name="another_field";
Content-Type: text/plain
another field data
--boundary_hash
Content-Disposition: form-data; name="filename"; filename="cf_login.png"
Content-Type: image/png
base64 file content
--boundary_hash--
I hope that helps you.
Cheers.
I am using Ajax binding with the Grid and ran into a problem where ASP.NET MVC was throwing a HttpRequestValidationException when I attempted an operation on the grid that invoked the Ajax call (like sorting).
Using Fiddler I was able to determine my browser was attempting to post back my entire model in the query string and there were some characters that would have triggered ASP.NET's request validation.
I was able to work around this by simply adding
[ValidateInput(false)]
to my controller action.
I'm wondering why was the grid sending back so much data? And is this a symptom of a bug in my code or Telerik's?
Here is what I saw in Fiddler (note the extremely long query string, even though the HTTP verb is "POST").
POST http://127.0.0.1:52601/MyController/DatabindGrid?Items=System.Collections.ObjectModel.Collection%601%5BPMyNamespace.Data.ViewEntities.Alert%5D&DetailsClientUrl=&GetJsonUrl=%2FMonitor%2FGetGridJson&ViewName=&CurrentItem=&PageTitle=My%20Web%20Page&CopyrightText=Copyright%20%26%23x00A9%3B%202004-2010%20My%20Company%20Corporation&BrowserCapabilities=&OemName=&UiVersion=20101123 HTTP/1.1
Referer: http://ipv4.fiddler:52601/MyController/MyAction
Content-Type: application/x-www-form-urlencoded
X-Requested-With: XMLHttpRequest
Accept: text/plain, */*; q=0.01
Accept-Language: en-US
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
Host: 127.0.0.1:52601
Content-Length: 56
Connection: Keep-Alive
Pragma: no-cache
Cookie: ASP.NET_SessionId=bvgwuno4bounqio2werepkw4; .ASPXAUTH=612E18BB916F720D13A0F0D1695A86079B94DFE94A3BF5A9A8F19E35A37AE987282B7B684201C112CEC6081181E3D1C52C5517A66D9158E4CF83C1C3F523EE32FF783BD2E3B6E0A42A35E1874E63BA76C7735F9E8ABBA4E58BF61EB29DA03789E07A201A1BA9E7B85F941516ED7EA26E3E8E1E65D0836F39A109201E357EE97478D1A359B3FB4B4AD4C64A02A0CE7BBB39DC8FE1F73B179F284A14CF55D9C67D
page=1&size=10&orderBy=LocationName-asc&groupBy=&filter=
Rick,
I think you might be interested in this...
http://tv.telerik.com/watch/aspnet-mvc/video/building-a-responsive-site-with-mvc
very detailed and informative.
~AZee