waha icon indicating copy to clipboard operation
waha copied to clipboard

[Gows] - POST /api/sendFile to send a PDF document via WAHA, the API returns 500 Internal Server Error

Open Hardeep-indigital opened this issue 9 months ago • 11 comments

When calling POST /api/sendFile to send a PDF document via WAHA, the API returns 500 Internal Server Error with a gRPC error:

2 UNKNOWN: failed to execute request:
Post "https://media-bom2-1.cdn.whatsapp.net/mms/document/...":
write tcp <internal-ip>:<port>-><remote-ip>:443:
write: connection reset by peer

Important:

  • Sending image files works correctly.
  • The issue occurs only when sending PDF documents.

Version

Output of GET /api/version:

{
  "version": "2026.1.4",
  "engine": "GOWS",
  "tier": "PLUS",
  "browser": null,
  "platform": "linux/x64",
  "worker": {
    "id": null
  }
}

Request Payload

POST /api/sendFile

{
  "chatId": "<redacted>@c.us",
  "file": {
    "mimetype": "application/pdf",
    "filename": "filename.pdf",
    "url": "https://<my-domain-redacted>/path/to/file.pdf"
  },
  "reply_to": null,
  "caption": "string",
  "session": "<redacted>"
}

Response

{
  "statusCode": 500,
  "exception": {
    "message": "2 UNKNOWN: failed to execute request: Post \"https://media-bom2-1.cdn.whatsapp.net/...\": write: connection reset by peer",
    "code": 2,
    "details": "connection reset by peer"
  }
}

Stack Trace Location

Failure occurs during:

  • WhatsappSessionGoWSPlus.sendMedia
  • WhatsappSessionGoWSPlus.sendFile

Expected Behavior

PDF file should upload successfully to WhatsApp CDN and return a valid message response (same behavior as image uploads).

Hardeep-indigital avatar Feb 20 '26 03:02 Hardeep-indigital

Might be related to a similar problem I'm encountering trying to send videos (I get the same error message). I was able to send by reducing the video size to ~1Mb, larger files fail.

AlexGoldovsky avatar Feb 21 '26 15:02 AlexGoldovsky

