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

Not able to call SmsConversion API to report the Feedback #665

Open
Go-coder-go opened this issue Feb 11, 2025 · 3 comments
Open

Not able to call SmsConversion API to report the Feedback #665

Go-coder-go opened this issue Feb 11, 2025 · 3 comments

Comments

@Go-coder-go
Copy link

Hi team,

Implemented a code to report the smsconversion back the Alibaba, but getting some error. Able to create client properly but facing EOF while calling SmsConversion API.
Below is the code:

func (ac *alibabaClientWrapper) sendFeedback(ctx context.Context, notificationID string) error {
	request := requests.NewCommonRequest()
	request.Method = "POST"
	request.Scheme = "https"
	request.Domain = ac.config.URL
	request.Version = "2018-05-01"
	request.ApiName = "SmsConversion"
	request.QueryParams["Action"] = "SmsConversion"
	request.QueryParams["MessageId"] = "abc"
	request.QueryParams["Delivered"] = "true"

	response, err := ac.sdkClient.ProcessCommonRequest(request)
	if err != nil {
		return errors.Wrap(err, "[Alibaba.sendFeedback] Error while making http call")
	}
	if !response.IsSuccess() {
		return errors.Errorf("[Alibaba.sendFeedback] Incorrect Status code %v", response.BaseResponse.GetHttpStatus())
	}

	return nil
}

Error:
Error while making http call : Post \"https://dysmsapi.ap-southeast-1.aliyuncs.com/?AccessKeyId=xxx\u0026Action=SmsConversion\u0026Delivered=true\u0026Format=JSON\u0026MessageId=xxx\u0026RegionId=ap-southeast-1\u0026Signature=xVmzhyz5E5FMrNP9w2%2BaZvDwzpM%3D\u0026SignatureMethod=HMAC-SHA1\u0026SignatureNonce=51b55f2bfbd22a419350d04142cd45fa\u0026SignatureType=\u0026SignatureVersion=1.0\u0026Timestamp=2025-02-10T07%3A36%3A27Z\u0026Version=2018-05-01\": EOF for notificationID: xxxx"

Please help in fixing this.

@TsinghuaDream
Copy link

This is usually caused by network jitter during cross-border calls, and the error message can be reinforced by strengthening the network path or adding retry logic.

@Go-coder-go
Copy link
Author

@TsinghuaDream Any concrete solution for this as it has been failing for a number of requests.

@TsinghuaDream
Copy link

TsinghuaDream commented Feb 11, 2025

Try adding retry like this:
for {
response, err := ac.sdkClient.ProcessCommonRequest(request)
if err == nil {
fmt.Println("Request successful.")
break
}

    if isEOFError(err) && retries < maxRetries {
        retries++
        fmt.Printf("EOF error detected, retrying %d/%d...\n", retries, maxRetries)
        time.Sleep(retryDelay)
        continue
    } else {
        fmt.Printf("Max retries but request failed: %v\n", err)
        break
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants