skupperproject / skupper-proxy

A service for bridging cluster-local communication to a Skupper network
https://skupper.io/
Apache License 2.0
8 stars 5 forks source link

HTTP Requests with Header `If-Modified-Since` cause Internal Server Error #11

Closed sergerad closed 4 years ago

sergerad commented 4 years ago

Problem

HTTP requests with header If-Modified-Since cause 500 responses.

Examples

Success with no headers

$ curl http://35.224.180.141:5000/
<!doctype html><html lang="en"><head><meta charset="utf-8"/...

Failures with header

$ curl -f http://34.71.186.240:5000/ \                     
-H "If-Modified-Since: Mon, 18 Nov 2019 21:17:37 GMT"
curl: (22) The requested URL returned error: 500 Internal Server Error
$ curl http://34.71.186.240:5000/ \                     
-H "If-Modified-Since: Mon, 18 Nov 2019 21:17:37 GMT"
Could not deliver request

Logs

Skupper Proxy instance shows this every time such a request is made:

Could not deliver request
(node:1) UnhandledPromiseRejectionWarning: ReferenceError: site is not defined
    at /opt/app-root/lib/bridges.js:186:120
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 7)

Background

When testing the HTTP Proxy through my browser, I noticed that the connection works until I try to refresh the page. I then tested the headers using curl and found If-Modified-Since to be causing the problem.

sergerad commented 4 years ago

Was getting the same error for a Proxy endpoint that worked until a path was specified. Will provide router logs when I get the chance

grs commented 4 years ago

What version of the proxy are you using and how do you have it configured?

Commit https://github.com/skupperproject/skupper-proxy/commit/a2bbced56020f7cd4a9b6550986d8ec1352bca1f prevents one issue you would see when using that header (and when the content has not changed). The way that manifested itself was different for me in my testing than what you report.

From the log snippet I have fixed on other issue https://github.com/skupperproject/skupper-proxy/commit/a37e73452d2080744b22a28fd3c0ec4f2e26fbe1, however that is in error handling so not the cause of the 'Could not deliver request'.

sergerad commented 4 years ago

This was tested on 1ebabf5.

Thanks, I will try the latest commits and let you know how I go.

sergerad commented 4 years ago

@grs Looks fixed thanks! I forgot to mention that this error appeared on the Proxy instance next to the Edge Router.

2020-07-30T23:23:40.334Z iofog info server sending reply for request to http://34.71.185.56/: {"to":"amqp:/_topo/0/default-router/temp.O2Nk7ovlFVjGuPn","correlation_id":66,"subject":"304","application_properties":{"x-powered-by":"Express","accept-ranges":"bytes","cache-control":"public, max-age=0","last-modified":"Mon, 18 Nov 2019 21:17:37 GMT","etag":"W/\"8e2-16e8060c968\"","date":"Thu, 30 Jul 2020 23:23:40 GMT","connection":"close"}}
[Thu Jul 30 2020 23:23:40] [ERROR] Thu, 30 Jul 2020 23:23:40 GMT Exception: Cannot read property 'length' of undefined
[Thu Jul 30 2020 23:23:40] [ERROR] TypeError: Cannot read property 'length' of undefined
    at IncomingMessage.<anonymous> (/opt/app-root/lib/bridges.js:102:182)
    at IncomingMessage.emit (events.js:327:22)
    at endReadableNT (_stream_readable.js:1218:12)

This error is also gone after your fixes!