EvolutionAPI / evolution-api

Evolution API is an open-source WhatsApp integration API
https://evolution-api.com
GNU General Public License v3.0
1.41k stars 673 forks source link

Typebot open session AxiosError #788

Open marioalexandreantunes opened 3 weeks ago

marioalexandreantunes commented 3 weeks ago

Bem-vido!

O que você fez?

Quando o evolution tenta iniciar uma sessão no typebot. Só recebe após a segunda mensagem do usuário.

O que você esperava?

que abrisse sessão e typebot recebesse a mensagem.

O que vc observou ao invés do que esperava?

nada só quando o usuário digita a segunda mensagem é que o typebot responde.

Capturas de Tela/Vídeos

No response

Qual versão da API você está usando?

2.0.9-rc

Qual é o seu ambiente?

Windows

Outras expecificações do ambiente

VPS 4 vCPU Cores 6 GB RAM 1 Snapshot 100 GB NVMe Ubuntu 22.04

Se aplicável, cole a saída do log

[Evolution API]    v2.0.9-rc  126   -  Fri Aug 16 2024 15:36:02     LOG   [TypebotService]  [string]  Debounce complete. Processing message: Olá, preciso de saber qual o melhor anti malware 
[Evolution API]    v2.0.9-rc  126   -  Fri Aug 16 2024 15:36:07     ERROR   [TypebotService]  [object]   
AxiosError: getaddrinfo EAI_AGAIN bot.XXXXX.XXXXX
    at AxiosError.from (/evolution/node_modules/axios/dist/node/axios.cjs:873:14)
    at RedirectableRequest.handleRequestError (/evolution/node_modules/axios/dist/node/axios.cjs:3152:25)
    at RedirectableRequest.emit (node:events:519:28)
    at eventHandlers.<computed> (/evolution/node_modules/follow-redirects/index.js:38:24)
    at ClientRequest.emit (node:events:519:28)
    at TLSSocket.socketErrorListener (node:_http_client:500:9)
    at TLSSocket.emit (node:events:519:28)
    at emitErrorNT (node:internal/streams/destroy:169:8)
    at emitErrorCloseNT (node:internal/streams/destroy:128:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
    at Axios.request (/evolution/node_modules/axios/dist/node/axios.cjs:4262:41)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  hostname: 'bot.XXXXX.XXXXX',
  syscall: 'getaddrinfo',
  code: 'EAI_AGAIN',
  errno: -3001,
  config: {
    transitional: {
      silentJSONParsing: true,
      forcedJSONParsing: true,
      clarifyTimeoutError: false
    },
    adapter: [ 'xhr', 'http', 'fetch' ],
    transformRequest: [ [Function: transformRequest] ],
    transformResponse: [ [Function: transformResponse] ],
    timeout: 0,
    xsrfCookieName: 'XSRF-TOKEN',
    xsrfHeaderName: 'X-XSRF-TOKEN',
    maxContentLength: -1,
    maxBodyLength: -1,
    env: { FormData: [Function], Blob: [class Blob] },
    validateStatus: [Function: validateStatus],
    headers: Object [AxiosHeaders] {
      Accept: 'application/json, text/plain, */*',
      'Content-Type': 'application/json',
      'User-Agent': 'axios/1.7.3',
      'Content-Length': '225',
      'Accept-Encoding': 'gzip, compress, deflate, br'
    },
    method: 'post',
    url: 'https://bot.xxxxxx.xxxxxx/api/v1/typebots/ma-whats-app-xxxxxxx/startChat',
    data: '{"prefilledVariables":{"remoteJid":"XXXXXXXXXX@s.whatsapp.net","pushName":"mário ANTUNES","instanceName":"XXXXXX","serverUrl":"https://api.XXXXX.XXXXX","apiKey":"XXXXXXXX","ownerJid":"XXXXXXXX"}}'
  },
  request: <ref *1> Writable {
    _events: {
      close: undefined,
      error: [Function: handleRequestError],
      prefinish: undefined,
      finish: undefined,
      drain: undefined,
      response: [Function: handleResponse],
      socket: [Function: handleRequestSocket]
    },
    _writableState: WritableState {
      highWaterMark: 16384,
      length: 0,
      corked: 0,
      onwrite: [Function: bound onwrite],
      writelen: 0,
      bufferedIndex: 0,
      pendingcb: 0,
      [Symbol(kState)]: 17580812,
      [Symbol(kBufferedValue)]: null
    },
    _maxListeners: undefined,
    _options: {
      maxRedirects: 21,
      maxBodyLength: Infinity,
      protocol: 'https:',
      path: '/api/v1/typebots/ma-whats-app-xxxxxxxx/startChat',
      method: 'POST',
      headers: [Object: null prototype],
      agents: [Object],
      auth: undefined,
      family: undefined,
      beforeRedirect: [Function: dispatchBeforeRedirect],
      beforeRedirects: [Object],
      hostname: 'bot.XXXXX.XXXXX',
      port: '',
      agent: undefined,
      nativeProtocols: [Object],
      pathname: '/api/v1/typebots/ma-whats-app-xxxxxxx/startChat'
    },
    _ended: false,
    _ending: true,
    _redirectCount: 0,
    _redirects: [],
    _requestBodyLength: 225,
    _requestBodyBuffers: [ [Object] ],
    _eventsCount: 3,
    _onNativeResponse: [Function (anonymous)],
    _currentRequest: ClientRequest {
      _events: [Object: null prototype],
      _eventsCount: 7,
      _maxListeners: undefined,
      outputData: [],
      outputSize: 0,
      writable: true,
      destroyed: false,
      _last: false,
      chunkedEncoding: false,
      shouldKeepAlive: true,
      maxRequestsOnConnectionReached: false,
      _defaultKeepAlive: true,
      useChunkedEncodingByDefault: true,
      sendDate: false,
      _removedConnection: false,
      _removedContLen: false,
      _removedTE: false,
      strictContentLength: false,
      _contentLength: '225',
      _hasBody: true,
      _trailer: '',
      finished: false,
      _headerSent: true,
      _closed: false,
      socket: [TLSSocket],
      _header: 'POST /api/v1/typebots/ma-whats-app-XXXXXXX/startChat HTTP/1.1\r\n' +
        'Accept: application/json, text/plain, */*\r\n' +
        'Content-Type: application/json\r\n' +
        'User-Agent: axios/1.7.3\r\n' +
        'Content-Length: 225\r\n' +
        'Accept-Encoding: gzip, compress, deflate, br\r\n' +
        'Host: bot.XXXXXX.XXXXXXX\r\n' +
        'Connection: keep-alive\r\n' +
        '\r\n',
      _keepAliveTimeout: 0,
      _onPendingData: [Function: nop],
      agent: [Agent],
      socketPath: undefined,
      method: 'POST',
      maxHeaderSize: undefined,
      insecureHTTPParser: undefined,
      joinDuplicateHeaders: undefined,
      path: '/api/v1/typebots/ma-whats-app-XXXXXX/startChat',
      _ended: false,
      res: null,
      aborted: false,
      timeoutCb: [Function: emitRequestTimeout],
      upgradeOrConnect: false,
      parser: null,
      maxHeadersCount: null,
      reusedSocket: false,
      host: 'bot.XXXXXXX.XXXXXX',
      protocol: 'https:',
      _redirectable: [Circular *1],
      [Symbol(shapeMode)]: false,
      [Symbol(kCapture)]: false,
      [Symbol(kBytesWritten)]: 0,
      [Symbol(kNeedDrain)]: false,
      [Symbol(corked)]: 0,
      [Symbol(kOutHeaders)]: [Object: null prototype],
      [Symbol(errored)]: null,
      [Symbol(kHighWaterMark)]: 16384,
      [Symbol(kRejectNonStandardBodyWrites)]: false,
      [Symbol(kUniqueHeaders)]: null
    },
    _currentUrl: 'https://bot.XXXX.XXXX/api/v1/typebots/ma-whats-app-XXXXXX/startChat',
    [Symbol(shapeMode)]: true,
    [Symbol(kCapture)]: false
  },
  cause: Error: getaddrinfo EAI_AGAIN bot.XXXXXXX.XXXX
      at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:120:26) {
    errno: -3001,
    code: 'EAI_AGAIN',
    syscall: 'getaddrinfo',
    hostname: 'bot.XXXXXX.XXXX'
  }
} 
[Evolution API]    v2.0.9-rc  126   -  Fri Aug 16 2024 15:36:07     ERROR   [unhandledRejection]  [object]   
{
  origin: Promise {
    <rejected> TypeError: Cannot read properties of undefined (reading 'session')
        at TypebotService.<anonymous> (/evolution/dist/src/api/integrations/typebot/services/typebot.service.js:1399:30)
        at Generator.next (<anonymous>)
        at fulfilled (/evolution/dist/src/api/integrations/typebot/services/typebot.service.js:5:58)
        at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  },
      
  stderr: 2,
  error: TypeError: Cannot read properties of undefined (reading 'session')
      at TypebotService.<anonymous> (/evolution/dist/src/api/integrations/typebot/services/typebot.service.js:1399:30)
      at Generator.next (<anonymous>)
      at fulfilled (/evolution/dist/src/api/integrations/typebot/services/typebot.service.js:5:58)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
} 

