react native axios network error post for https

in my react native app suddenly some device is stuck on network errors and can not apply any request even if they reinstalled the app they stuck on network error

“react-native”: “0.74.1”, “axios”: “^1.7.3”,

the error log is

{
  "message": "Network Error",
  "name": "AxiosError",
  "stack": "AxiosError: Network Error\n    at anonymous (/data/user/0/com.ukkera.student/files/CodePush/44b7e2c3628b0100789c76ed4c664c5d0f2862ce56c593bf4044d93ed26de5c3/CodePush/index.android.bundle:1556:1290)\n    at call (native)\n    at dispatchEvent (/data/user/0/com.ukkera.student/files/CodePush/44b7e2c3628b0100789c76ed4c664c5d0f2862ce56c593bf4044d93ed26de5c3/CodePush/index.android.bundle:136:5650)\n    at value (/data/user/0/com.ukkera.student/files/CodePush/44b7e2c3628b0100789c76ed4c664c5d0f2862ce56c593bf4044d93ed26de5c3/CodePush/index.android.bundle:129:8891)\n    at value (/data/user/0/com.ukkera.student/files/CodePush/44b7e2c3628b0100789c76ed4c664c5d0f2862ce56c593bf4044d93ed26de5c3/CodePush/index.android.bundle:129:4822)\n    at apply (native)\n    at anonymous (/data/user/0/com.ukkera.student/files/CodePush/44b7e2c3628b0100789c76ed4c664c5d0f2862ce56c593bf4044d93ed26de5c3/CodePush/index.android.bundle:129:7606)\n    at apply (native)\n    at value (/data/user/0/com.ukkera.student/files/CodePush/44b7e2c3628b0100789c76ed4c664c5d0f2862ce56c593bf4044d93ed26de5c3/CodePush/index.android.bundle:52:789)\n    at apply (native)\n    at anonymous (/data/user/0/com.ukkera.student/files/CodePush/44b7e2c3628b0100789c76ed4c664c5d0f2862ce56c593bf4044d93ed26de5c3/CodePush/index.android.bundle:49:906)\n    at value (/data/user/0/com.ukkera.student/files/CodePush/44b7e2c3628b0100789c76ed4c664c5d0f2862ce56c593bf4044d93ed26de5c3/CodePush/index.android.bundle:49:915)\n    at apply (native)\n    at value (/data/user/0/com.ukkera.student/files/CodePush/44b7e2c3628b0100789c76ed4c664c5d0f2862ce56c593bf4044d93ed26de5c3/CodePush/index.android.bundle:37:3898)\n    at anonymous (/data/user/0/com.ukkera.student/files/CodePush/44b7e2c3628b0100789c76ed4c664c5d0f2862ce56c593bf4044d93ed26de5c3/CodePush/index.android.bundle:37:694)\n    at value (/data/user/0/com.ukkera.student/files/CodePush/44b7e2c3628b0100789c76ed4c664c5d0f2862ce56c593bf4044d93ed26de5c3/CodePush/index.android.bundle:37:2529)\n    at value (/data/user/0/com.ukkera.student/files/CodePush/44b7e2c3628b0100789c76ed4c664c5d0f2862ce56c593bf4044d93ed26de5c3/CodePush/index.android.bundle:37:665)\n    at ?anon_0_ (/data/user/0/com.ukkera.student/files/CodePush/44b7e2c3628b0100789c76ed4c664c5d0f2862ce56c593bf4044d93ed26de5c3/CodePush/index.android.bundle:1532:629)\n    at throw (native)\n    at n (/data/user/0/com.ukkera.student/files/CodePush/44b7e2c3628b0100789c76ed4c664c5d0f2862ce56c593bf4044d93ed26de5c3/CodePush/index.android.bundle:7:74)\n    at s (/data/user/0/com.ukkera.student/files/CodePush/44b7e2c3628b0100789c76ed4c664c5d0f2862ce56c593bf4044d93ed26de5c3/CodePush/index.android.bundle:7:322)\n    at tryCallOne (address at InternalBytecode.js:1:1180)\n    at anonymous (address at InternalBytecode.js:1:1874)\n    at apply (native)\n    at anonymous (/data/user/0/com.ukkera.student/files/CodePush/44b7e2c3628b0100789c76ed4c664c5d0f2862ce56c593bf4044d93ed26de5c3/CodePush/index.android.bundle:123:1668)\n    at k (/data/user/0/com.ukkera.student/files/CodePush/44b7e2c3628b0100789c76ed4c664c5d0f2862ce56c593bf4044d93ed26de5c3/CodePush/index.android.bundle:123:499)\n    at w (/data/user/0/com.ukkera.student/files/CodePush/44b7e2c3628b0100789c76ed4c664c5d0f2862ce56c593bf4044d93ed26de5c3/CodePush/index.android.bundle:123:889)\n    at callReactNativeMicrotasks (/data/user/0/com.ukkera.student/files/CodePush/44b7e2c3628b0100789c76ed4c664c5d0f2862ce56c593bf4044d93ed26de5c3/CodePush/index.android.bundle:123:3059)\n    at value (/data/user/0/com.ukkera.student/files/CodePush/44b7e2c3628b0100789c76ed4c664c5d0f2862ce56c593bf4044d93ed26de5c3/CodePush/index.android.bundle:37:2897)\n    at anonymous (/data/user/0/com.ukkera.student/files/CodePush/44b7e2c3628b0100789c76ed4c664c5d0f2862ce56c593bf4044d93ed26de5c3/CodePush/index.android.bundle:37:984)\n    at value (/data/user/0/com.ukkera.student/files/CodePush/44b7e2c3628b0100789c76ed4c664c5d0f2862ce56c593bf4044d93ed26de5c3/CodePush/index.android.bundle:37:2529)\n    at value (/data/user/0/com.ukkera.student/files/CodePush/44b7e2c3628b0100789c76ed4c664c5d0f2862ce56c593bf4044d93ed26de5c3/CodePush/index.android.bundle:37:942)\n    at value (/data/user/0/com.ukkera.student/files/CodePush/44b7e2c3628b0100789c76ed4c664c5d0f2862ce56c593bf4044d93ed26de5c3/CodePush/index.android.bundle:37:722)",
  "config": {
    "transitional": {
      "silentJSONParsing": true,
      "forcedJSONParsing": true,
      "clarifyTimeoutError": false
    },
    "adapter": [
      "xhr",
      "http",
      "fetch"
    ],
    "transformRequest": [
      null
    ],
    "transformResponse": [
      null
    ],
    "timeout": 0,
    "xsrfCookieName": "XSRF-TOKEN",
    "xsrfHeaderName": "X-XSRF-TOKEN",
    "maxContentLength": -1,
    "maxBodyLength": -1,
    "env": {},
    "headers": {
      "Accept": "application/json",
      "Content-Type": "application/json",
      "lang": "ar"
    },
    "method": "post",
    "url": "https://apis.ukkera.com/api/v1/student/private/gate",
    "data": "{\"user\":\"01032176793\",\"password\":\"\",\"password_confirmation\":\"\",\"device_id\":\"dde318d99ccc05f3\",\"device_type\":\"RMX3261 application\"}"
  },
  "code": "ERR_NETWORK"
}

