Skip to content

Bad HTTP 503 On Proxied Hook Request #737

@hiddenalpha

Description

@hiddenalpha

How To Reproduce

Start gateleen instance (I used paisa/eagle @ 03.00.22.00, but also reproduces with gateleen-playground).

Setup two terminals with nodejs available.

In 1st, run node reproduce.js --zaphod (see attachments further down). This will start a http server at 7080 which sets a hook on the gateleen at localhost:7012 to itself.

(optional, but recommended) Start tcpdump (or wireshark) with port 7012 to see what is going on.

In 2nd, run node reproduce.js --slarti. This emulates a client performing two HTTP requests to that same gateleen, which then should get routed to the --zaphod mock server.

Expected Outcome: Both slarti requests receive a HTTP 200 OK with the small example response.

Actual Outcome: One of the requests (usually the 2nd one) fails with HTTP 502 Bad Gateway.

A Few Details

About the situation:

  • There's a gateleen instance running.
  • There's a service which places its service hook on that gateleen. (see my --zaphod mock).
  • There's a client, doing multiple requests intended for that other (zaphod) server.
  • gateleen now should proxy those requests to zaphod and then hand back the results to slarti.

Here what I've observed:

Image

Client (slarti) gets 200 for its 1st request, but a 502 for its 2nd request. This is because gateleen tries to re-use the upstream connection which got closed in the previous request-response cycle. This connection re-use MUST NOT happen. Fiddling around with logging, I was able to get this message in the logs:

Image

So obviously gateleen at some point realizes that the connection is closed. But this is already too late. Nevertheless gateleen MUST recognize this earlier, as upstream response clearly announces the closing via Connection: close header and therefore MUST NOT re-use that connection.

Also worth noting:

When creating a plain vertx app with similar configuration, it is impossible to reproduce the bug. Vertx always behaves exactly as it should. Looks like eagle/gateleen/friends do something ugly somewhere.

More detailed analysis is available in SDCISA-22791 (not publicly available unfortunately).

Attachments

reproduce.js.gz.b64

H4sIAAAAAAAAA81Y3XPbNhJ/lv+KDR8aKpYokbnWqXR+4NmK7TSx3Eip0zadDixBEh2KYAnIsuPqf79dgN+ic725Ppw9oyGB3cV
+7w8c2otNNFOBiOz248HBTERSwUTMPnMFx5DwPzZBwm0r4spqO2Z9mFKtlIorNGLOB7RotTMSfh+QmDgRMy6lQ6/ZllRzniSlTb
MwPOj1DMGSq0uxHcWz1TuJZKdMc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FzUtgrcg3SrMDJDNxz5IGCIRWX
MZRgV5mhVjqjy/F08uEqcyp9zLLdBsesWWBgo/lMRS46hvHNLbYRRJ8s1DdYA0es/Hqqb54Gixz1XY/eMrsGxmSzZFQtLcl0QV/
xdEgHEG3CsJO9e7V3XVn5tTkvpGxlRz9f0oMfi+8TR/1XfcOhAXQhlBg0PKBKZcnyrvRNj15xZ0HXP9oOfNx0YUgP/9TEWX0OET
/hYt4VcI8qHil+DfzfsionfhLwzTeAYwJPmW9mvOcoupohbTu96RKeDaINH2K5B8tIJNTYAon9jpvrdJEOdAwOlW53xcPYSvlL3
+qGJQzXxJZ+N0gZq2muc/gpRhO3KmOW5VVGE9nyF0hrdHH5k//WTLWkfFsrZSW1qF1DlaDv9ougWfwJiyKhADGDHhtikcE9hu3G
WA7MfFeULJ0ZTlN9mG98dTWe/VU93tFnCDxdxDxhpsYCKRHENB9Gnam4X5lypG+xO5sug/8GSAqVP/IWAAA=

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions