n8n-nodes-chat2crm 0.1.13 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -96,8 +96,18 @@ class Chat2CrmTrigger {
|
|
|
96
96
|
// Создаем подключения к Redis только для нужных баз данных
|
|
97
97
|
const redisConnections = new Map();
|
|
98
98
|
for (const db of streamsByDb.keys()) {
|
|
99
|
+
// Создаем отдельное соединение для каждой базы данных
|
|
99
100
|
const redis = await RedisConnection_1.createRedisConnection.call(this, credentials, db);
|
|
100
101
|
redisConnections.set(db, redis);
|
|
102
|
+
// ДИАГНОСТИКА: Проверяем, что соединение использует правильную базу данных
|
|
103
|
+
try {
|
|
104
|
+
// Проверяем все ключи сразу после подключения
|
|
105
|
+
const testKeys = await redis.keys('*');
|
|
106
|
+
console.log(`[Chat2Crm Trigger] Test keys in DB ${db} after connection:`, testKeys);
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
console.error(`[Chat2Crm Trigger] Error checking keys in DB ${db}:`, error.message);
|
|
110
|
+
}
|
|
101
111
|
}
|
|
102
112
|
// Храним последние прочитанные ID для каждого stream
|
|
103
113
|
const lastReadIds = new Map();
|
|
@@ -106,10 +116,35 @@ class Chat2CrmTrigger {
|
|
|
106
116
|
// Инициализируем lastReadIds для каждого stream и собираем информацию
|
|
107
117
|
for (const [db, dbStreams] of streamsByDb.entries()) {
|
|
108
118
|
const redis = redisConnections.get(db);
|
|
119
|
+
// ИСПРАВЛЕНИЕ: Явно выбираем базу данных перед проверкой stream'ов
|
|
120
|
+
try {
|
|
121
|
+
const selectResult = await redis.select(db);
|
|
122
|
+
console.log(`[Chat2Crm Trigger] SELECT ${db} result:`, selectResult);
|
|
123
|
+
// ДИАГНОСТИКА: Проверяем все stream'ы через SCAN
|
|
124
|
+
const streamKeys = [];
|
|
125
|
+
let cursor = '0';
|
|
126
|
+
do {
|
|
127
|
+
const [nextCursor, keys] = await redis.scan(cursor, 'MATCH', '*', 'COUNT', 100);
|
|
128
|
+
cursor = nextCursor;
|
|
129
|
+
for (const key of keys) {
|
|
130
|
+
const keyType = await redis.type(key);
|
|
131
|
+
if (keyType === 'stream') {
|
|
132
|
+
streamKeys.push(key);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
} while (cursor !== '0');
|
|
136
|
+
console.log(`[Chat2Crm Trigger] Found ${streamKeys.length} streams in DB ${db}:`, streamKeys);
|
|
137
|
+
console.log(`[Chat2Crm Trigger] Looking for:`, dbStreams);
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
console.error(`[Chat2Crm Trigger] Failed to select DB ${db}:`, error.message);
|
|
141
|
+
}
|
|
109
142
|
for (const stream of dbStreams) {
|
|
110
143
|
try {
|
|
144
|
+
console.log(`[Chat2Crm Trigger] Checking stream "${stream}" in DB ${db}`);
|
|
111
145
|
// Пытаемся получить информацию о stream
|
|
112
146
|
const streamInfo = await redis.xinfo('STREAM', stream);
|
|
147
|
+
console.log(`[Chat2Crm Trigger] Stream "${stream}" found! Info:`, streamInfo);
|
|
113
148
|
if (streamInfo && Array.isArray(streamInfo)) {
|
|
114
149
|
// Ищем 'last-entry' в информации о stream
|
|
115
150
|
const lastEntryIndex = streamInfo.indexOf('last-entry');
|
|
@@ -188,14 +188,10 @@ async function createRedisConnection(credentials, db = 0) {
|
|
|
188
188
|
});
|
|
189
189
|
redis.on('ready', async () => {
|
|
190
190
|
console.log(`[Redis Connection] Redis ready at ${redisHost}:${redisPort}, DB ${selectedDb}`);
|
|
191
|
-
//
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
}
|
|
196
|
-
catch (error) {
|
|
197
|
-
console.error(`[Redis Connection] Failed to select DB ${selectedDb}:`, error.message);
|
|
198
|
-
}
|
|
191
|
+
// УБИРАЕМ select - он не нужен, так как db уже указан в конфигурации
|
|
192
|
+
// И вызов select после ready может вызвать проблемы, если проверка stream'ов уже началась
|
|
193
|
+
// await redis.select(selectedDb);
|
|
194
|
+
// console.log(`[Redis Connection] Explicitly selected DB ${selectedDb}`);
|
|
199
195
|
});
|
|
200
196
|
redis.on('error', (err) => {
|
|
201
197
|
console.error(`[Redis Connection] Redis error on ${redisHost}:${redisPort}, DB ${selectedDb}:`, err.message);
|