post https request and it should return normal reponse

The “Network Error” you’re encountering in your React Native app can be caused by various issues, especially since it seems to be affecting some devices persistently. Here are several troubleshooting steps and considerations to help resolve the issue:

1. Check Network Connectivity

  • Ensure that the affected devices have a stable internet connection. You can try accessing other websites or services to confirm.

2. Verify API Endpoint

  • Make sure that the API endpoint (https://apis.ukkera.com/api/v1/student/private/gate) is reachable from those devices. Use a browser or tools like Postman on the device to test the endpoint.

3. Check SSL Certificate

  • If you are using HTTPS, ensure that the SSL certificate for your API is valid and trusted. You can check this using tools like SSL Labs to see if there are any issues with the certificate.

4. Debugging in Axios

  • Consider adding error handling in your Axios request to log more specific details about the failure. You can do this using .catch:
axios.post(url, data)
  .then(response => {
    console.log(response.data);
  })
  .catch(error => {
    if (error.response) {
      // The request was made and the server responded with a status code
      console.log('Error response data:', error.response.data);
      console.log('Error response status:', error.response.status);
    } else if (error.request) {
      // The request was made but no response was received
      console.log('Error request:', error.request);
    } else {
      // Something happened in setting up the request that triggered an error
      console.log('Error message:', error.message);
    }
  });

5. Clear App Data and Cache

  • Sometimes, clearing the app’s data and cache can resolve persistent issues. Instruct users to do this in their device settings.

6. Check for Device-Specific Issues

  • If the problem is isolated to certain devices, check if there are any device-specific settings (like VPNs, firewall rules, etc.) that could be affecting the network requests.

7. Update Dependencies

  • Ensure that your dependencies (including Axios and React Native) are up to date. There might be bug fixes or improvements in newer versions.

8. CodePush Issues

  • Since your logs mention CodePush, verify if there are any issues related to the latest deployment. Sometimes, a bad deployment can cause unexpected behavior.

9. Check for Proxy Settings

  • If the affected devices are on a corporate or restricted network, there might be proxy settings that need to be configured for the app to access external services.

10. Use a Different HTTP Client

  • If the issue persists, consider testing with a different HTTP client library (like fetch) to see if the issue is related to Axios.

11. Network Interceptors

  • You can add network interceptors to log every request and response to get more insights:
axios.interceptors.request.use(request => {
  console.log('Starting Request', request);
  return request;
});

axios.interceptors.response.use(response => {
  console.log('Response:', response);
  return response;
});