Error: Socket hang up

I am getting occasional instances where Otto Webhooks get an error of “Failed to load resource: the server responded with a status of 400()”. The Otto logs have an entry for “error BadRequestError: Error: socket hang up. code: -2 - {“service”:“express-error-handler”}”.

Any ideas what may be causing this error?

I am running OttoFMS 4.10.3 & FMS 21.1.4.400

Hey Carl,

My suspicion is that OttoFMS is trying to call the data API during the webhook and it is hanging. Do you see any errors in any of the dapi logs?

-Kyle

Hi Kyle

The only errors I see in the fmdapi log are the attempts to login with an expired token. Subsequent DAPI requests seem to complete successfully.

Otto-error:
2025-05-06T15:48:29.725Z error BadRequestError: Error: socket hang up. code: -2 - {“service”:“express-error-handler”}
fmdapi:
2025-05-06 16:47:43.834 +0100 952 ERROR POST /fmi/data/vLatest/databases/xxx.fmp12/layouts/OttoReceiver/records 92
2025-05-06 16:47:44.017 +0100 0 INFO Tabulator POST /fmi/data/vLatest/databases/xxx.fmp12/sessions 118
2025-05-06 16:48:29.781 +0100 0 INFO Tabulator POST /fmi/data/vLatest/databases/xxx.fmp12/layouts/OttoReceiver/records 1259
2025-05-06 16:48:40.578 +0100 0 INFO Tabulator POST /fmi/data/vLatest/databases/xxx.fmp12/layouts/OttoReceiver/records 927

Otto-error:
2025-05-07T08:23:00.403Z error BadRequestError: Error: socket hang up. code: -2 - {“service”:“express-error-handler”}
fmdapi:
2025-05-07 09:22:32.460 +0100 952 ERROR POST /fmi/data/vLatest/databases/xxx.fmp12/layouts/OttoReceiver/records 92
2025-05-07 09:22:32.869 +0100 0 INFO Tabulator POST /fmi/data/vLatest/databases/xxx.fmp12/sessions 118
2025-05-07 09:24:10.572 +0100 0 INFO Tabulator POST /fmi/data/vLatest/databases/xxx.fmp12/layouts/OttoReceiver/records 1620

otto-error:
2025-05-13T13:21:27.516Z error BadRequestError: Error: socket hang up. code: -2 - {“service”:“express-error-handler”}
fmdapi:
2025-05-13 14:20:34.548 +0100 952 ERROR POST /fmi/data/vLatest/databases/xxx.fmp12/layouts/OttoReceiver/records 92
2025-05-13 14:20:34.727 +0100 0 INFO Tabulator POST /fmi/data/vLatest/databases/xxx.fmp12/sessions 118
2025-05-13 14:26:05.901 +0100 0 INFO Tabulator POST /fmi/data/vLatest/databases/xxx.fmp12/layouts/OttoReceiver/records 817

Otto-error:
2025-05-16T11:29:35.087Z error BadRequestError: Error: socket hang up. code: -2 - {“service”:“express-error-handler”}
fmdapi:
2025-05-16 12:29:28.547 +0100 952 ERROR POST /fmi/data/vLatest/databases/xxx.fmp12/layouts/OttoReceiver/records 92
2025-05-16 12:29:29.224 +0100 0 INFO Tabulator POST /fmi/data/vLatest/databases/xxx.fmp12/sessions 118
2025-05-16 12:31:13.804 +0100 0 INFO Tabulator POST /fmi/data/vLatest/databases/xxx.fmp12/layouts/OttoReceiver/records 817

Otto-error:
2025-05-19T11:53:32.192Z error BadRequestError: Error: socket hang up. code: -2 - {“service”:“express-error-handler”}
fmdapi:
2025-05-19 12:52:47.461 +0100 952 ERROR POST /fmi/data/vLatest/databases/xxx.fmp12/layouts/OttoReceiver/records 92
2025-05-19 12:52:47.646 +0100 0 INFO Tabulator POST /fmi/data/vLatest/databases/xxx.fmp12/sessions 118
2025-05-19 14:17:37.793 +0100 952 ERROR POST /fmi/data/vLatest/databases/xxx.fmp12/layouts/OttoReceiver/records 92

Otto-error:
2025-05-21T09:05:39.929Z error BadRequestError: Error: socket hang up. code: -2 - {“service”:“express-error-handler”}
fmdapi:
2025-05-21 10:04:55.349 +0100 952 ERROR POST /fmi/data/vLatest/databases/xxx.fmp12/layouts/OttoReceiver/records 92
2025-05-21 10:04:55.569 +0100 0 INFO Tabulator POST /fmi/data/vLatest/databases/xxx.fmp12/sessions 118
2025-05-21 10:17:29.231 +0100 0 INFO Tabulator POST /fmi/data/vLatest/databases/xxx.fmp12/layouts/OttoReceiver/records 525

Otto-error:
2025-05-21T10:24:28.527Z error BadRequestError: Error: socket hang up. code: -2 - {“service”:“express-error-handler”}
fmdapi:
2025-05-21 11:24:22.144 +0100 952 ERROR POST /fmi/data/vLatest/databases/xxx.fmp12/layouts/OttoReceiver/records 92
2025-05-21 11:24:22.342 +0100 0 INFO Tabulator POST /fmi/data/vLatest/databases/xxx.fmp12/sessions 118
2025-05-21 11:25:12.779 +0100 0 INFO Tabulator POST /fmi/data/vLatest/databases/xxx.fmp12/layouts/OttoReceiver/records 525

I do seem to get the error most frequently on the first time that a call is made to the webhook, ie. when a new token is needed. Don’t know if that is related.

Hope that helps.

Carl

Hi Kyle. Just wondering if you have any further thoughts on this issue?

Hey Carl,

Sorry for the delayed response, just got back from a vacation. It does look like the socket hang ups coincide with the calls to the data api after the refresh of the dapi token.

The flow in ottofms is essentially:

  1. It attempts to call the data api with the stored token (these are the first fall you’re seeing in the log)
  2. if that failed, it will refresh the token (this is the call to the session endpoint)
  3. Once it has a new token, it will try to call the data api again. This call seems to be missing in your logs, which is likely because the socket hangs up during it.

Have you tried restarting the Data API? sometimes that can solve instabilities like this

If you turn on the debug flag in OttoFMS and try this again, what shows up in the otto-debug.log around the time of the webhook coming in?

Thanks Carl!

-Kyle