.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Kaviya Balasubramanian
Sgraph Infotech
Imran Ghani
Post New Web Links

System.Net.WebException: The underlying connection was closed: The server committed a protocol viola

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :WPF
 
I need to send files using FTP with SSL enabled.  Unfortunately a "protocol violation" WebException is thrown whenever GetRequestStream is execute.  Please see a sample program below.

I've reviewed the post "Unable to use FTPWebRequest over SSL" but do not find a solution there.

I can use WinSCP to the same FTP site without problem so I'm working on the assumption that I my .NET logic is incorrect.

Any help appreciated.

// .NET 2.0
using System;
using System.Collections.Generic;
using System.Text;

using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Security.Policy;
using System.Net.Security;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            System.Diagnostics.TextWriterTraceListener listener = new System.Diagnostics.TextWriterTraceListener(@"C:\Documents and Settings\jhotchk\Desktop\NetworkTrace.Log");
            System.Diagnostics.Trace.Listeners.Add(listener);
  &n


View Complete Post


More Related Resource Links

System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a rec

  
Hello Guys,         I am getting following exception while web service (ASMX) is returning the response. <!-- [if gte mso 10]> <mce:style> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive.     <!-- [if gte mso 10]> <mce:style>                                                     InnterException (System.IO.Exception): "Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host."       I think either the Asp.net web server is closing the connection or the response is too long.   Following is my simple code.    1)   namespace JFA.IndiePay.BusinessAccess { public class VerTexProcessor { public DataSet ProcessVerTexForBatch(DataSet dsInputRequest) { DataSet dsResponse = new DataSet(); //Call vertex web service here. VertexService.Service texCalculator = new VertexService.Service(); texCalculator.Timeout = 500000;

System.Net.WebException Message=The underlying connection was closed: The connection was clos

  

Hi,

I have a work flow developed in vs2010 WF4 exposed as service. I am consuming this service in a test web application, whenever service returns i get the following exception:

System.Net.WebException       Message=The underlying connection was closed: The connection was closed unexpectedly.

If i return a string it works fine, whenever i deserialize my result into an object and return that object i get the above mentioned error.

 

Regards,

Hassam


System.Net.WebException Message=The underlying connection was closed: The connection was clos

  

Hi,

I have a work flow developed in vs2010 WF4 exposed as service. I am consuming this service in a test web application, whenever service returns i get the following exception:

System.Net.WebException       Message=The underlying connection was closed: The connection was closed unexpectedly.

If i return a string it works fine, whenever i deserialize my result into an object and return that object i get the above mentioned error.

 

Regards,

Hassam


...The underlying connection was closed: The connection was closed unexpectedly. at System.Net.Web

  

I have a WCF service with the following lines of code:

WebClient Client = new WebClient();

Stream strm = Client.OpenRead(fPath); < -- Exception Occurs exactly here

Everything works great when I am hosting the service via the ASP.NET Development server, but when I publish the service to IIS, the following runtime error is thrown:

The underlying connection was closed: The connection was closed unexpectedly.\r\n   at System.Net.WebClient.OpenRead(Uri address)

As stated, the program opens the file without any problems when the service is hosted in the ASP.NET development server.  When hosted in IIS, an exception is thrown at the location specified above.  I thought that it might be an issue of security, so I went berserk in permission granting.  I sort of ruled that out at this point as every group has full access and the exception is still being thrown.

Any assistance on this would be greatly appreciated...


The underlying connection was closed: Unable to connect to the remote server.

  

Hello,

 

I get this error message when i kick off my web service to run. It gathers survey feedback from a database via http soap. Recently i put in a proxy that is required for access to internet. The web service started to fail that day as well. Can anyone tell me how i could hard code the proxy that should be used by the web service? I found this link: http://support.microsoft.com/kb/307220

and tried editing the machine.config file but that didn't fix my issue. Any Ideas?

 

Error:

 

8/2/2007 1:02:25 PM
The underlying connection was closed: Unable to connect to the remote server.
   at System.Net.HttpWebRequest.CheckFinalStatus()
   at Syst

The underlying connection was closed: An unexpected error occurred on a send.

  

I am consuming a third party web service wsdl using my .net aps.net page. And I am getting following error message. Cannt get to resolve it. Its working on my machine but not in my development machine. I have installed the certificate also in certificates on that machine. Can somone please help.?

Error -->  The underlying connection was closed: An unexpected error occurred on a send.

 

 

 

 


A connection that was expected to be kept alive was closed by the server.

  

When  i want to Call http://BDCRWSS/_vti_bin/BdcAdminService.svc Bdc AdminService in SharePoint Foundation  2010

the binding i use:

    <binding name="BasicHttpBinding_BusinessDataCatalogSharedService"
      closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00"
      sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false"
      hostNameComparisonMode="StrongWildcard" maxBufferSize="999999"
      maxBufferPoolSize="9999999" maxReceivedMessageSize="999999"
      messageEncoding="Mtom" textEncoding="utf-8" transferMode="Buffered"
      useDefaultWebProxy="true">
     <readerQuotas maxDepth="99" maxStringContentLength="999999" maxArrayLength="999999"
       maxBytesPerRead="999999" maxNameTableCharCount="999999" />
     <security mode="TransportCredentialOnly">
      <transport clientCredentialType="Ntlm" proxyCredentialType="None"
        realm="">
       <extendedProtectionPolicy policyEnforcement="Never" />
      </transport>
      <message clientCredentialType="Use

The underlying connection was closed: An unexpected error occurred on a receive

  
Hi All,   i have developed a web application to call WCF service (which is hosted in IIS) from client application using .Net 1.1 it works fine.   but i got an error "The underlying connection was closed: An unexpected error occurred on a receive." when the return object is getting complex.   i analysis the issue with different level of object complexity and i found it get failed for following structure.   eg:   ObjectA - outer object that has some primitive data types and the list of ObjectB ObjectB - this also contain some primitive data and list of ObjectC.   Hope you can understand the hierarchy (complexity) of the return object. This works up to 2nd level of object hierarchy.   Does anyone have idea about the solution for this exception?   Thanks in Advance Shazvi

Exception: "The underlying connection was closed: The connection was closed unexpectedly." (sometime

  
I have a windows app connecting to a webservice.  In some situation(s) (haven't narrowed it down enough), I get the following exception: The underlying connection was closed: The connection was closed unexpectedly. When this exception is thrown, it is calling a method of a web reference. Now the situation that we experience this is on a laptop in the field that is using a WWAN connection in at least one location.  It works fine in the lab at the office.  Anyone have any ideas what could be causing this?

SSRS 2008 - report manager: System.Net.WebException: Unable to connect to the remote server

  
I have an instance of Reporting Services 2008 running on Windows 2003 server.  So, the webservice URL is running on port 801, and runs fine (I can browse reports from that directory, and upload / deploy new reports and overwrite existing reports. Report manager is set to use port 800 (IIS is also on that machine running port 80).  When I attempt to connect to report manager, I get the following error, with a link to "Home" in report manager (which brings me back to the existing error page):    Unable to connect to the remote server  In the logfiles for reporting services, the following error is there: " System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it.   Any ideas? Windows Firewall is NOT running on this machine.   Thanks, Chrisrjp

"The underlying connection was closed: The connection was closed unexpectedly."

  
HI, I am getting error as "The underlying connection was closed: The connection was closed unexpectedly." The problem occured when data is heavy. i have set to maxBufferpool size and MAxBoolsize also high. Stack Trace of the Error: Server stack trace:    at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)    at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)    at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)    at System.ServiceModel.Channels.ClientReliableChannelBinder`1.RequestClientReliableChannelBinder`1.OnRequest(TRequestChannel channel, Message message, TimeSpan timeout, MaskingMode maskingMode)    at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout, MaskingMode maskingMode)    at System.ServiceModel.Channels.ClientReliableChannelBinder`1.Request(Message message, TimeSpan timeout)    at System.ServiceModel.Security.SecuritySessionClientSettings`1.SecurityRequestSessionChannel.Request(Message message, TimeSpan timeout)    at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan tim

The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure

  

I've gone through lot of articles and not one solution worked for me:

I'm having IIS 7 on Windows 2k8 with SSRS 2008.

How SSL is configured: Its configured to access SSL over existing web-site. final url looks like https://url/reports. When I enter this URL I get the error message.

But, if I connect to same site using non SSL website from my local machine, it works fine. For example, if i use VS 2008 web server and connect to it, it works and shows me report, but as soon as I deploy it on webserver having SSL enabled, it just throws this message.

 

Somebody please help me wid this one


Not so important

System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketExcept

  

I have a scenario where there is a web service (WS2) which resides behind WSLX authentication. There is another web service (WS1) which is outside of this WSLX authentication. Now we have blackberry application which calls WS1 & send its login credentials which gets passed to WS2 & token is returned back to the blackberry app. For subsequent request the same token is passed in order to ensure that it is the same session. I have seen the similar error as mentioned below earlier in the log but now after migration to SQL 2005 from SQL 2000 this has become more frequent. The error is:

 

System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond     at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)     at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)     at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)    

