Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dial tcp: lookup sqs..amazonaws.com: no such host #2472

Closed
ChevalierTieto opened this issue Jan 29, 2024 · 4 comments
Closed

dial tcp: lookup sqs..amazonaws.com: no such host #2472

ChevalierTieto opened this issue Jan 29, 2024 · 4 comments
Assignees
Labels
guidance Question that needs advice or information. p3 This is a minor priority issue response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.

Comments

@ChevalierTieto
Copy link

Describe the bug

Running SQS code to receive messages on my EC2 instance encountered an exception.

Expected Behavior

DNS resolution issue
I am testing DNS resolution on the EC2 instance, whether it is "nslookup sqs. us east-1. amazonaws. com" or "dig" https://sqs.us-east-1.amazonaws.com It's all normal.
i update all modules under aws-sdk-go-v2 (including indirects)

Current Behavior

The error message is as follows

https response error StatusCode: 0, RequestID: , request send failed, Post "https://sqs..amazonaws.com/": dial tcp: lookup sqs..amazonaws.com: no such host

Reproduction Steps

cfg, err := config.LoadDefaultConfig(context.Background(), config.WithRegion("us-east-1"))
sqsClient := sqs.NewFromConfig(cfg)
msgOutput, err := sqsClient.ReceiveMessage(context.Background(), &sqs.ReceiveMessageInput{
		QueueUrl:            ptrutil.Ptr("https://sqs.us-east-1.amazonaws.com/1111111/my-queue"),
		MaxNumberOfMessages: 10,
		WaitTimeSeconds:     20,
	})

I have tried not specifying a region, but still encountered an error because my EC2 instance and SQS service are both in "us east-1" region

cfg, err = config.LoadDefaultConfig(context.Background())

However, if i make some changes to the code and log in and run it as SSO on the local machine without changing the version dependency, it can run normally

cfg, err := config.LoadDefaultConfig(context.Background(),config.WithSharedConfigProfile("my-profile-name"))
sqsClient := sqs.NewFromConfig(cfg)
msgOutput, err := sqsClient.ReceiveMessage(context.Background(), &sqs.ReceiveMessageInput{
		QueueUrl:            ptrutil.Ptr("https://sqs.us-east-1.amazonaws.com/1111111/my-queue"),
		MaxNumberOfMessages: 10,
		WaitTimeSeconds:     20,
	})

Possible Solution

Region parsing may have issues

Additional Information/Context

No response

AWS Go SDK V2 Module Versions Used

My go version and related dependencies are as follows

go 1.20  
require (
	github.com/aws/aws-sdk-go-v2 v1.24.1
	github.com/aws/aws-sdk-go-v2/config v1.26.6
	github.com/aws/aws-sdk-go-v2/service/s3 v1.48.1
	github.com/aws/aws-sdk-go-v2/service/ses v1.19.6
	github.com/aws/aws-sdk-go-v2/service/sqs v1.29.7
)
require (
	github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.5.4 // indirect
	github.com/aws/aws-sdk-go-v2/credentials v1.16.16 // indirect
	github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.11 // indirect
	github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.10 // indirect
	github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.10 // indirect
	github.com/aws/aws-sdk-go-v2/internal/ini v1.7.3 // indirect
	github.com/aws/aws-sdk-go-v2/internal/v4a v1.2.10 // indirect
	github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.4 // indirect
	github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.2.10 // indirect
	github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.10.10 // indirect
	github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.16.10 // indirect
	github.com/aws/aws-sdk-go-v2/service/sso v1.18.7 // indirect
	github.com/aws/aws-sdk-go-v2/service/ssooidc v1.21.7 // indirect
	github.com/aws/aws-sdk-go-v2/service/sts v1.26.7 // indirect
)

Compiler and Version used

go1.20.4 linux/amd64

Operating System and version

Ubuntu 22.04.3 LTS

@ChevalierTieto ChevalierTieto added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 29, 2024
@ChevalierTieto
Copy link
Author

ChevalierTieto commented Jan 29, 2024

After running go get github.com/aws/aws-sdk-go-v2@v1.24.0, it works well.
However, I still need to specify the region, such as specifying it like this,

cfg, err := config.LoadDefaultConfig(context.Background(), config.WithRegion("us-east-1"))

Even my EC2 instance and SQS service are in "us east-1"
otherwise the same error message will still appear

@RanVaknin
Copy link
Contributor

RanVaknin commented Jan 30, 2024

Hi @ChevalierTieto ,

You must specify a region in your config because the SDK does not "know" where your resources live. The SDK's job is to take in various inputs, like your credentials, the region, and input for the actual operation, form the correct URL and sign the request based on what the Service API requires. Region must be provided like any other input like queue name.

Let me know if you have any other question.
Ran~

@RanVaknin RanVaknin self-assigned this Jan 30, 2024
@RanVaknin RanVaknin added guidance Question that needs advice or information. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. p3 This is a minor priority issue and removed bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 30, 2024
@ChevalierTieto
Copy link
Author

Hi @RanVaknin
It seems that I misunderstood the configuration method of region. I previously thought that there was no need to specify a region when using the SDK on an EC2 instance. Now it seems that I was wrong. After specifying the region, the code will run normally, which has nothing to do with the SDK version. Thank you very much!

Copy link

github-actions bot commented Feb 1, 2024

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
guidance Question that needs advice or information. p3 This is a minor priority issue response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days.
Projects
None yet
Development

No branches or pull requests

2 participants