I am trying to send images to WooCommerce through API and I am getting 504 Gateway Time-out
, the same error I am getting in Postman. I tried with changing max_execution_time but again I got error 504.
public function updateProduct($ecart, $product, $wooId){
//set_time_limit(3600);
//ini_set('max_execution_time', 3600);
//ini_set('memory_limit', '2048M');
$response = Http::withHeaders([
'Content-Type' => 'application/json',
])->withBasicAuth($ecart->client_key, $ecart->client_secret)->put(
$ecart->url.'/wp-json/wc/v3/products/'.$wooId,
$product);
//dd($response);
dump('res',$response);
$body = json_decode($response->getBody(), true);
dd($body);
return $response;
}
What else I can do, because I have this problem in localhost, adn I don't know will this happen in production??
This is my response
Illuminate\Http\Client\Response^ {#9529
#response: GuzzleHttp\Psr7\Response^ {#9583
-reasonPhrase: "Gateway Time-out"
-statusCode: 504
-headers: array:6 [
"Server" => array:1 [
0 => "nginx"
]
"Date" => array:1 [
0 => "Fri, 27 Jan 2023 08:08:48 GMT"
]
"Content-Type" => array:1 [
0 => "text/html"
]
"Content-Length" => array:1 [
0 => "160"
]
"Connection" => array:1 [
0 => "keep-alive"
]
"Strict-Transport-Security" => array:1 [
0 => "max-age=63072000"
]
]
-headerNames: array:6 [
"server" => "Server"
"date" => "Date"
"content-type" => "Content-Type"
"content-length" => "Content-Length"
"connection" => "Connection"
"strict-transport-security" => "Strict-Transport-Security"
]
-protocol: "1.1"
-stream: GuzzleHttp\Psr7\Stream^ {#9580
-stream: stream resource {@1032
wrapper_type: "PHP"
stream_type: "TEMP"
mode: "w+b"
unread_bytes: 0
seekable: true
uri: "php://temp"
options: []
}
-size: null
-seekable: true
-readable: true
-writable: true
-uri: "php://temp"
-customMetadata: []
}
}
#decoded: null
+"cookies": GuzzleHttp\Cookie\CookieJar^ {#9554
-cookies: []
-strictMode: false
}
+"transferStats": GuzzleHttp\TransferStats^ {#9584
-request: GuzzleHttp\Psr7\Request^ {#9577
-method: "PUT"
-requestTarget: null
-uri: GuzzleHttp\Psr7\Uri^ {#9553
-scheme: "https"
-userInfo: ""
-host: "test.myraidbox.de"
-port: null
-path: "/wp-json/wc/v3/products/10612"
-query: ""
-fragment: ""
-composedComponents: "https://test.myraidbox.de/wp-json/wc/v3/products/10612"
}
-headers: array:5 [
"Content-Length" => array:1 [
0 => "1902"
]
"User-Agent" => array:1 [
0 => "GuzzleHttp/7"
]
"Authorization" => array:1 [
0 => "Basic Y2tfYWY4MTFhZmU4OWM2OWNjMWRjY2NiMGRlYjVmYjc2Y2UyODQxYTUyNzpjc182ZThkODlhZDIzNTVlYjA1ZTJhOTY5YThkODE3ZmQ4NWQ0NjY3MDA2"
]
"Host" => array:1 [
0 => "test.myraidbox.de"
]
"Content-Type" => array:1 [
0 => "application/json"
]
]
-headerNames: array:5 [
"content-length" => "Content-Length"
"user-agent" => "User-Agent"
"authorization" => "Authorization"
"host" => "Host"
"content-type" => "Content-Type"
]
-protocol: "1.1"
-stream: GuzzleHttp\Psr7\Stream^ {#9568
-stream: stream resource {@1030
wrapper_type: "PHP"
stream_type: "TEMP"
mode: "w+b"
unread_bytes: 0
seekable: true
uri: "php://temp"
options: []
}
-size: 1902
-seekable: true
-readable: true
-writable: true
-uri: "php://temp"
-customMetadata: []
}
}
-response: GuzzleHttp\Psr7\Response^ {#9583}
-transferTime: 30.163235
-handlerStats: array:38 [
"url" => "https://test.myraidbox.de/wp-json/wc/v3/products/10612"
"content_type" => "text/html"
"http_code" => 504
"header_size" => 200
"request_size" => 2195
"filetime" => -1
"ssl_verify_result" => 0
"redirect_count" => 0
"total_time" => 30.163235
"namelookup_time" => 0.004224
"connect_time" => 0.007388
"pretransfer_time" => 0.103427
"size_upload" => 1902.0
"size_download" => 160.0
"speed_download" => 5.0
"speed_upload" => 63.0
"download_content_length" => 160.0
"upload_content_length" => 1902.0
"starttransfer_time" => 30.163099
"redirect_time" => 0.0
"redirect_url" => ""
"primary_ip" => "::ffff:167.235.133.93"
"certinfo" => []
"primary_port" => 443
"local_ip" => "::ffff:172.18.0.7"
"local_port" => 57572
"http_version" => 2
"protocol" => 2
"ssl_verifyresult" => 0
"scheme" => "HTTPS"
"appconnect_time_us" => 103359
"connect_time_us" => 7388
"namelookup_time_us" => 4224
"pretransfer_time_us" => 103427
"redirect_time_us" => 0
"starttransfer_time_us" => 30163099
"total_time_us" => 30163235
"appconnect_time" => 0.103359
]
-handlerErrorData: 0
}
}
And this is my .docker/nginx/default
server {
listen 80 default_server;
listen 443 ssl;
server_name backend.brandcanyon.de;
root /var/www/html/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
ssl_certificate /etc/ssl/certs/localhost.crt;
ssl_certificate_key /etc/ssl/private/localhost.key;
client_max_body_size 100M;
fastcgi_read_timeout 600;
proxy_read_timeout 600;
location / {
try_files $uri $uri/ /index.php?$query_string;
# for OPTIONS return these headers and HTTP 200 status
if ($request_method = OPTIONS) {
add_header Access-Control-Allow-Methods "*";
add_header Access-Control-Allow-Headers "*";
add_header Access-Control-Allow-Origin "*";
return 200;
}
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
location ~ \.php$ {
fastcgi_pass php-fpm:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}