RuntimeError: 1047 (AWS_IO_SOCKET_CONNECTION_REFUSED): socket connection refused..

0

Good evening everyone 👋,

I have a question that has been bugging me for a couple of hours at this point.

I'm trying to set up an IPC communication with my Docker component deployed in my GG core device.

However, I'm getting this error for socket connection:

2023-11-16T16:57:25.144Z [WARN] (Copier) container: stderr. _awscrt.event_stream_rpc_client_connection_connect(. {scriptName=services.container.lifecycle.run, serviceName=container, currentState=RUNNING} 2023-11-16T16:57:25.144Z [WARN] (Copier) container: stderr. RuntimeError: 1047 (AWS_IO_SOCKET_CONNECTION_REFUSED): socket connection refused.. {scriptName=services.container.lifecycle.run, serviceName=container, currentState=RUNNING} 2023-11-16T16:57:26.124Z [INFO] (Copier) container: Run script exited. {exitCode=1, serviceName=container, currentState=RUNNING}

This is my configuration for the component

{
  "RecipeFormatVersion": "2020-01-25",
  "ComponentName": "${component_name}",
  "ComponentVersion": "${component_version}",
  "ComponentDescription": "A component that runs a Docker container from S3.",
  "ComponentPublisher": "Ed",
  "ComponentDependencies": {
    "aws.greengrass.DockerApplicationManager": {
      "VersionRequirement": "~2.0.0"
    },
    "aws.greengrass.TokenExchangeService": {
      "VersionRequirement": "~2.0.0"
    }
  },
  "Manifests": [
    {
      "Platform": {
        "os": "all"
      },
      "Lifecycle": {
        "run": "docker run --rm -e SVCUID -e AWS_GG_NUCLEUS_DOMAIN_SOCKET_FILEPATH_FOR_COMPONENT -v {kernel:rootPath}/ipc.socket:{kernel:rootPath}/ipc.socket 109139691401.dkr.ecr.eu-central-1.amazonaws.com/signal-process:container"
      },
      "Artifacts": [
        {
          "URI": "docker:109139691401.dkr.ecr.eu-central-1.amazonaws.com/signal-process:container"
        }
      ]
    }
  ]
}

Is there any other configuration I have to do in the container so that I can run this?

I appreciate it a lot 🙏

Ed
已提問 7 個月前檢視次數 312 次
2 個答案
1

Hello,

Please follow the documented docker options to correctly use IPC: https://docs.aws.amazon.com/greengrass/v2/developerguide/run-docker-container.html#docker-container-ipc

Cheers,

Michael

AWS
專家
已回答 7 個月前
0
已接受的答案

Thank you very much for such a prompt response Michael, following the link that you provided actually worked!

Here's an updated version from the docker component configuration:

{
  "RecipeFormatVersion": "2020-01-25",
  "ComponentName": "${component_name}",
  "ComponentVersion": "${component_version}",
  "ComponentDescription": "A component that runs a Docker container from S3.",
  "ComponentPublisher": "Ed",
  "ComponentDependencies": {
    "aws.greengrass.DockerApplicationManager": {
      "VersionRequirement": "~2.0.0"
    },
    "aws.greengrass.TokenExchangeService": {
      "VersionRequirement": "~2.0.0"
    }
  },
  "ComponentConfiguration": {
    "DefaultConfiguration": {
      "topic": "thesis/docker",
      "message": "Hello, World!",
      "qos": "1",
      "accessControl": {
        "aws.greengrass.ipc.pubsub": {
          "dockercontainer:pubsub:1": {
            "policyDescription": "Allows access to publish to Pub and Sub topics.",
            "operations": [
              "aws.greengrass#SubscribeToTopic"
            ],
            "resources": [
              "thesis/docker"
            ]
          }
        }
      }
    }
  },
  "Manifests": [
    {
      "Platform": {
        "os": "all"
      },
      "Lifecycle": {
        "run": "docker run -v {kernel:rootPath}/ipc.socket:{kernel:rootPath}/ipc.socket -v /home/pi/mastergit/audio_files/100:/app/files -e SVCUID -e AWS_GG_NUCLEUS_DOMAIN_SOCKET_FILEPATH_FOR_COMPONENT -e MQTT_TOPIC=\"{configuration:/topic}\" -e MQTT_MESSAGE=\"{configuration:/message}\" -e MQTT_QOS=\"{configuration:/qos}\" --rm 109139691401.dkr.ecr.eu-central-1.amazonaws.com/signal-process:shark"
      },
      "Artifacts": [
        {
          "URI": "docker:109139691401.dkr.ecr.eu-central-1.amazonaws.com/signal-process:shark"
        }
      ]
    }
  ]
}

There are couple of things that need to be point from the documentation in the link provided, however.

  • There is a mismatch in the access control. The AWS IoT Core MQTT is specified as granting access, however the PubSub is the one that is enabled.
"accessControl": {
        "aws.greengrass.ipc.mqttproxy": {
          "com.example.python.docker.PublishToIoTCore:pubsub:1": {
  • For me, it worked to include the kernel rootPath {kernel:rootPath}/ipc.socket:{kernel:rootPath}/ipc.socket . Otherwise I would be getting issues related to RuntimeError: 44 (AWS_ERROR_FILE_INVALID_PATH): Invalid file path.

Hope it is useful, and thank you very much again for the help

Ed

Ed
已回答 7 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南