BITS error codes - windows

I'm writing an application updater that pulls installation package from our distribution web site to the user's PC using the background intelligent download service facility.
More or less everything is working fine now but I'm having a bit of problem getting the application react well to all recoverable errors. Specifically, I'd like the application to handle properly the case of proxy authentication.
In HTTP, it's simple: make a request, get a "407" HTTP response code, prompt for user name/password and repeat until you ether go through or the user press "cancel".
With BITS, it's not that simple. I don't get the HTTP status code. I get a couple of codes: the context (which should be BG_ERROR_CONTEXT_REMOTE_FILE in my case) and an "ErrorCode" that is supposed to depend on the context.
If I request the textual description of the error through GetErrorDescription, I get the correct "407 proxy authentication require" text. But the error code I have is 0x80190197 which is nowhere near 407.
So, does anyone know where I can get a full list of the BITS error code ? Failing that, partial list with the most common errors would be nice.

0x80190197 is not strictly speaking a BITS error, it's an HTTP stack error. The list is available here: Errors (019) FACILITY_HTTP

Related

Chromecast sample sender application CastHelloText-chrome ends with error when trying to get session

I have problem with launching Google-Cast application similar to sample CastHelloText-chrome. I slightly modified example code for my specific purposes. The goal for creating this application is to send and show image data directly in Chromecast device.
Particularly the difference between official sample and my code is in message format and its content, sent by sender application. Sender application took png image coded by base64 and send through message bus with custom namespace. Receiver application get this message and use this as data source for html object <img>.
Error appears when I do this steps:
Reload sender page, checking console if any device found.
Send the form by just pushing enter on input box (text is ignored).
Now a popup from Chromecast extension shows. Next there are two scenarios:
3a) I confirm casting to device by choosing one from the list, then I get this error message in console:
onError: {"code":"channel_error","description":"Error: Timeout","details":null}
3b) I just click somewhere else, I get this error:
onError: {"code":"cancel","description":"User closed popup menu","details":null}
Both of errors are caused by calling function chrome.cast.requestSession in chromehellotext.html at line 161, but what's really wrong I don't know.
When I step sender script I realize that function sessionListener is never called. I know that something go wrong when code try to call chrome.cast.requestSession, where described error raises. So I need help if I missed about right way to use Google-Cast API or If this problem has something to do with networking issues.
Receiver application is registered on Google Cast SDK Developer Console and I'm testing on registered device with some serial number. I'm using Google Chrome in version 42.0.2300.2 canary (64-bit) and Chrome version 40.0.2214.111 (current stable I suppose). For testing I also tried to turn off Windows Firewall entirely but with no luck.
Edit:
There were some syntactic errors that caused error message described above.
It seems like you are trying to use the data/control channel to send an image; please don't do that; that channel is not meant to be used for large data communications; in fact it cannot send anything which approaches or exceeds 64k. If your goal is to send images from your local machine, you would need to run a local web server on your local machine and serve images through the web server.
For and easiest tutorial you can have a look to this tutorial.
It is well explained in this tutorial.
Chromecast Sender application
There is no need to maintain session by yourself.
just add button and enjoy casting
mCastManager.addMediaRouterButton(mediaRoutebtn);
I found a source of my problem. There was something wrong in receiver code - syntactic and runtime errors, so I must admit that my code wasn't functional. Now its working in terms of launching application and getting session.
Unfortunate thing is that the error message generated by Chromecast extension didn't match the actual error - at least it was a bit confusing when I didn't know what's really happening on receiver side without ability to debug the code.

How can I scrape an image that doesn't have an extension?

