簡體   English   中英

從部署的應用程序(Hetzner)向 authorize.net 發送請求時連接超時?

[英]getting connect timeout when sending request to authorize.net from deployed app(Hetzner)?

我們有一個 grails 4.0.10 應用程序。 我們集成了 authorize.net 以接受信用卡付款。 我用過 accept.js 庫。

向 authorize.net 發送信用卡收費請求的代碼部分如下

        def descriptor = params['dataDescriptor']
        def value = params['dataValue']


        String firstName = params[AuthNetField.X_FIRST_NAME.fieldName]
        String lastName = params[AuthNetField.X_LAST_NAME.fieldName]
        String address = params[AuthNetField.X_ADDRESS.fieldName]
        String city = params[AuthNetField.X_CITY.fieldName]
        String state = params[AuthNetField.X_STATE.fieldName]
        String zip = params[AuthNetField.X_ZIP.fieldName]
        String country = params[AuthNetField.X_COUNTRY.fieldName]
        String phone = params[AuthNetField.X_PHONE.fieldName]
        String email = params[AuthNetField.X_EMAIL.fieldName]

        String apiLoginId = grailsApplication.config.net.authorize.apiLoginId


        if (grailsApplication.config.net.authorize.environment == net.authorize.Environment.PRODUCTION){
            ApiOperationBase.setEnvironment(Environment.PRODUCTION);
        }
        else{
            ApiOperationBase.setEnvironment(Environment.SANDBOX);
        }

        String transactionKey = grailsApplication.config.net.authorize.transactionKey


        MerchantAuthenticationType merchantAuthenticationType  = new MerchantAuthenticationType() ;
        merchantAuthenticationType.setName(apiLoginId);
        merchantAuthenticationType.setTransactionKey(transactionKey);
        ApiOperationBase.setMerchantAuthentication(merchantAuthenticationType);

        // Populate the payment data
        PaymentType paymentType = new PaymentType();
        OpaqueDataType OpaqueData = new OpaqueDataType();
        OpaqueData.setDataDescriptor(descriptor);
        OpaqueData.setDataValue(value);
        paymentType.setOpaqueData(OpaqueData);


        CustomerDataType cdt = new CustomerDataType()
        cdt.setEmail(email)

        CustomerAddressType customerType = new CustomerAddressType()
        customerType.setFirstName(firstName)
        customerType.setLastName(lastName)
        customerType.setAddress(address)
        customerType.setCity(city)
        customerType.setState(state)
        customerType.setZip(zip)
        customerType.setCountry(country)
        customerType.setPhoneNumber(phone)

        // Create the payment transaction request
        TransactionRequestType txnRequest = new TransactionRequestType();
        txnRequest.setTransactionType(TransactionTypeEnum.AUTH_CAPTURE_TRANSACTION.value());
        txnRequest.setPayment(paymentType);
        txnRequest.setBillTo(customerType)
        txnRequest.setCustomer(cdt)

        ArrayOfLineItem aol = new ArrayOfLineItem()


        itemizedOrderEntries.each { io ->

            def parts = io.split("<\\|>")

            LineItemType lit = new LineItemType()
            lit.setItemId(parts[0])
            lit.setName(parts[1])
            lit.setDescription(parts[2])
            lit.setQuantity(parts[3].toBigDecimal())
            lit.setUnitPrice(parts[4].toBigDecimal())
            lit.setTaxable(parts[5].toBoolean())


            aol.lineItem.add(lit)


        }


        txnRequest.setLineItems(aol)


        txnRequest.setAmount(total.setScale(2, RoundingMode.CEILING));


        // Make the API Request
        CreateTransactionRequest apiRequest = new CreateTransactionRequest();
        apiRequest.setTransactionRequest(txnRequest);
        CreateTransactionController controller = new CreateTransactionController(apiRequest);
        controller.execute();


        CreateTransactionResponse tresponse = controller.getApiResponse();

當應用程序在本地運行時,它可以連接到 authorize.net 服務器。

但是當應用程序被部署到遠程服務器時,我們正在使用 hetzner 服務器,我正在連接超時。 我在下面粘貼了錯誤。

2023-01-28 23:53:17.082 ERROR --- [pool-4-thread-1] net.authorize.util.HttpCallTask          : Http request execute failed: 'Connect to apitest.authorize.net:443 [apitest.authorize.net/198.241.206.22] failed: connect timed out'
2023-01-28 23:53:17.082  WARN --- [pool-4-thread-1] net.authorize.util.HttpCallTask          : Adding ErrorMessage: Code: 'org.apache.http.conn.ConnectTimeoutException', Text: 'Connect to apitest.authorize.net:443 [apitest.authorize.net/198.241.206.22] failed: connect timed out'
2023-01-28 23:53:17.083 ERROR --- [nio-8443-exec-3] n.a.a.controller.base.ApiOperationBase   : Invalid response:'net.authorize.api.contract.v1.ANetApiResponse@6744ad91'
2023-01-28 23:53:17.091 ERROR --- [nio-8443-exec-3] StackTrace                               : Full Stack Trace:

當我在我的系統中本地運行應用程序時,它可以成功連接到 authorize.net api 但是當我遠程運行它時,即我們的 web 應用程序托管在 Hetzner 服務器上,它會出現連接超時錯誤。

你知道是什么導致了這個連接超時嗎?

我似乎沒有找到原因。 我感謝任何指導。

謝謝

更新:

正如@roanjain 所建議的,我向沙箱 api 端點發出了 curl 請求。

花了幾分鍾然后輸出如下

在此處輸入圖像描述

更新 2:

我從另一台服務器發送了相同的 curl 請求並且它有效。 所以我認為問題只出在 hetzner 服務器上。

在此處輸入圖像描述

最后通過將服務器移動到另一個位置讓它工作。 最初我在俄勒岡州有服務器。 Hetzner 確認該位置的 ips 大部分已被 authorize.net 阻止。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM