Getresponse Protocol Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this webexception status protocolerror site About Us Learn more about Stack Overflow the company Business Learn webexception protocol error more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question system.net.webexceptionstatus.protocolerror 500 x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up HTTPWebRequest.GetResponse() protocol error 7 failing with authenticated requests through a transparent proxy up vote 13 down vote favorite 1 We're using the HTTPWebRequest objects to make HTTP requests to our application and we're having a problem when the request requires authentication and there is a transparent proxy (Squid 3.1.10). string url = "http://www.icode.co.uk/test/auth.php"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Credentials = new NetworkCredential("username", "password"); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream stream
Protocol Error C#
= response.GetResponseStream(); StreamReader reader = new StreamReader(stream); MessageBox.Show(reader.ReadToEnd()); reader.Close(); stream.Close(); response.Close(); Our original code used the WebClient class which exhibited the same problem. The first time this code runs, it displays the result correctly. When the code runs a second time, it fails on the GetResponse() line with: System.Net.WebException was unhandled Message="The server committed a protocol violation. Section=ResponseStatusLine" Source="System" StackTrace: at System.Net.HttpWebRequest.GetResponse() at Dummy.DummyForm.button1_Click(Object sender, EventArgs e) in H:\Trial\Dummy\DummyForm.cs:line 42 at ... On Windows 7, restarting the process causes it to recover and work once, but Server 2003 requires a full reboot. Looking at the network capture, two requests are identical to start with, the initial unauthenticated request is sent and the server replies, but the failing requests sends the 2nd authenticated request in the middle of the initial reply as if it's ignoring the Content-Length header (which is correct). It then receives the rest of the initial reply and fails with the protocol error. It does seem odd that the client (HTTPWebRequest) doesn't close the connection cleanly though. When the proxy is not in use (non port 80 or internal traffic) the requests all work as expected. When
resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel 9 Documentation APIs and
Httpwebrequest Getresponse
reference Dev centers Retired content Samples We’re sorry. The content you requested httpwebrequest getresponse timeout has been removed. You’ll be auto redirected in 1 second. System.Net HttpWebRequest Class HttpWebRequest Methods HttpWebRequest Methods GetResponse "a webexception with status protocolerror was thrown" Method GetResponse Method GetResponse Method Abort Method AddRange Method BeginGetRequestStream Method BeginGetResponse Method EndGetRequestStream Method EndGetResponse Method GetObjectData Method GetRequestStream Method GetResponse Method MemberwiseClone Method ISerializable.GetObjectData Method TOC Collapse the table http://stackoverflow.com/questions/10984264/httpwebrequest-getresponse-failing-with-authenticated-requests-through-a-trans of content Expand the table of content This documentation is archived and is not being maintained. This documentation is archived and is not being maintained. HttpWebRequest.GetResponse Method () .NET Framework (current version) Other Versions Visual Studio 2010 .NET Framework 4 Visual Studio 2008 .NET Framework 3.5 .NET Framework 3.0 .NET Framework 2.0 .NET Framework 1.1 Returns a response from an Internet https://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.getresponse(v=vs.110).aspx resource.Namespace: System.NetAssembly: System (in System.dll)Syntax C#C++F#VB Copy public override WebResponse GetResponse() Return Value Type: System.Net.WebResponseA WebResponse that contains the response from the Internet resource.Exceptions Exception Condition InvalidOperationExceptionThe stream is already in use by a previous call to BeginGetResponse.-or- TransferEncoding is set to a value and SendChunked is false. ProtocolViolationExceptionMethod is GET or HEAD, and either ContentLength is greater or equal to zero or SendChunked is true.-or- KeepAlive is true, AllowWriteStreamBuffering is false, ContentLength is -1, SendChunked is false, and Method is POST or PUT. -or- The HttpWebRequest has an entity body but the GetResponse method is called without calling the GetRequestStream method. -or- The ContentLength is greater than zero, but the application does not write all of the promised data.NotSupportedExceptionThe request cache validator indicated that the response for this request can be served from the cache; however, this request includes data to be sent to the server. Requests that send data must not use the cache. This exception can occur if you are using a custom cache validator that is incorrectly implemented. WebExceptionAbort was previously called.-or- The time-out period
Started Documentation Release Overview Trailhead Books & Cheat Sheets On-Demand Webinars Certification Blogs Tools Force.com IDE Lightning Design System Source Code Scanner https://developer.salesforce.com/forums/?id=906F00000008lRaIAI More Tools & Toolkits By Topic App Distribution App Logic Architect Database Lightning Mobile Integration Security User Interface Websites Community Developer Forums Events Calendar Developer MVPs Developer Groups Developer Success Stories Blogs Blog All Blogs Developer Relations Engineering Force.com Labs Tech Docs Trailhead Trailhead - Trails - Modules - Projects Get Help Join the Community Login with Salesforce Don't have an account? Signup for a Developer Edition Browse protocol error by Topic Apex Code Development (56245) General Development (42698) Visualforce Development (29069) Formulas & Validation Rules Discussion (6952) APIs and Integration (6635) Jobs Board (6103) Other Salesforce Applications (5574) Force.com Sites & Site.com (3605) Java Development (3505) .NET Development (3333) Mobile (1760) Lightning (1557) Trailhead (3308) Perl, PHP, Python & Ruby Development (1896) AppExchange Directory & Packaging (1808) Mobile (1760) Security (1732) Lightning (1557) Chatter and Chatter API Development (1437) getresponse protocol error Visual Workflow (1096) Salesforce Labs & Open Source Projects (1010) Desktop Integration (970) Apple, Mac and OS X (709) VB and Office Development (613) Schema Development (604) Architecture (429) Salesforce Summer of Hacks (132) Salesforce $1 Million Hackathon (128) Predictive Services (5) View More Topics See All Posts Welcome to Support! Search for an answer or ask a question of the zone or Customer Support. Need help? Dismiss ShowAll Questionssorted byDate Posted ShowAll QuestionsUnanswered QuestionsUnsolved QuestionsSolved Questions sorted byDate PostedRecent ActivityMost Popular + Start a Discussion You need to sign in to do that Sign in to start a discussion Don't have an account? Signup for a Developer Edition Solved QuestionsThis Question opiedogReceiving intermittent protocol error and "(500) internal server error"I have an implementation for a client that works most of the time. When it doesn't work, I'm receiving a WebException.Status of ProtocolError with an HttpWebResponse.StatusCode of InternalServerError. Could you provide some guidance about what might cause this? I log the SOQL query strings and they can be run successfully so I assume it's in the way I'm constructing the HTTP headers. Thanks!August 19, 2010 · Like0 · Follow0 Best Answer chosen by Admin(Salesforce Developers)SuperfellAPI sessions expire on inactivity, if there's a long enough gap between your api requests the