Sometimes I come across an image that I can't scrape so that it can be saved. An example of this is:
https://s3.amazonaws.com/plumdistrict.com-production/perks/12321/image/original.?1325898487
When I hit the url from Internet Explorer I see the image but when I try to get it from the code below I get the following error message "System.Net.WebException The remote server returned an error: (403) Forbidden" error with GetResponse:
string url = "https://s3.amazonaws.com/plumdistrict.com-production/perks/12321/image/original.?1325898487";
WebRequest request = WebRequest.Create(url);
WebResponse response = request.GetResponse();
Any ideas on how to get this image?
Edit:
I am able to get to save images that do have extensions. For example I can scrape the following image just fine:
https://s3.amazonaws.com/plumdistrict.com-production/perks/12659/image/original.jpg?1326828951
Although HTTP is originally supposed to be stateless, there are a lot of implementations that rely on it being stateless. I could configure my webserver to only accept requests for "http://mydomain.com/sexy_avatar.jpg" if you provide a cookie proving you were logged in. If not, I send you a redirect 303 to "http://mydomain.com/avatar_for_public_use.jpg".
Amazon could be doing the same. Try to load the web page using Chrome, and look at the Network view in developer mode (CTRL+SHIFT+J) to see all headers supplied to the website. Maybe you even need to do a full navigation in the same session before you are allowed to see the image. This is certainly the case in many web applications I have developed :-)
Well, it looks like it's being generated from a script (possibly being retrieved from a database). The server should be sending a file/content type to go along with that... but it doesn't seem to be, which I believe is a violation of standards.
My Linux box knows full well that that's a JPEG image once it's on my hard drive, because it examines file headers rather than relying on extensions. Perhaps there is a tool to do the same in Windows?
Edit: Actually, on further contemplation, it seems odd that you'd get a 403 for that. Perhaps the server is actually blocking you from retrieving the file in that manner.

What other 5xx errors could be occuring and how to I find/track them?

I have a Classic ASP/VBScript site running on IIS 6, and a program called SmarterStats (found via an earlier question) providing various stats and info from the server logs. This is an internal site, and we do use integrated authentication (AUTH_TYPE = Negotiate).
I'm looking at the report on response codes, and it says that in the last 7 days there have been 255 responses with a 5xx error code... naturally not the most useful stat I could get back.
I have a custom error page for 500 and 500.100 errors that logs the specifics for me to follow up on - and that log is virtually empty. I've tested with an intentionally broken page, and a standard user account, and it is working as expected - custom message, log entry made. (and checked with "friendly error messages" on and off - works either way)
The only entry I have in the log is a single entry for an error -2147024843 (authentication related, took too long to get a response), and that's it... what other errors could be happening and how can I find/track them?
Should I route all the different types of 5xx errors through my custom page? Or is there something else I should be doing?
Resolution: I'm going to go with running all 5xx errors through the custom page. For reasons that leave me totally baffled, the errors have stopped... I've not changed anything, no one has changed anything on that server - but the errors have stopped. Go figure.
It seems like logging all 5xx errors via your custom page might be a good idea. Your logging seems to be working, but SmarterStats seems like it might be giving you bogus data?
What version of SmarterStats are you using?
My hosting provider has Version 5.2 and I can see a detailed list of which pages have produced a 5xx error by going to Report Items > Server Responses > 5xx - Server Errors in the navigation tree. The report that gets displayed has a table listing the pages that have produced the error codes so you can then go investigate those pages to see what may be causing the error.
Depending on your site the error might be perfectly normal, for example I have some custom HTTP handlers which implement a standardised HTTP protocol which actually specifies that 5xx errors should be thrown under certain circumstances.
Though this shouldn't apply to an internal only site on public websites it is sometimes the case that badly written crawlers will access your pages in such a way as to produce an error

Team test: Failing load. Request failed: The server committed a protocol violation. Section=ResponseHeader Detail=CR must be followed by LF

