gpt4 book ai didi

php - AWS-CloudWatch : InvalidSequenceTokenException

转载 作者:可可西里 更新时间:2023-11-01 12:35:25 26 4
gpt4 key购买 nike

我有一个 php worker,我将事件记录到 AWS 可以观看。不幸的是,我在尝试提交时遇到了以下错误。

InvalidSequenceTokenException Error executing "PutLogEvents" on "https://logs.eu-west-1.amazonaws.com"; AWS HTTP error: Client error: POST https://logs.eu-west-1.amazonaws.com resulted in a 400 Bad
Request
response: {"__type":"InvalidSequenceTokenException","expectedSequenceToken":"999999999999990356407851919528174 (truncated...) InvalidSequenceTokenException (client): The given sequenceToken is invalid. The next expected sequenceToken is: 495599999999988500356407851919528174642 - {"__type":"InvalidSequenceTokenException","expectedSequenceToken":"495573099999999900356407851919528174642","message":"The given sequenceToken is invalid. The next expected sequenceToken is: 495579999999900356407851919528174642"}

这是我的代码

 $date = new DateTime();
$instance= = new CloudWatchLogsClient([
'region' => 'eu-west-1',
'version' => 'latest',
'credentials' => [
'key' => 'XXX',
'secret' => 'XXXX'
]
]);
$instance->putLogEvents([
'logGroupName' => "WorkerLog",
'logStreamName' => "log",
'logEvents' => [
[
'timestamp' => $date->getTimestamp(),
'message' => "test log"
]
]
]);

最佳答案

http://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutLogEvents.html

您必须在请求中包含一个序列标记。如果您没有,则必须使用 describeLogStreams ( http://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_DescribeLogStreams.html ) 来获取流序列。

当您调用 putLogEvents 时,您将在响应中获得 nextToken。您还必须为其他人推送到流并使 nextToken 无效的情况做好准备。 (在这种情况下,您需要再次描述流以获取更新的 token )。

关于php - AWS-CloudWatch : InvalidSequenceTokenException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34525955/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com