@AlexGoldovsky I tried sending a file <1MB, but nothing changed. :(

Hardeep-indigital avatar Feb 21 '26 15:02 Hardeep-indigital

same problem here and tried many things without succcess

priscillienMei avatar Feb 22 '26 10:02 priscillienMei

Hi! Could you try it now? It could be some WA outage

patron:PRO

devlikepro avatar Feb 24 '26 05:02 devlikepro

Same problem.

patron:PLUS

dhyegocalota avatar Feb 24 '26 08:02 dhyegocalota

@devlikepro Double checked and it is still happening.

AlexGoldovsky avatar Feb 24 '26 12:02 AlexGoldovsky

Hi! Could you try dev image?

Make sure to select the engine via the environment variable - WHATSAPP_DEFAULT_ENGINE=GOWS:

  • devlikeapro/waha-plus:dev
  • devlikeapro/waha-plus:dev-chrome
  • devlikeapro/waha-plus:dev-arm

patron:PRO

devlikepro avatar Feb 25 '26 03:02 devlikepro

@devlikepro did not work.

[06:51:59.043] INFO (7): request errored {"reqId":162,"req":{"id":162,"method":"POST","url":"/api/sendVoice","query":{},"params":{"path":["api","sendVoice"]}},"res":{"statusCode":500},"responseTime":14405}
err: {
"type": "Error",
"message": "2 UNKNOWN: failed to execute request: Post \"https://media-gru1-1.cdn.whatsapp.net/mms/audio/6MOKERyIyB6CL0f8ll90V1T6zH0NPfWqzuTE8NiEjPU=?auth=Ac1cBL3_zwq4bR-R4okRjA6qs7Y4Cs2qN6-iO1hcDmRtuQ&token=6MOKERyIyB6CL0f8ll90V1T6zH0NPfWqzuTE8NiEjPU%3D\": write tcp 172.18.0.15:43972->157.240.222.60:443: write: connection reset by peer",
"stack":
Error: 2 UNKNOWN: failed to execute request: Post "https://media-gru1-1.cdn.whatsapp.net/mms/audio/6MOKERyIyB6CL0f8ll90V1T6zH0NPfWqzuTE8NiEjPU=?auth=Ac1cBL3_zwq4bR-R4okRjA6qs7Y4Cs2qN6-iO1hcDmRtuQ&token=6MOKERyIyB6CL0f8ll90V1T6zH0NPfWqzuTE8NiEjPU%3D": write tcp 172.18.0.15:43972->157.240.222.60:443: write: connection reset by peer
at callErrorFromStatus (/app/node_modules/@grpc/grpc-js/build/src/call.js:32:19)
at Object.onReceiveStatus (/app/node_modules/@grpc/grpc-js/build/src/client.js:193:76)
at Object.onReceiveStatus (/app/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:367:141)
at Object.onReceiveStatus (/app/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:327:181)
at /app/node_modules/@grpc/grpc-js/build/src/resolving-call.js:135:78
at process.processTicksAndRejections (node:internal/process/task_queues:84:11)
for call at
at MessageServiceClient.makeUnaryRequest (/app/node_modules/@grpc/grpc-js/build/src/client.js:161:32)
at MessageServiceClient.SendMessage (/app/node_modules/@grpc/grpc-js/build/src/make-client.js:105:19)
at MessageServiceClient.SendMessage (/app/dist/core/engines/gows/grpc/gows.js:10456:30)
at node:internal/util:495:21
at new Promise (<anonymous>)
at node:internal/util:481:12
at /app/dist/plus/engines/gows/session.gows.plus.js:195:82
at async TmpDir.use (/app/dist/utils/tmpdir.js:22:20)
at async WhatsappSessionGoWSPlus.sendMedia (/app/dist/plus/engines/gows/session.gows.plus.js:185:16)
at async WhatsappSessionGoWSPlus.sendVoice (/app/dist/plus/engines/gows/session.gows.plus.js:207:16)
at async descriptor.value (/app/dist/core/abc/activity.js:9:20)
"code": 2,
"details": "failed to execute request: Post \"https://media-gru1-1.cdn.whatsapp.net/mms/audio/6MOKERyIyB6CL0f8ll90V1T6zH0NPfWqzuTE8NiEjPU=?auth=Ac1cBL3_zwq4bR-R4okRjA6qs7Y4Cs2qN6-iO1hcDmRtuQ&token=6MOKERyIyB6CL0f8ll90V1T6zH0NPfWqzuTE8NiEjPU%3D\": write tcp 172.18.0.15:43972->157.240.222.60:443: write: connection reset by peer",
"metadata": {
"content-type": [
"application/grpc"
]
}
}

patron:PLUS

dhyegocalota avatar Feb 25 '26 09:02 dhyegocalota

Working with waha plus dev

patron:PLUS

priscillienMei avatar Feb 25 '26 17:02 priscillienMei

seems to work on waha plus dev.

AlexGoldovsky avatar Feb 28 '26 08:02 AlexGoldovsky

looks like

{ "class": "APIError", "request": { "method": "POST", "url": "/api/sendImage", "body": "{"session":"IA24HS_COMERCIAL","caption":"","chatId":"278275329@lid","file":{"url":"https://xxxx/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBekZGQkE9PSIsImV4cCI6bnVsbCwicHVyIjoiYmxvYl9pZCJ9fQ==--b5d0e5ed432dbec7ebca07a3a58061be60ec9430/image.png","mimetype":"image/png"},"mentions":null}" }, "response": { "status": 500, "statusText": "Internal Server Error", "headers": { "x-powered-by": "Express", "access-control-allow-origin": "*", "content-type": "application/json; charset=utf-8", "content-length": "2368", "etag": "W/"940-GatTmozlXVNemztn9c"", "date": "Wed, 03 Jun 2026 19:00:28 GMT", "connection": "keep-alive", "keep-alive": "timeout=5" }, "body": { "statusCode": 500, "timestamp": "2026-06-03T19:00:28.607Z", "exception": { "message": "2 UNKNOWN: failed to refresh media connections: failed to query media connections: websocket not connected", "code": 2, "details": "failed to refresh media connections: failed to query media connections: websocket not connected", "metadata": {}, "name": "Error", "stack": "Error: 2 UNKNOWN: failed to refresh media connections: failed to query media connections: websocket not connected\n at callErrorFromStatus (/app/node_modules/@grpc/grpc-js/build/src/call.js:32:19)\n at Object.onReceiveStatus (/app/node_modules/@grpc/grpc-js/build/src/client.js:193:76)\n at Object.onReceiveStatus (/app/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:367:141)\n at Object.onReceiveStatus (/app/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:327:181)\n at /app/node_modules/@grpc/grpc-js/build/src/resolving-call.js:135:78\n at process.processTicksAndRejections (node:internal/process/task_queues:84:11)\nfor call at\n at MessageServiceClient.makeUnaryRequest (/app/node_modules/@grpc/grpc-js/build/src/client.js:161:32)\n at MessageServiceClient.SendMessage (/app/node_modules/@grpc/grpc-js/build/src/make-client.js:105:19)\n at MessageServiceClient.SendMessage (/app/dist/core/engines/gows/grpc/gows.js:10542:30)\n at node:internal/util:495:21\n at new Promise ()\n at node:internal/util:481:12\n at /app/dist/plus/engines/gows/session.gows.plus.js:212:82\n at async TmpDir.use (/app/dist/utils/tmpdir.js:22:20)\n at async WhatsappSessionGoWSPlus.sendMedia (/app/dist/plus/engines/gows/session.gows.plus.js:202:16)\n at async WhatsappSessionGoWSPlus.sendImage (/app/dist/plus/engines/gows/session.gows.plus.js:218:16)\n at async descriptor.value (/app/dist/core/abc/activity.js:9:20)" }, "request": { "path": "/api/sendImage", "method": "POST", "body": { "session": "IA24, "caption": "", "chatId": "2782753629@lid", "file": { "url": "https://p/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBBekZGQkE9PSIsImV4cCI6bnVsbCwicHVyIjoiYmxvYl9pZCJ9fQ==--b5d0e5ed432dbec7ebca07a3a58061be60ec9430/image.png", "mimetype": "image/png" }, "mentions": null }, "query": {} }, "version": { "version": "2026.5.1", "engine": "GOWS", "tier": "PLUS", "browser": null, "platform": "linux/x64", "worker": { "id": null } } } } }

brunocicom avatar Jun 03 '26 19:06 brunocicom