Authorize.Net Connection Fails to Respond

Discussion in 'ASP.NET / ASP.NET Core' started by mtfarmer1, Jul 18, 2009.

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 attempting to use my site to connect to Authorize.Net to process payments and am receiving a time-out error (see below) when attempting to submit the payment to the processor.

    The code works fine on my production server but breaks when moved to the live environment. Does anyone with Authorize.Net expreience recognize this error?

    I have attached both the relevant source code and the error page below.

    Any help you can provide would be appreciated.

    Thanks,
    Mark T. Farmer
    [email protected]


    ERROR MESSAGE:

    Server Error in '/roth2010' Application.

    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 212.227.255.181:3128

    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: 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 212.227.255.181:3128

    Source Error:
    Line 209: ' post data is sent as a stream
    Line 210: Dim myWriter As StreamWriter = Nothing
    Line 211: myWriter = New StreamWriter(objRequest.GetRequestStream())
    Line 212: myWriter.Write(post_string)
    Line 213: myWriter.Close()


    Source File: E:\web\advisorstru\htdocs\roth2010\order-form.aspx.vb Line: 211

    Stack Trace:
    [SocketException (0x274c): 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 212.227.255.181:3128]
    System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +239
    System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) +35
    System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +224

    [WebException: Unable to connect to the remote server]
    System.Net.HttpWebRequest.GetRequestStream() +5322142
    OrderForm.ProcessTransaction() in E:\web\advisorstru\htdocs\roth2010\order-form.aspx.vb:211
    OrderForm.OrderWizard_FinishButtonClick(Object sender, WizardNavigationEventArgs e) in E:\web\advisorstru\htdocs\roth2010\order-form.aspx.vb:74
    System.Web.UI.WebControls.Wizard.OnFinishButtonClick(WizardNavigationEventArgs e) +108
    System.Web.UI.WebControls.Wizard.OnBubbleEvent(Object source, EventArgs e) +641
    System.Web.UI.WebControls.WizardChildTable.OnBubbleEvent(Object source, EventArgs args) +19
    System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
    System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +118
    System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +166
    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) +1565


    Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082

    SOURCE CODE (line throwing the error is highlighted in red):

    Protected Sub ProcessTransaction()
    Dim post_url As String
    post_url = "https://test.authorize.net/gateway/transact.dll"
    Dim post_values As New Dictionary(Of String, String)

    'TEST REQUEST
    post_values.Add("x_test_request", "FALSE")


    'Account ID Info
    post_values.Add("x_login", "xxxxxxxx")
    post_values.Add("x_tran_key", "xxxxxxxxxxxxxxx")


    'Response Format
    post_values.Add("x_delim_data", "TRUE")
    post_values.Add("x_delim_char", "|")
    post_values.Add("x_relay_response", "FALSE")


    'CC Information
    post_values.Add("x_type", "AUTH_CAPTURE")
    post_values.Add("x_method", "CC")
    post_values.Add("x_card_num", Trim(cardnumber.Text))
    post_values.Add("x_exp_date", expmonth.Text & "-" & expyear.Text)


    'Transaction Details
    post_values.Add("x_amount", HiddenPrice.Value.ToString)
    post_values.Add("x_description", HiddenProductName.Value.ToString)


    'Customer Info
    post_values.Add("x_first_name", Trim(fname.Text))
    post_values.Add("x_last_name", Trim(lname.Text))
    post_values.Add("x_phone", Trim(telephone.Text))
    post_values.Add("x_email", Trim(email.Text))
    post_values.Add("x_company", Trim(company.Text))


    'Billing Address
    post_values.Add("x_address", Trim(address1.Text & " " & address2.Text))
    post_values.Add("x_city", Trim(city.Text))
    post_values.Add("x_state", Trim(state.Text))
    post_values.Add("x_zip", Trim(zip.Text))


    'Email Message
    post_values.Add("x_header_email_receipt", "Dear " & fname.Text & "," & vbCrLf & vbCrLf & "Thank you for purchasing the " & Trim(HiddenProductName.Value.ToString) & ". We will send you a separate email containing the login information for your new account. The details of your transaction are listed below:")
    post_values.Add("x_footer_email_receipt", "If you have any questions about your purchase please don't hesitate to contact us at
    [email protected]. Once again, thank you for your business!")

    Dim post_string As String = ""

    For Each field As KeyValuePair(Of String, String) In post_values
    post_string &= field.Key & "=" & field.Value & "&"
    Next

    post_string = Left(post_string, Len(post_string) - 1)


    ' create an HttpWebRequest object to communicate with Authorize.net
    Dim objRequest As HttpWebRequest = CType(WebRequest.Create(post_url), HttpWebRequest)
    objRequest.Method = "POST"
    objRequest.ContentLength = post_string.Length
    objRequest.ContentType = "application/x-www-form-urlencoded"


    ' post data is sent as a stream
    Dim myWriter As StreamWriter = Nothing
    myWriter = New StreamWriter(objRequest.GetRequestStream())
    myWriter.Write(post_string)
    myWriter.Close()


    ' returned values are returned as a stream, then read into a string
    Dim objResponse As HttpWebResponse = CType(objRequest.GetResponse(), HttpWebResponse)
    Dim responseStream As New StreamReader(objResponse.GetResponseStream())
    Dim post_response As String = responseStream.ReadToEnd()
    responseStream.Close()
     
  2. Hi,
    I'd contact DASP Support about this as it appears this service is needing a two way handshake across DASP servers.
    All the best,
    Mark
     
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