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

Cannot receive the retry failed callback #4

Closed
tang4595 opened this issue Jul 4, 2024 · 1 comment
Closed

Cannot receive the retry failed callback #4

tang4595 opened this issue Jul 4, 2024 · 1 comment

Comments

@tang4595
Copy link
Contributor

tang4595 commented Jul 4, 2024

When a message fails to be sent and enters the resend queue, you will never receive a resend failure callback.

Relevant code:

WKRetryManager.m

-(void) retrySend{
    [self.retryLock lock];
    NSArray *keys = self.retryDict.allKeys;
    [self.retryLock unlock];
    for (NSString *key  in keys) {
        [self.retryLock lock];
        WKRetryItem *item =  self.retryDict[key];
        [self.retryLock unlock];
        NSTimeInterval now = [[NSDate date] timeIntervalSince1970];
        // 如果重试次数小于目标重试次数并且满足重试时间,则重试
        if(item && item.retryCount<[WKSDK shared].options.messageRetryCount) {
            if(item.retryCount<[WKSDK shared].options.messageRetryCount ) {
                if((now - item.nextRetryTime)>=0) {
                    if([WKSDK shared].isDebug) {
                        NSLog(@"重发消息  key:[%@] retryCount: [%ld] nextRetryTime: [%ld]",key,item.retryCount,item.nextRetryTime);
                    }
                    item.retryCount++;
                    item.nextRetryTime =now+[WKSDK shared].options.messageRetryInterval;
                    [[[WKSDK shared] chatManager] sendMessage:item.message addRetryQueue:false];
                }
            }else { // 超过重试次数 消息状态设置为发送失败
                [self.retryLock lock];
                [self.retryDict removeObjectForKey:key];
                [self.retryLock unlock];
                // 更新消息状态为失败
                item.message.status =WK_MESSAGE_FAIL;
                [[WKMessageDB shared] updateMessageStatus:WK_MESSAGE_FAIL withClientSeq:item.message.clientSeq];
               
                // 通知上层
                [[WKSDK shared].chatManager callMessageUpdateDelegate:item.message];
            }
           
        }
    }
   
}

The code [[WKSDK shared].chatManager callMessageUpdateDelegate:item.message] will never be excuted.

Logs:

重发消息  key:[26] retryCount: [0] nextRetryTime: [1720074011]
重发消息  key:[26] retryCount: [1] nextRetryTime: [1720074021]
重发消息  key:[26] retryCount: [2] nextRetryTime: [1720074031]
重发消息  key:[26] retryCount: [3] nextRetryTime: [1720074041]
重发消息  key:[26] retryCount: [4] nextRetryTime: [1720074051]
重发消息  key:[26] retryCount: [5] nextRetryTime: [1720074061]
重发消息  key:[26] retryCount: [6] nextRetryTime: [1720074071]
重发消息  key:[26] retryCount: [7] nextRetryTime: [1720074081]
@tang4595
Copy link
Contributor Author

tang4595 commented Jul 5, 2024

Resolved with PR #5

@tang4595 tang4595 closed this as completed Jul 5, 2024
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

1 participant