-
Notifications
You must be signed in to change notification settings - Fork 236
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
Concurrent goroutine and WithRetryKey() Usage Leads to Request Discrepancies #435
Comments
Hi, thank you for using line-bot-sdk-go and this report, @YukiTsuchida ! The issue is that this is not thread-safe in line-bot-sdk-go/linebot/client.go Lines 294 to 296 in 7bb6882
Therefore, creating a new client is one of the solutions. The new client does not seem to have the same issue. Please give it a try. Lines 149 to 165 in 291a96f
|
@Yang-33 Thanks for the quick reply! I solved it using the method you provided. |
Thank you for trying this yourself~ That's good~ |
System Informations
Expected Behavior
When making multiple PushMessage API requests concurrently using goroutines, each request's X-Line-Retry-Key and message body should match and be sent as expected.
Current Behavior
Using goroutines to invoke the PushMessage API multiple times results in occasional mismatches between the X-Line-Retry-Key and the message content in the request body. This leads to the LINE API mistakenly identifying these requests as duplicates, returning a 409 error, and consequently failing to send some messages.
Steps to Reproduce
https://go.dev/play/p/6idORXgHYJ_s
Logs
Here is an example of the actual request logs, where the mismatch between the X-Line-Retry-Key and the text field in the request body can be confirmed:
Additional Context
Currently, I am working around this issue by creating a new instance of linebot.Client for each request, but this is merely a temporary workaround. This approach is not suitable, especially under circumstances of handling large-scale traffic. I am looking forward to a resolution for this problem.
The text was updated successfully, but these errors were encountered: