Exception Details: System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it


The following class throws an excpetion that is handled by Utilities.LogError(Ex) which in turn gives me the error with regards to send mail. However I am trying to figure out why is ExecuteSelectCommand() throwing an exception to begin with. Any help is very appreciated. I have attached the stack trace to get a better insight.

Also I am a noob when it comes to oop, asp.net etc. Apologise is this is too silly a question. Thanks  :)

public
static DataTable ExecuteSelectCommand(DbCommand command)

{

//The DataTable to be returned

DataTable table;

//Execute the command making sure the connection gets closed in the end

try

{

//Open the data connection

command.Connection.Open();

//Execute the command and save the results in a DataTable

DbDataReader reader = command.ExecuteReader();table = new DataTable();

table.Load(reader);

//Close the reader

reader.Close();

}

catch (Exception ex)

{

Utilities.LogError(ex);throw ex;

}

finally

{

//Close the connection

command.Connection.Close();

}

return table;

}

 

Stack Trace:

[SocketException (0x274d): No connection could be made because the target machine actively refused it]
   System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +200
   System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) +60
   System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +579

[WebException: Unable to connect to the remote server]
   System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) +391
   System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) +288
   System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) +46
   System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) +429
   System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) +333
   System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) +287
   System.Net.Mail.SmtpClient.GetConnection() +56
   System.Net.Mail.SmtpClient.Send(MailMessage message) +1679

[SmtpException: Failure sending mail.]
   System.Net.Mail.SmtpClient.Send(MailMessage message) +2246
   Utilities.SendMail(String from, String to, String subject, String body) in c:\vwd\BalloonShop\App_Code\Utilities.cs:24
   Utilities.LogError(Exception ex) in c:\vwd\BalloonShop\App_Code\Utilities.cs:50
   GenericDataAccess.ExecuteSelectCommand(DbCommand command) in c:\vwd\BalloonShop\App_Code\GenericDataAccess.cs:45
   CatalogAccess.GetDepartments() in c:\vwd\BalloonShop\App_Code\CatalogAccess.cs:32
   UserControls_DepartmentsList.Page_Load(Object sender, EventArgs e) in c:\vwd\BalloonShop\UserControls\DepartmentsList.ascx.cs:18
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +31
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +68
   System.Web.UI.Control.OnLoad(EventArgs e) +88
   System.Web.UI.Control.LoadRecursive() +74
   System.Web.UI.Control.LoadRecursive() +158
   System.Web.UI.Control.LoadRecursive() +158
   System.Web.UI.Control.LoadRecursive() +158
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3037

0
ASPdiuhfsiufh
9/5/2007 7:49:06 AM
asp.net.object-datasource 16182 articles. 0 followers. Follow

0 Replies
968 Views

Similar Articles

[PageSpeed] 21

Reply:

Similar Artilces:

Exception while calling .NET web service | System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
Hi,   We have written a .NET web service which retrieves an xml file from the database. This web service is SSL secured and requires client certificates for connection.   Problem: The web service is throwing an exception while retrieving large files. It works fine when the file size is around 1 MB, but fails with a file size of around 65 MB with the following exception: System.InvalidOperationException: There is an error in XML document (1, 38455668). ---> System.IO.IOException: Unable to read data from the transport connection. ---> System.Net.Sockets.SocketException: ...

System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: Only one usage of each socket address (protocol/network address/port) is normally permitted
I'm getting this error when hitting a webservice thousands of times for a mass upload. I've researched on the web and added the suggested code but am still getting the error: protected override WebRequest GetWebRequest(Uri uri) { System.Net.HttpWebRequest webRequest = (System.Net.HttpWebRequest)base.GetWebRequest(uri); webRequest.KeepAlive = false; return webRequest; }  Are you receiving it on the client, or on the service?John Saunders | MVP – Connected System Developer...

