Baileys: [BUG] Unable to download SAVED sticker from whatsapp AXIOS error
Describe the bug
When trying to download media, it works when downloading GIF (mp4) video files but when it’s a sticker the downloadMediaMessage
function throws an error.
To Reproduce Steps to reproduce the behavior:
- Created a new connection
- listen for messages
- on
message.upsert
try to download the sticker
Expected behavior The stiker image should be downloaded.
Environment (please complete the following information):
- Is this on a server?
NO
It’s my developement machine - What do your
connectOptions
look like?
const NAME_DIR_SESSION = `${this.globalVendorArgs.name}_sessions`
const { state, saveCreds } = await useMultiFileAuthState(NAME_DIR_SESSION)
const loggerBaileys = pino({ level: 'fatal' })
this.saveCredsGlobal = saveCreds
const sock = makeWASocket({
logger: loggerBaileys,
printQRInTerminal: false,
auth: {
creds: state.creds,
keys: makeCacheableSignalKeyStore(
state.keys,
loggerBaileys
),
},
browser: ['Chrome (Linux)', '', ''],
syncFullHistory: false,
generateHighQualityLinkPreview: true,
})
- Do you have multiple clients on the same IP?
NO
- Are you using a proxy?
NO
Additional context Here is where I try to download the image:
let contentType, file_type
if (message?.videoMessage?.mimetype) {
contentType = message?.videoMessage?.mimetype
file_type = 'video'
}
if (message?.stickerMessage?.mimetype) {
contentType = message?.stickerMessage?.mimetype
file_type = 'image'
}
const buffer = await downloadMediaMessage(
ctx,
'buffer',
{},
{
reuploadRequest: provider.updateMediaMessage,
}
).catch((e) => console.log(e))
Here is the error output:
AxiosError: getaddrinfo ENOTFOUND web.whatsapp.net
at AxiosError.from (file:///home/roberto/viko/only-bots/node_modules/.pnpm/axios@1.5.1/node_modules/axios/lib/core/AxiosError.js:89:14)
at RedirectableRequest.handleRequestError (file:///home/roberto/viko/only-bots/node_modules/.pnpm/axios@1.5.1/node_modules/axios/lib/adapters/http.js:593:25)
at RedirectableRequest.emit (node:events:514:28)
at eventHandlers.<computed> (/home/roberto/viko/only-bots/node_modules/.pnpm/follow-redirects@1.15.3/node_modules/follow-redirects/index.js:14:24)
at ClientRequest.emit (node:events:514:28)
at TLSSocket.socketErrorListener (node:_http_client:495:9)
at TLSSocket.emit (node:events:514:28)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
hostname: 'web.whatsapp.net',
syscall: 'getaddrinfo',
code: 'ENOTFOUND',
errno: -3008,
config: {
transitional: {
silentJSONParsing: true,
forcedJSONParsing: true,
clarifyTimeoutError: false
},
adapter: [ 'xhr', 'http' ],
transformRequest: [ [Function: transformRequest] ],
transformResponse: [ [Function: transformResponse] ],
timeout: 0,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: Infinity,
maxBodyLength: Infinity,
env: { FormData: [Function], Blob: [class Blob] },
validateStatus: [Function: validateStatus],
headers: Object [AxiosHeaders] {
Accept: 'application/json, text/plain, */*',
'Content-Type': undefined,
Origin: 'https://web.whatsapp.com',
'User-Agent': 'axios/1.5.1',
'Accept-Encoding': 'gzip, compress, deflate, br'
},
responseType: 'stream',
method: 'get',
url: 'https://web.whatsapp.net',
data: undefined
},
request: <ref *1> Writable {
_writableState: WritableState {
state: 802924,
highWaterMark: 16384,
defaultEncoding: 'utf8',
length: 0,
corked: 0,
onwrite: [Function: bound onwrite],
writecb: null,
writelen: 0,
afterWriteTickInfo: null,
buffered: [],
bufferedIndex: 0,
pendingcb: 0,
errored: null,
[Symbol(kOnFinished)]: []
},
_events: [Object: null prototype] {
response: [Function: handleResponse],
error: [Function: handleRequestError],
socket: [Function: handleRequestSocket]
},
_eventsCount: 3,
_maxListeners: undefined,
_options: {
maxRedirects: 21,
maxBodyLength: Infinity,
protocol: 'https:',
path: '/',
method: 'GET',
headers: [Object: null prototype],
agents: [Object],
auth: undefined,
family: undefined,
beforeRedirect: [Function: dispatchBeforeRedirect],
beforeRedirects: [Object],
hostname: 'web.whatsapp.net',
port: '',
agent: undefined,
nativeProtocols: [Object],
pathname: '/'
},
_ended: true,
_ending: true,
_redirectCount: 0,
_redirects: [],
_requestBodyLength: 0,
_requestBodyBuffers: [],
_onNativeResponse: [Function (anonymous)],
_currentRequest: ClientRequest {
_events: [Object: null prototype],
_eventsCount: 7,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
destroyed: false,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: true,
maxRequestsOnConnectionReached: false,
_defaultKeepAlive: true,
useChunkedEncodingByDefault: false,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
strictContentLength: false,
_contentLength: 0,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
_closed: false,
socket: [TLSSocket],
_header: 'GET / HTTP/1.1\r\n' +
'Accept: application/json, text/plain, */*\r\n' +
'Origin: https://web.whatsapp.com\r\n' +
'User-Agent: axios/1.5.1\r\n' +
'Accept-Encoding: gzip, compress, deflate, br\r\n' +
'Host: web.whatsapp.net\r\n' +
'Connection: keep-alive\r\n' +
'\r\n',
_keepAliveTimeout: 0,
_onPendingData: [Function: nop],
agent: [Agent],
socketPath: undefined,
method: 'GET',
maxHeaderSize: undefined,
insecureHTTPParser: undefined,
joinDuplicateHeaders: undefined,
path: '/',
_ended: false,
res: null,
aborted: false,
timeoutCb: [Function: emitRequestTimeout],
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
reusedSocket: false,
host: 'web.whatsapp.net',
protocol: 'https:',
_redirectable: [Circular *1],
[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://web.whatsapp.net/',
[Symbol(kCapture)]: false
},
cause: Error: getaddrinfo ENOTFOUND web.whatsapp.net
at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:118:26) {
errno: -3008,
code: 'ENOTFOUND',
syscall: 'getaddrinfo',
hostname: 'web.whatsapp.net'
}
}
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Comments: 15
I was able to resolve using:
I was able to download stickers too normally, but, there is an exception: