Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bala_dev's avatar

HTTP request method returns null.

Hi Everyone,

I am receiving a NULL response from the API.

From my Job file I am calling this function as below.

            $customers = $this->bcAgent->getCustomers([
                "id:in" => $orderRow['customer_id']
            ])->json();

This primary job is to export the orders with the customers from bigcommerce. When exporting from my local, I don't have any problem.

When I run this same on the Digital Ocean server, I am encountering a NULL response from the API. This happens very random.

This is my queue configuration

        'database' => [
            'driver' => 'database',
            'connection' => env('DB_QUEUE_CONNECTION'),
            'table' => env('DB_QUEUE_TABLE', 'jobs'),
            'queue' => env('DB_QUEUE', 'default'),
            'retry_after' => (int) env('DB_QUEUE_RETRY_AFTER', 90),
            'after_commit' => false,
        ],

For running the jobs, I am using supervisor with the below command

php artisan queue:work --timeout=3600

Can anyone suggest what's the possible cause for this. Thanks.

0 likes
2 replies
LaryAI's avatar
Level 58

The issue you're experiencing with receiving a NULL response from the API on your Digital Ocean server, while it works fine locally, could be due to several factors. Here are some potential causes and solutions:

  1. Network Issues:

    • Ensure that your server has a stable internet connection. Network instability can cause requests to fail intermittently.
  2. Firewall or Security Groups:

    • Check if there are any firewall rules or security groups on your Digital Ocean server that might be blocking outgoing requests to the BigCommerce API.
  3. Timeouts:

    • The NULL response might be due to a timeout. You have set a timeout of 30 seconds in your request() method. Consider increasing this timeout to see if it resolves the issue:
      protected function request()
      {
          $request = $this->agent::withHeaders([
              'X-Auth-Token' => $this->token,
              'Accept' => 'application/json',
              'Content-Type' => 'application/json'
          ]);
          $request->timeout(60); // Increase timeout to 60 seconds
          $request->asJson();
          return $request;
      }
      
  4. Error Handling:

    • Add error handling to log the response status and body when a request fails. This can help you diagnose the issue:
      public function getCustomers(array $query): Response
      {
          $response = $this->request()->get($this->url . 'v3/customers?' . http_build_query($query));
      
          if ($response->failed()) {
              Log::error('BigCommerce API request failed', [
                  'status' => $response->status(),
                  'body' => $response->body()
              ]);
          }
      
          return $response;
      }
      
  5. Environment Differences:

    • Ensure that the environment variables on your server are correctly set, especially those related to the API URL, tokens, and any other configuration that might differ from your local setup.
  6. Supervisor Configuration:

    • Check your Supervisor configuration to ensure it's not causing any issues. Sometimes, Supervisor might not be configured to handle long-running processes correctly.
  7. API Rate Limits:

    • Verify if you're hitting any rate limits imposed by the BigCommerce API. If so, you might need to implement rate limiting or retry logic.

By implementing these suggestions, you should be able to identify and resolve the issue causing the NULL response from the API on your server.

Please or to participate in this conversation.