woocommerce / woocommerce-rest-api-js-lib

New JavaScript library for WooCommerce REST API
https://www.npmjs.com/package/@woocommerce/woocommerce-rest-api
MIT License
273 stars 76 forks source link

The AWS Lambda returns "Error: connect ETIMEDOUT **.****.***.***:443" #105

Open acabun opened 2 years ago

acabun commented 2 years ago

I have to services, Admin Panel(Laravel) и Online Shop(Woocommerce). TH relation between these to services was realized with "AWS Lambda"

when I try to send an updating product request from my ADmin panel to online shop, time to time the lambda couldn't connect to the Woocomerce API. On time when the system is not updating the product, lambda returns the error "Error: connect ETIMEDOUT"

I originally thought that the Wordpress didn't have enought time for updating process. And decided to increase the lambda's timeout (60000 ms). But it didn't help. I still found the ETIMEDOUT errors in logs.

By the way, the time period between sending the updating request to woocommerce and showing an error is 2 min. If I right understand, the lambda had enought time for getting the answer from woocommerce.

Another strage thing. According the lambda's logs, on time when lambda got an error, the woocommerce API was available. It seems like something disconnects the internet on time when lambda is sending the request.

My question is, why lambda cannot send to woocommerce API the reuqest. Why it happens time to time ?

P.S. Below I added the example of lambda's logs.


The log on starting sending the uptading request.

2021-08-14T18:23:48.692Z b228455b-45a8-5cbf-8160-1cc INFO Inside edit Online List { status: '1',


is_delete: 0, name: 'Omega Speedmaster Moonwatch Chronograph 42mm ', price_on_request: 0, on_sale: 0 }

The log with error.

2021-08-14T18:25:58.299Z b228455b-45a8-5cbf-8aae6 INFO WooCommerce editOnlineStock err::: { Error: connect ETIMEDOUT *.***..:443 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1107:14) errno: 'ETIMEDOUT', code: 'ETIMEDOUT', syscall: 'connect', address: '.**.**.', port: 443, config: { url: 'https://domain.com/wp-json/wc/v3/products/*', method: 'put', params: {}, data: '{"name":"Omega Speedmaster Moonwatch Chronograph 42mm ","type":"simple"***', headers: { Accept: 'application/json', 'Content-Type': 'application/json;charset=utf-8', 'User-Agent': 'WooCommerce REST API - JS Client/1.0.1', 'Content-Length': 681 }, auth: { username: 'ck****', password: 'cs****' }, transformRequest: [ [Function: transformRequest] ], transformResponse: [ [Function: transformResponse] ], timeout: 60000, adapter: [Function: httpAdapter], responseType: 'json', xsrfCookieName: 'XSRF-TOKEN', xsrfHeaderName: 'X-XSRF-TOKEN',