System.Net.Sockets.SocketException: An established connection was aborted by the software in your host machine
Hello, I got this error today in an Application.  This app is coded in asp.net 2, using VB.  I have the Andri Code (http://makoto.madmedia.ca/2007/03/mysql-membership-and-role-provider-for.html) to connect asp.net with mysql. It has never caused errors in the past, I have the same configuration on another app that has been running for several months with no problem. This app is new (1 week) and today is the first day I see this error. Any ideas? Server Error in '/' Application.-------------------------------------------------------------------------------- An estab...

When runnig Web Service asynchronously
When I try to call web service asynchronousIy I am getting exception from CLR: System.Net.Sockets.SocketException: The attempted operation is not supported for the type of object referenced. (During VS.NET debugging the exception is wrapped as: Unable to connect to the remote server) When i call the service synchronously it works perfectly.  The service just convert strings to lower case. I'm using .NET Framework 2.0, here is the source code of form to call the service asynchronously:   Imports localhost Partial Class ChangeStrings Inherits System.Web.UI....

System.Net.Sockets.SocketException with MySQL Connector.NET
Hi. I already tried many things and spent already 2 days without any success. Please help or I'll hang myself.I am using MySql.Data.dll  ver. 5.2.5.0 (runtime v2.0.50727) from my project (library). It works great if i use it from WindowsApplication but once i use it same way in WebApplication, it keeps throwing: The attempted operation is not supported for the type of object referencedException Details: System.Net.Sockets.SocketException: The attempted operation is not supported for the type of object referenced .. AsyncResult ias = socket.BeginConnect(endPoint, null, null);.. (or w...

smtp error: unable to connect to remote server...No connection could be made because the target machine actively refused it
Hi, I got "InnerException: Unable to connect to remote server"..."No connection could be made because the target machine actively refused it" when I attempted to send an email through my Intranet app that is written in asp.net 2.0.  The smtp server is a local server and it uses Port 25.  The Authentication is set to Anonymous Access.  Here's my code:     <system.net>       <mailSettings>         <smtp>           <network host="10.162.22.72" /> &nb...

No connection could be made because the target machine actively refused it
Hi, I'm trying to send email with SMTP from a webproject developed in vb and ASP.NET 2.0, In my code i assigned my machine name as localhost ,and i got the following message. No connection could be made because the target machine actively refused it Can anyone help me Thanx Mrugesh  I'm not sure I totally understand you problem.Do you host the SMTP server on your machine ? Basically, the error message above means that you are trying to connect to some address on port 25 (default for SMTP) and that port is not listening for any incoming connections. Prob...

No connection could be made because the target machine actively refused it
No connection could be made because the target machine actively refused it   i had this error when i tried to access a RSS Feed i wrote a code which is working fine when running in localhost mode from the visual studio IDE while when running that code from the IIS  it gives that error any ides the Code is as follows 'Server AuthenticationDim cred1 As New System.Net.NetworkCredential("UserName", "Password", "DomainName") Dim bnareader1 As XmlTextReader Dim wrq As HttpWebRequest ' RSS Feed Reading For BBC NewsDim reader1 As X...

No connection could be made because the target machine actively refused it
Hi, I'm trying to send email with SMTP from a webproject developed in C-Sharp and ASP.NET 2.0, In my code i assigned my machine name as Computos8,and i got the following message. No connection could be made because the target machine actively refused it   Any help will be appreciated. That error message usually means a firewall is blocking your connection.  Instead of using your machine name "Computos8", try using "localhost".  Darrell Norton, MVPDarrell Norton's BlogPlease mark this post as answered if it helped you! Hi Darell Norton, Ev...

No connection could be made because the target machine actively refused it
 Hi!    I am working on a server-client project. I use HttpWebRequest, whenever I tried to request on the server I got the error that says "No connection could be made because the target machine actively refused it" Here is my code, kindly check and tell me where did I go wrong. Client: Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load                Dim req As HttpWebRequest = WebRequest.Create("http://localhost:1652/HttpWebRe...

No connection could be made because the target machine actively refused it
Can someone help me with this error...? This error comes after I publish precompiled to the server using VS2005.Server Error in '/' Application. No connection could be made because the target machine actively refused it Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Net.Sockets.SocketException: No connection could be made because the target machine a...

No connection could be made because the target machine actively refused it
Hello,  I am not sure if this is the right forum. This is the first time that I have seen this error, No connection could be made because the target machine actively refused it I have a web app that when some one inserts text in a text box and clicks a button it creates a new web page and a new table in the database.  Up until this point it has always worked.  A datalist returns the data.  In the datalist there is a hyperlink that when clicked takes the client to the new webpage.  But for some reason it is not working now and that is the error above. I am ...

No connection could be made because the target machine actively refused it #2
 Hi all In my asp.net application I try to connect to a web service hosted on a different server using the WebRequest Class.The web service returns a string as a Response. While doing so I get an Error: "System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it" The code that I am using is below:            WebRequest request = WebRequest.Create(url);                    &n...

Error: No connection could be made because the target machine actively refused it
I am trying to call a WebService method and pass an string (xml format) and am getting following errror... any idea? ---------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- No connection could be made because the target machine actively refused it Description: An unhandled exception occurred during the execution...

Web resources about - Exception Details: System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it - asp.net.object-datasource

Resources last updated: 11/23/2015 11:08:56 PM