WhatsApp Bot on Railway Metal: Frequent Connection Timeouts to Facebook Graph API

farreldarianPRO

18 days ago

Hi team,

I am currently building a WhatsApp bot and facing an issue where it frequently encounters a "Connection Timeout" error when communicating with Facebook's API (`graph.facebook.com`). This problem occurs while the service is running on Railway Metal in Singapore.

Here's the error log for more detail

{
  "severity": "info",
  "timestamp": "2025-05-21T05:52:58.923619212Z",
  "tags": {
    "deploymentId": "033c2fe7-7508-479b-ad79-d49528829b45",
    "deploymentInstanceId": "8f6838bb-47cb-4f73-b961-b09c3f58c882",
    "environmentId": "5b79bd83-29de-481c-9907-e1758c9c0507",
    "pluginId": null,
    "projectId": "eddcba0a-2e58-4632-9cc6-a4f409485714",
    "serviceId": "701ddde2-9e5b-40fa-b0e1-e653d47335c7",
    "snapshotId": null
  },
  "attributes": {
    "error": {
      "cause": {
        "cause": {
          "aggregateErrors": [
            {
              "address": "157.240.22.19",
              "code": "ETIMEDOUT",
              "errno": -110,
              "message": "connect ETIMEDOUT 157.240.22.19:443",
              "port": 443,
              "stack": "aError: aconnect ETIMEDOUT 157.240.22.19:443\n    at createConnectionError (node:net:1677:14)\n    at Timeout.internalConnectMultipleTimeout (node:net:1736:38)\n    at listOnTimeout (node:internal/timers:610:11)\n    at process.processTimers (node:internal/timers:543:7)",
              "syscall": "connect",
              "type": "Error"
            },
            {
              "address": "2a03:2880:f031:12:face:b00c:0:2",
              "code": "ENETUNREACH",
              "errno": -101,
              "message": "connect ENETUNREACH 2a03:2880:f031:12:face:b00c:0:2:443 - Local (:::0)",
              "port": 443,
              "stack": "Error: connect ENETUNREACH 2a03:2880:f031:12:face:b00c:0:2:443 - Local (:::0)\n    at internalConnectMultiple (node:net:1211:16)\n    at Timeout.internalConnectMultipleTimeout (node:net:1741:5)\n    at listOnTimeout (node:internal/timers:610:11)\n    at process.processTimers (node:internal/timers:543:7)",
              "syscall": "connect",
              "type": "Error"
            }
          ],
          "code": "ETIMEDOUT",
          "message": "",
          "stack": "AggregateError [ETIMEDOUT]: \n    at internalConnectMultiple (node:net:1139:18)\n    at internalConnectMultiple (node:net:1215:5)\n    at Timeout.internalConnectMultipleTimeout (node:net:1741:5)\n    at listOnTimeout (node:internal/timers:610:11)\n    at process.processTimers (node:internal/timers:543:7)",
          "type": "AggregateError"
        },
        "message": "fetch failed",
        "type": "TypeError"
      },
      "message": "Failed to send WhatsApp message",
      "type": "Error"
    },
    "hostname": "b7b98e89819b",
    "level": "info",
    "pid": 67,
    "time": 1747806778916
  }
}
$10 Bounty

3 Replies

18 days ago

This seems to be something wrong with railway's egress. Can you SSH into your deployment and ping and traceroute to graph.facebook.com?


17 days ago

The dual error (timeout on IPv4, unreachable on IPv6) suggests the host can’t reach Facebook at all, not just a slow response.

To check this run a test from a shell: curl -v https://graph.facebook.com/

Also try changing the metal region to see if it works.

If it doesn't open a Direct Support ticket through your BM and they should help you troubleshoot.


testuser123

The dual error (timeout on IPv4, unreachable on IPv6) suggests the host can’t reach Facebook at all, not just a slow response.To check this run a test from a shell: curl -v https://graph.facebook.com/Also try changing the metal region to see if it works.If it doesn't open a Direct Support ticket through your BM and they should help you troubleshoot.

farreldarianPRO

17 days ago

Yes, I'm currently running in the Netherlands. But it would waste unnecessary latency in the long term.