Docker app gives ERR_SOCKET_CONNECTION_TIMEOUT when use ArrayBuffer in Axios or fetch method

20 views Asked by At

I am getting a strange issue with docker. When I use axios / fetch method to get data from an API with that return the arrayBuffer My axios gives error ERR_SOCKET_CONNECTION_TIMEOUT.

Same things works properly when I run my application without docker. adding few of the docker for refrence.

docker-compose.yml

version: '3'
services:
  staging: 
    build: ./
    environment:
      - NODE_ENV=${NODE_ENV}
      - SERVER_PORT=${API_CLIENT_PORT}
    # ports:
      # - ${API_CLIENT_PORT}:${API_CLIENT_PORT}
    network_mode: "host"

Axios call

try {
            const result = await Axios({
                method: method,
                url: endpoint,
                headers: {
                    'Content-Type': 'text/xml'
                },
                responseType: apiType != '' ? 'arraybuffer' : 'text'
            });

            return result.data;
        } catch (error) {
            return false;
        }

I tried with changing the method from Axios to fetch, or increasing the timeout in the axios call but nothing works.

0

There are 0 answers