"The server committed a protocol violation. Section=ResponseStatusLine"

  

i am getting "The server committed a protocol violation. Section=ResponseStatusLine"

error whan calling webservice form my windows application

 

thanks


Windows WCF client with internet proxy server showing error The server committed a protocol violatio

  

Our team trying to create a windows application(c#) to call a WCF service using internet proxy server

Showing exception "The server committed a protocol violation. Section=ResponseStatusLine" while calling WCF service

Please give suggestion to solve this problem/any alternative solution

 

//Code for creating proxy
public static DevicesServiceClient CreateProxy()
{
 
var proxy = new DevicesServiceClient("BasicHttpBinding_IDevicesService");

 
BasicHttpBinding binding = new BasicHttpBinding();
  binding
.Security.Mode = BasicHttpSecurityMode.None;
  binding

WCF client with internet proxy server showing error The server committed a protocol violation. Secti

  

Our team trying to create a windows application(c#) to call a WCF service using internet proxy server

Showing exception "The server committed a protocol violation. Section=ResponseStatusLine" while calling WCF service

when i tried to solve the problem using this code then showing the same error

 

<configuration>
   
<system.net>
       
<settings>
           
<httpWebRequest useUnsafeHeaderParsing="true" />
       
</settings>
   
</system.net>
</configuration>

 

Please give suggestion to solve this problem/any alternative solution

 

Invoking a web method fails with 'The underlying connection was closed: Unable to connect to the re

  

Hi all,

i am currently challenging a problem that suddenly started to happen in my production environment when invoking a WS method from a windows-service .NET app.

The windows service is waiting for requests incoming through MQ, unwraps these requests from an "MQ XML packet" and redirects these requests to the web service. This web service has only one web method, which is kind of "main entry point" for the underlying backend application.

This monday approx. 30% of attempts to invoke that web method are failing with message: The underlying connection was closed: Unable to connect to the remote server.   
      CallStack:   
      at System.Net.HttpWebRequest.CheckFinalStatus()   
      at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult)   
      at System.Net.HttpWebRequest.GetRequestStream()   
      at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object?! parameters)   
      at MyWebService.GetResponse(String requestMessage, String&amp; responseMessage)   
 &n

Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend