An existing connection was forcibly closed.. Error.

Discussion in 'ASP.NET / ASP.NET Core' started by ezboy, Mar 1, 2011.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I am getting this error when I am setting my password recovery in my asp website hosted by discountasp.net

    " An existing connection was forcibly closed by the remote host "

    Here is the settings I am using.. Please let me know if I am missing something..

    <system.net>
    <mailSettings>
    <smtp deliveryMethod="Network"
    from="[email protected]">
    <network host="smtp.websiteatdiscountasp.com"
    userName="[email protected]"
    password="xxxxxxx"
    port="25" />
    </smtp>
    </mailSettings>
    </system.net>

    I tried host="localhost" also in place of smtp.webs..., i get the same error.

    <membership defaultProvider="xxxxxxxx">
    <providers>

    <add name="xxxxxxxx"
    type="System.Web.Security.SqlMembershipProvider"
    connectionStringName="LocalSqlServer"
    enablePasswordRetrieval="false"
    enablePasswordReset="true"
    requiresQuestionAndAnswer="false"
    applicationName="xxxxxxx"
    requiresUniqueEmail="true"
    passwordFormat="Hashed"
    maxInvalidPasswordAttempts="5"
    minRequiredPasswordLength="7"
    minRequiredNonalphanumericCharacters="0"
    passwordAttemptWindow="6"
    passwordStrengthRegularExpression=""/>
    </providers>
    </membership>

    In the mark up page for the password recover control, this is what I have..

    <asp:passwordRecovery ID="PasswordRecovery1" runat="server">

    <MailDefinition BodyFileName="~/xxxx/Pwdreco.txt"
    Subject="Password has been changed...">
    </MailDefinition>
    </asp:passwordRecovery>


    I need help setting this email recovery on this Discountaspnet host website... thank you for any help...
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    switch smtp host to localhost
    take out the authentication, ie. blank out the username / password
     
  3. That did not fix it. I get the same error message.
     
  4. Try it like this:

    <system.net>
    <mailSettings>
    <smtp from="[email protected]" deliveryMethod="Network">
    <network host="localhost" port="25" password="xxxxxxx" userName="[email protected]"/>
    </smtp>
    </mailSettings>
    </system.net>
     
  5. ok. I tried this also.
    Same error message.
    But where am I using Discounstasp.net email server and messaging system, in your solution?
     
  6. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

    Try it like this as bruce suggested:

    <network host="localhost" port="25" />
     
  7. Well I tried again , gets me the same error message.

    There is definitely something that I am doing incorrectly here.. Please see my code in the my original post.. and let me know if you need any more information.... I need to get this working.

    Thank you all for your suggestions and help.
     
  8. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

    Shouldn't enablePasswordRetrieval be set to true?
     
  9. For passwordformat ="Hashed", PasswordRetrieval should be false.
    and passwordreset should be true.

    I checked the documentation again. That is how it should be for hashed passwords, because they are unretreivable... with passwordreset = true, a new password is generated and sent.

    This is where I need the email settings - to send the new password to user.
     
  10. ...I just looked your code over again and the ASP.NET control doesn't look right.
    Should be like this:
    <asp:passwordRecovery ID=PasswordRecovery1" Runat="server">
    <MailDefinition From="[email protected]">
    </MailDefinition>
    </asp:passwordRecovery>

    ASP.NET examples for this control always use this in the web.config:
    <smtp from="[email protected]>
    <network host="localhost" port="25" defaultCredentials="true" />
    </smtp>
     
  11. I am getting the same error. I pasted the error message below. I am working on a copy on my development machine , the database is on the discountasp server ...

    An existing connection was forcibly closed by the remote host
    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: An existing connection was forcibly closed by the remote host

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:


    [SocketException (0x2746): An existing connection was forcibly closed by the remote host]
    System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) +6132200
    System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) +134

    [IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.]
    System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) +300
    System.Net.DelegatedStream.Read(Byte[] buffer, Int32 offset, Int32 count) +45
    System.Net.BufferedReadStream.Read(Byte[] buffer, Int32 offset, Int32 count) +105
    System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader caller, Boolean oneLine) +248
    System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader caller) +16
    System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint) +665
    System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint) +170
    System.Net.Mail.SmtpClient.GetConnection() +50
    System.Net.Mail.SmtpClient.Send(MailMessage message) +1484

    [SmtpException: Failure sending mail.]
    System.Net.Mail.SmtpClient.Send(MailMessage message) +1811
    System.Web.UI.WebControls.LoginUtil.SendPasswordMail(String email, String userName, String password, MailDefinition mailDefinition, String defaultSubject, String defaultBody, OnSendingMailDelegate onSendingMailDelegate, OnSendMailErrorDelegate onSendMailErrorDelegate, Control owner) +371
    System.Web.UI.WebControls.PasswordRecovery.AttemptSendPasswordUserNameView() +566
    System.Web.UI.WebControls.PasswordRecovery.AttemptSendPassword() +62
    System.Web.UI.WebControls.PasswordRecovery.OnBubbleEvent(Object source, EventArgs e) +103
    System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
    System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +125
    System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +167
    System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
    System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
    System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563
     
  12. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

    Sorry, I missed the passwordformat="Hashed". Can you verify that the email address you're trying to send to is valid?
     
  13. Got this fixed.
    Bruce's suggestion in the beginning was the solution.

    Not paying attention to small details...thanks to every one who responded.
     
  14. mjp

    mjp

    Glad you got it sorted out.
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page