Notas Adicionais

Instalação pelo OrionSetup 2.5.9

Portainer traefik:v2.11.2 redis:latest postgres:14 dify:latest baptistearno/typebot-builder:2.27.0 atendai/evolution-api:v2.0.9-rc

marioalexandreantunes commented 3 weeks ago

getaddrinfo EAI_AGAIN EAI_AGAIN is a DNS lookup timed out error, o que significa que se possivelmente se trata de um erro de conetividade de rede dns.

Mudei na vps dns atraves do netplan para 1.1.1.1 também já estou a usar v2.0.10 (mas não é da versão pois testei antes da mudança do dns/vps e tive o com mesmo erro)

No primeiro teste após reiniciar a VPS não houve o erro, ou seja na abertura de session, mas após 3 minutos :

[Evolution API]  [Avidsen]  v2.0.10  164   -  Fri Aug 16 2024 20:15:43     LOG   [ChannelStartupService]  [object]   
{
  key: {
    remoteJid: 'ZZZZZZZZ@s.whatsapp.net',
    fromMe: true,
    id: '7C8D1EE61561E96FF8',
    participant: undefined
  },
  pushName: 'mário ANTUNES',

  message: {
    extendedTextMessage: ExtendedTextMessage {
      text: 'obrigado',
      contextInfo: [ContextInfo]
    }
  },
  contextInfo: ContextInfo {
    mentionedJid: [],
    groupMentions: [],
    expiration: 0,
    ephemeralSettingTimestamp: Long { low: 0, high: 0, unsigned: false },
    disappearingMode: DisappearingMode { initiator: 0 }
  },
  messageType: 'extendedTextMessage',
  messageTimestamp: 1723850143,
  instanceId: '57bec2a4-de06-40e3-9f9a-13992512ad07',
  source: 'desktop'
} 

