Cannot Create new tread or post reply in any forum

Topics: Help
Nov 9, 2007 at 3:04 AM
Edited Nov 9, 2007 at 3:07 AM
Hi all,

I get the following error when trying to create a new tread or posting a reply to a forum

-------------------------------------------------------------------------------------------

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 actively refused it

Source Error:


Line 54: smtp.Send(mailMsg)
Line 55: Catch ex As Exception
Line 56: Throw
Line 57: End Try
Line 58: End Sub


Source File: C:\inetpub\wwwroot\FCU\App_Code\BLL\ForumPostNotification.vb Line: 56

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) +1029090
System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) +33
System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +431

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) +1475584
System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) +190
System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) +21
System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) +318
System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) +227
System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) +316
System.Net.Mail.SmtpClient.GetConnection() +42
System.Net.Mail.SmtpClient.Send(MailMessage message) +1485

SmtpException: Failure sending mail.
System.Net.Mail.SmtpClient.Send(MailMessage message) +2074
ClubStarterKit.Web.ForumNotification.Notify(ForumMessage forumMsg) in C:\inetpub\wwwroot\FCU\App_Code\BLL\ForumPostNotification.vb:56
ClubStarterKit.Web.Forum.Add(ForumMessage msg, Boolean AdminOnly) in C:\inetpub\wwwroot\FCU\App_Code\BLL\Forum.vb:104
ASP.forumaddpostaspx.UpdateButton_Click(Object sender, EventArgs e) in C:\inetpub\wwwroot\FCU\Forum\AddPost.aspx:100
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +105
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +174
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.312; ASP.NET Version:2.0.50727.833
Nov 9, 2007 at 6:51 AM
Edited Nov 9, 2007 at 6:53 AM
It looks like your email configuration is improperly set.

One system option allows sending an email when the post was finished. It looks like the server
couldn't send it. Check your site settings and make sure the email account, password, and server are all correct.



As a software developer, though, I'm curious if re-throwing at the end of the block is a good idea. It seems unwise to announce to the world that there is a server misconfiguration. At my work we have written our own sites to send stack trace and other debugging info to the developers while showing a nice pretty error screen to the clients. Over the years it has accumulated a lot of useful debugging info -- but that's beside the point for this reply.

It's a shame the this system couldn't just send an email to the site admin or some other behind-the-scenes reporting, but obviously if the email is misconfigured then it would have a hard time doing that. :-)
Nov 9, 2007 at 11:00 PM
Thanks for the answer.

I do not have a smtp server since i'm just playing around with the club site on my laptop.

I commented out the throw statement and now i'm getting this error

Server Error in '/' Application.
--------------------------------------------------------------------------------

The INSERT statement conflicted with the FOREIGN KEY constraint "FKMembersThreadsThreads". The conflict occurred in database "ClubDB", table "dbo.Threads", column 'threadid'.
The statement has been terminated.
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.Data.SqlClient.SqlException: The INSERT statement conflicted with the FOREIGN KEY constraint "FKMembersThreadsThreads". The conflict occurred in database "ClubDB", table "dbo.Threads", column 'threadid'.
The statement has been terminated.

Source Error:


Line 108:
Line 109: Public Shared Sub MarkThreadRead(ByVal threadid As Integer, ByVal memberid As Guid)
Line 110: SPs.MarkThreadRead(threadid, memberid).Execute()
Line 111: End Sub
Line 112:


Source File: C:\inetpub\wwwroot\FCU\App_Code\BLL\Forum.vb Line: 110

Stack Trace:


[SqlException (0x80131904): The INSERT statement conflicted with the FOREIGN KEY constraint "FK_MembersThreads_Threads". The conflict occurred in database "ClubDB", table "dbo.Threads", column 'threadid'.
The statement has been terminated.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +859322
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +736198
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1959
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +149
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +903
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +132
System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) +415
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +135
SubSonic.SqlDataProvider.ExecuteQuery(QueryCommand qry) in C:\SubSonic 2.0.3\src\SubSonic\DataProviders\SqlDataProvider.cs:196
SubSonic.StoredProcedure.Execute() in C:\SubSonic 2.0.3\src\SubSonic\ActiveRecord\StoredProcedure.cs:152
ClubStarterKit.Web.Forum.MarkThreadRead(Int32 threadid, Guid memberid) in C:\inetpub\wwwroot\FCU\App_Code\BLL\Forum.vb:110
ASP.forumaddpostaspx.UpdateButton_Click(Object sender, EventArgs e) in C:\inetpub\wwwroot\FCU\Forum\AddPost.aspx:102
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +105
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +174
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.312; ASP.NET Version:2.0.50727.833

I think we should give the option to send email or not from the site setting

Hannibal
Apr 11, 2008 at 4:56 PM
You can't send email from your app on your local machine. While testing on your local machine just comment out Line 54: smtp.Send(mailMsg).

You will then more than likely receive an error about not being able to mark the thread as read when you are replying. I have not spent any time on trying to fix that issue, I just commented it out as it was not important to me that that thread is marked as read when someone replies. So in your Forum/AddPost.aspx VB code find ClubStarterKit.Web.Forum.MarkThreadRead(newmsgthreadid, uGuid) and just commented it out.

There is also another discussion on this topic in this Forum with a possible solution (I haven't tried it yet). Refer to thread 21234 http://www.codeplex.com/ClubStarterKit/Thread/View.aspx?ThreadId=21234

Good luck.
Apr 11, 2008 at 5:07 PM
Here's another thread on same issue, it seems to have solved the issue for those who have tried it.

http://www.codeplex.com/ClubStarterKit/Thread/View.aspx?ThreadId=16103