The folk in the QA department use visual studio team test (2008 IIRC) to run load tests against our web application.
The latest set of tests have failed on several pages. The error reported is
Request failed: The server committed a protocol violation. Section=ResponseHeader Detail=CR must be followed by LF
Searching for this using google yields quite a few results. it would appear that this error message is generated from the .Net framework WebRequest class (i.e. it is not a visual studio specific message). The most useful result is this one, which details my exact problem and how to suppress the error.
But of course, I want to get to the bottom of why this error occurs in the first place. Here are some more facts: -
This error never used to occur when the tests were run against an older version of the web app. The web app. host OS and web server (Win 2003 and IIS 6) are identical in both cases.
Not all the pages generate this error - only some.
The only significant change to these pages (that I can think of) is that they now use some AJAX whereas before they did not (IIRC)
In order to narrow down the problem, I created the simplest page that I could to replicate the problem. Luckily, that was not too hard. I then inspected the bytes in the header using Fiddler but I could not find an occurrence of a CR (0x0D) that was not followed by a LF (0x0A).
The raw HTTP response (as stored from Fiddler by response saving bytes - so its encoding should not have been altered during the save) is here as text if you don't believe me!
So now I am left thinking that the supposed error might be a false alarm. Does anyone else have experience of this/can help shed light?
This is definitely not a false alarm - I've been getting this error in my app a lot while trying to communicate with Facebook API.
I've just stumbled upon this response from Steven Cheng - http://www.velocityreviews.com/forums/t302174-why-do-i-get-the-server-committed-a-protocol-violation.html - and let me quote him:
From your description, you're using
the HttpWebRequest component to send
some http request to some external web
resource in your ASP.NET web
application. However, you're always
getting the "The server committed a
protocol violation.
Section=ResponseStatusLine" error
unless you set the following section
in the web.config file:
<system.net>
<settings>
<httpWebRequest useUnsafeHeaderParsing="true" />
</settings>
</system.net>
And you're wondering the cause of this behavior, correct?
As for this issue, I've performed some
research on this and found that the
problem is actually caused by the
critical http header
parsing/validating of the
HttpWebRequest component. According to
the Http Specification(http1.1), the
HTTP header keys shoud specifically
not include any spaces in their names.
However, some web servers do not fully
respect standards they're meant to.
Applications running on the Dotnet
framework and making heavy use of http
requests usually use the
httpWebRequest class, which
encapsulates everything a web oriented
developer could dream of. With all the
recently issues related to security,
the "httpWebRequest" class provides a
self protection mechanism preventing
it to accept HTTP answers which not
fully qualify to the specifications.
The common case is having a space in
the "content-length" header key. The
server actually returns a "content
length" key, which, assuming no spaces
are allowed, is considered as an
attack vector (HTTP response split
attack), thus, triggering a "HTTP
protocol violation error" exception.
Will try if this helps right now and post results later

Need to debug recorded jmeter script

I recently recorded a test script in Jmeter intended for use as a load test script (using this handy set of instructions. The recording itself worked great and I even figured out how to grab and parametrize the session ids and timestamps. However, if I run the recorded steps just as they were recorded some of them don't work -- they generate "500--Server encountered and internal error ...nested exception is java.lang.NullPointerException" The failing steps are all Ajax calls that populate sidebar elements. If I copy the request GET call (Request tab, ViewResultsTree) and paste it into a browser I get the exact same error. Do I need to record my script differently, or hand-code the ajax calls? Other, earlier steps work correctly and send the expected POST data, so it isn't the application under test or forgotten proxy settings. Currently running against Firefox 3.6.10
Any suggestions on how I can debug this would be greatly appreciated.
The first thing I'd do is determine if the java.lang.NullPointerException is happening on the client side (JMeter) or on your server. If it is happening in JMeter, than something is terribly wrong with either your script or with JMeter.
But assuming that the error is encountered on your server, then looking into the cause of the exception may shed light on what is wrong with the request issued by JMeter. Do you have access to the code where the exception is thrown?
I would also recommend comparing the request in the recording with the request that generated the error. You may need to determine which parts of the request are session-specific and ensure those fields are populated correctly.
It sounds like Jmeter isn't executing the AJAX calls, and this can be fine depending on your site. Can you simply do an HTTP request to get the pages the AJAX calls populate?
I would recommend reading this post, as it looks pretty good.
I've seen that situation caused by a few things:
a page is required to load and be cached BEFORE making the failing request;
the failing page needs to automatically redirected to work properly;
the failing page has sub-requests JMeter failed to record. Devs can help with this.
Hope this helps.

Resources