[Evolution API]    v2.0.10  164   -  Fri Aug 16 2024 20:15:43     WARN   [OpenaiService]  [string]  Session is already opened in another integration 
[Evolution API]    v2.0.10  164   -  Fri Aug 16 2024 20:15:43     WARN   [DifyService]  [string]  Session is already opened in another integration 
[Evolution API]    v2.0.10  164   -  Fri Aug 16 2024 20:15:44     LOG   [TypebotService]  [string]  Debounce complete. Processing message: obrigado 
[Evolution API]    v2.0.10  164   -  Fri Aug 16 2024 20:15:44     ERROR   [unhandledRejection]  [object]   
{
  origin: Promise {
    <rejected> TypeError: Cannot read properties of undefined (reading 'id')
        at et.getTypeMessage (/evolution/dist/main.js:133:44446)
        at et.getConversationMessage (/evolution/dist/main.js:133:45668)
        at et.processTypebot (/evolution/dist/main.js:142:4853)
        at async /evolution/dist/main.js:142:3899
  },

  stderr: 2,
  error: TypeError: Cannot read properties of undefined (reading 'id')
      at et.getTypeMessage (/evolution/dist/main.js:133:44446)
      at et.getConversationMessage (/evolution/dist/main.js:133:45668)
      at et.processTypebot (/evolution/dist/main.js:142:4853)
      at async /evolution/dist/main.js:142:3899
} 

