SUMMERY:
cant proxy/process file uploads/downloads to or from backend services via hydra-router.
##upload
POST postman (file) -->> hydra-router -->> backend-service
backend-service does not receive the upload file from hydra but when I hit the backend-service directly it works perfectly
##download (get file)
GET postman (filename) -->> hydra-router -->> backend-service
backend-service receive the request, processes/return the result (confirmed by tracing), but hydra-router for some reason cant forward file to the client.
HYDRA-ROUTER CONFIGURATION FILE:
{
"externalRoutes": {},
"routerToken": "",
"disableRouterEndpoint": false,
"debugLogging": true,
"queuerDB": 0,
"requestTimeout": 300,
"forceMessageSignature": false,
"signatureSharedSecret": "*********************************",
"cors": {
"access-control-allow-origin": "",
"access-control-allow-methods": "GET, POST, PUT, DELETE, OPTIONS",
"access-control-allow-headers": "accept, authorization, cache-control, content-type, x-requested-with",
"access-control-allow-credentials": "true",
"access-control-Max-Age": 10
},
"hydra": {
"serviceName": "hydra-router",
"serviceDescription": "Service Router",
"serviceIP": "",
"servicePort": "5353",
"serviceType": "router",
"plugins": {
"logger": {
"logRequests": true,
"redact": [
"password"
]
},
"hydraLogger": {
"logToConsole": true,
"onlyLogLocally": false
},
"dontuse-logger": {
"logRequests": false,
"noFile": true,
"toConsole": false,
"redact": [
"password"
],
"elasticsearch": {
"rotate": "daily",
"host": "host",
"port": 9200,
"index": "hydra"
}
},
"dontuse-loggly": {
"method": "POST",
"protocol": "http",
"hostname": "logs-01.loggly.com",
"port": 80,
"path": "/inputs/{token-here}/tag/http/",
"logToConsole": true,
"onlyLogLocally": false
}
},
"redis": {
"url": "redis://127.0.0.1:6379/15"
}
}
}
BACKEND-SERVICE CODE SNIPPET:
galleryServiceRouter.get("/images/:filename", [cache('5 minutes')], async function (req, res) {
console.log("getting image: " + req.params.filename);
let image = await Image.findOne({
filename: req.params.filename
});
if (!image) {
res.status(400).json({
error: "Couldnt find image with that filename"
});
} else {
res.writeHead(200, {
"Content-Type": "image/png"
});
res.end(image.data);
console.log("found image: " + req.params.filename);
}
});
LOG FROM H-ROUTER:
1611308775 INFO hydra-router | {"tracer":"HR: tracer=2ad5pg2nkaf","url":"/api/v1/gallery-service/images/1a7cdd8f-581f-491a-a8cf-772c76d58f73_large.png","method":"GET","callerIP":"::1","body":{},"host":"localhost:5353","userAgent":"PostmanRuntime/7.26.8"}
1611308775 INFO hydra-router | HR: [2ad5pg2nkaf] Request for http://localhost:5353/api/v1/gallery-service/images/1a7cdd8f-581f-491a-a8cf-772c76d58f73_large.png
1611308775 INFO hydra-router | HR: [2ad5pg2nkaf] Calling remote service {"to":"gallery-service:[get]/api/v1/gallery-service/images/1a7cdd8f-581f-491a-a8cf-772c76d58f73_large.png","from":"aa482ad9b2a5469e99f856edc4d2194f@hydra-router:/","headers":{"user-agent":"PostmanRuntime/7.26.8","accept":"/","postman-token":"275ebdae-5619-44b4-a4e0-2633afe9e130","host":"localhost:5353","connection":"keep-alive","x-hydra-tracer":"2ad5pg2nkaf"},"mid":"8f93c9f6-1e90-407f-a2a5-2390f723aeeb-2ad5pg2nkaf","timestamp":"2021-01-22T09:46:15.784Z","version":"UMF/1.4.6","body":{}}
1611308775 INFO hydra-router | {"to":"gallery-service:[get]/api/v1/gallery-service/images/1a7cdd8f-581f-491a-a8cf-772c76d58f73_large.png","from":"aa482ad9b2a5469e99f856edc4d2194f@hydra-router:/","headers":{"user-agent":"PostmanRuntime/7.26.8","accept":"/","postman-token":"275ebdae-5619-44b4-a4e0-2633afe9e130","host":"localhost:5353","connection":"keep-alive","x-hydra-tracer":"2ad5pg2nkaf"},"mid":"8f93c9f6-1e90-407f-a2a5-2390f723aeeb-2ad5pg2nkaf","timestamp":"2021-01-22T09:46:15.784Z","version":"UMF/1.4.6","body":{}}
LOG FROM BACKEND-SERVICE:
getting image: 1a7cdd8f-581f-491a-a8cf-772c76d58f73_large.png
found image: 1a7cdd8f-581f-491a-a8cf-772c76d58f73_large.png
NB: returns image with all relevant headers
NB: ends response
QUESTION:
when I hit the backend-service directly it works perfectly.
Is there a simple way to get around this problem? or how can it be resolved?