question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Docker config step missing? 400 reason: connect ECONNREFUSED

See original GitHub issue

I was running the docker version of this twin explorer, and getting a 400 error from the Identity.

per the docs I did:

  • Access tokens enabled
  • URI callback http://localhost:3000 added

Application runs fine, however the credential issue below.

AuthenticationError: ManagedIdentityCredential authentication failed.(status code 400).
More details:
request to http://169.254.169.254/metadata/identity/oauth2/token?resource=https%3A%2F%2Fdigitaltwins.azure.net&api-version=2018-02-01 failed, reason: connect ECONNREFUSED 169.254.169.254:80
    at ManagedIdentityCredential.<anonymous> (/usr/src/app/client/node_modules/@azure/identity/dist/index.js:1077:23)
    at Generator.throw (<anonymous>)
    at rejected (/usr/src/app/client/node_modules/@azure/identity/node_modules/tslib/tslib.js:112:69)
    at processTicksAndRejections (node:internal/process/task_queues:93:5)
  • is it required to add 169.254.169.254 to the callback URI in the app, in addition to localhost?
  • is there another place in the system setup where you need to add the DT credentials?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
joseba-altrancommented, Nov 2, 2020

Well, the following Dockerfile does appear to be working fine again. I’ll try to brush it up a little bit (I’ll also try to convert it into a multi-stage build in order to reduce the image size) and create a PR.

FROM node:latest

# Create app directory
WORKDIR /usr/src/app/client

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY ./client/package*.json ./
WORKDIR /usr/src/app/client/src
RUN npm install
# If you are building your code for production
# RUN npm ci --only=production

# Bundle app source
WORKDIR /usr/src/app
COPY . .

# Install the Azure CLI, which will be required for authentication
RUN curl -sL https://aka.ms/InstallAzureCLIDeb | bash

# Notify that we want to expose port 3000
EXPOSE 3000
# Create startup script & start the app
WORKDIR /usr/src/app/client/src
RUN printf "#!/bin/sh\nset -e\naz login && npm run start" > startup.sh
RUN chmod 0755 startup.sh
ENTRYPOINT ["./startup.sh"]
2reactions
joseba-altrancommented, Nov 2, 2020

I can replicate the issue and would say that the problem with the authentication is related to the changes mentioned here: https://github.com/Azure-Samples/digital-twins-explorer/commit/52f6de60a04d32776a626ff05b59ae99656a0154

I have manually tried to install the azure CLI and run az login within the docker image and that seems to work, will have to integrate that into the Dockerfile & update the instructions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Docker container having issue communicating to local server ...
Since everything is running on one machine, is there a reason you configured server.ui.graphql_url to be different than its default (localhost)?.
Read more >
Node.js Error: connect ECONNREFUSED - Stack Overflow
ECONNREFUSED error means that connection could not be made with the target service (in your case localhost:8080 ).
Read more >
Troubleshoot Docker Engine installation
Your Docker client is attempting to connect to a Docker daemon on a different host, and that host is unreachable. To see which...
Read more >
Docker Tools Tips and Tricks - Visual Studio Code
Docker containers and images have disappeared from Docker view ... This is most likely caused by a conflict with another extension called Docker...
Read more >
The connection to the server localhost:8080 was refused
when you run any kubectl or a similar command in Kubernetes you may get an error message like this The connection to the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found