fix: recover CMPP slots after gateway restart
This commit is contained in:
@@ -541,6 +541,9 @@ describe('SmsConfigService', () => {
|
||||
remoteIp: '127.0.0.1',
|
||||
}),
|
||||
});
|
||||
expect(prisma.cmppDownstreamConnection.deleteMany).toHaveBeenCalledWith({
|
||||
where: { status: 'connected', lastHeartbeatAt: { lt: new Date('2026-07-11T10:58:30.000Z') } },
|
||||
});
|
||||
expect(prisma.operationLog.create).toHaveBeenCalledWith({
|
||||
data: expect.objectContaining({
|
||||
action: 'cmpp_downstream_connection.connected',
|
||||
|
||||
@@ -681,6 +681,10 @@ export class SmsConfigService {
|
||||
if (data.remoteIp && !isIpAllowed(data.remoteIp, application.ipAllowlist.map((item) => item.ipCidr))) {
|
||||
throw new ForbiddenException('CMPP source IP is not in application allowlist');
|
||||
}
|
||||
// A Gateway process can disappear before it reports disconnect. Prune its
|
||||
// expired rows here so a restarted process can reclaim connection slots
|
||||
// without waiting for an operator to open the connection-list page.
|
||||
await this.markTimedOutDownstreamConnections(observedAt);
|
||||
const activeConnections = await this.prisma.cmppDownstreamConnection.findMany({
|
||||
where: { applicationId: application.id, status: 'connected' },
|
||||
select: { connectionId: true },
|
||||
|
||||
Reference in New Issue
Block a user