tenho configurado : Expira em (minutos) : 2 Tempo de espera : 1 Mantem a sessão do bot aberta : Não

marioalexandreantunes commented 3 weeks ago

Agora testei na Hetzner (novo server), instalação limpa Ubuntu 22.04, só com portainer 2.19.5, traefik v2.11.2, postgresql 14, redis lasted e evolution 2.0.10.

[Evolution API]  [Mario Antunes]  v2.0.10  159   -  Sat Aug 17 2024 08:28:58     LOG   [ChannelStartupService]  [object]   
{
  key: {
    remoteJid: 'XXXXXXXXXX@s.whatsapp.net',
    fromMe: true,
    id: '2F0EAF33A28944F353',
    participant: undefined
  },
  pushName: 'mário ANTUNES',

  message: {
    extendedTextMessage: ExtendedTextMessage {
      text: 'Olá Bom Dia , preciso de ajuda com o meu pc',
      contextInfo: [ContextInfo]
    }
  },
  contextInfo: ContextInfo {
    mentionedJid: [],
    groupMentions: [],
    expiration: 0,
    ephemeralSettingTimestamp: Long { low: 0, high: 0, unsigned: false },
    disappearingMode: DisappearingMode { initiator: 0 }
  },
  messageType: 'extendedTextMessage',
  messageTimestamp: 1723894138,
  instanceId: 'f46bc1e2-a777-44b3-97b0-80306f488ce4',
  source: 'desktop'
} 

[Evolution API]    v2.0.10  159   -  Sat Aug 17 2024 08:28:59     WARN   [OpenaiService]  [string]  Session is already opened in another integration 
[Evolution API]    v2.0.10  159   -  Sat Aug 17 2024 08:28:59     WARN   [DifyService]  [string]  Session is already opened in another integration 
[Evolution API]    v2.0.10  159   -  Sat Aug 17 2024 08:29:00     LOG   [TypebotService]  [string]  Debounce complete. Processing message: Olá Bom Dia , preciso de ajuda com o meu pc 
[Evolution API]    v2.0.10  159   -  Sat Aug 17 2024 08:29:00     ERROR   [unhandledRejection]  [object]   
{
  origin: Promise {
    <rejected> TypeError: Cannot read properties of undefined (reading 'id')
        at et.getTypeMessage (/evolution/dist/main.js:133:44446)
        at et.getConversationMessage (/evolution/dist/main.js:133:45668)
        at et.processTypebot (/evolution/dist/main.js:142:4853)
        at async /evolution/dist/main.js:142:3899
  },

  stderr: 2,
  error: TypeError: Cannot read properties of undefined (reading 'id')
      at et.getTypeMessage (/evolution/dist/main.js:133:44446)
      at et.getConversationMessage (/evolution/dist/main.js:133:45668)
      at et.processTypebot (/evolution/dist/main.js:142:4853)
      at async /evolution/dist/main.js:142:3899
} 
JuanxCursed commented 1 week ago

Estou com o mesmo problema para atualizar a imagem do perfil de um grupo, no meu caso versão 1.8.2

JuanxCursed commented 1 week ago

O erro acontece pela própria collection da EvolutionApi no postman tbm: Basta setar o groupjId que o erro acontece.

image