Why http requests are not chunked? (Segment too large error)
- Dominant language
- JavaScript
- Stars
- 280
- Forks
- 157
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
I have app which performs multiple large http requests to other services. When some process will trigger start, is runs serveral http requests to other server in interval of few seconds.
Sadly, when i report this to XRay often I get error "Segment too large" because my requests are fat and after few of it, limit 65k bytes are hit.
I have set setStreamingThreshold to 0 which helps, but now each request is send separately. How to do it better?
Here is reproduce code, based on sample app:
```js
const AWSXRay = require("aws-xray-sdk-core");
AWSXRay.setStreamingThreshold(0);
const XRayExpress = require("aws-xray-sdk-express");
const rp = require('request-promise');
const express = require('express');
const crypto = require('crypto');
// Capture all outgoing https requests
AWSXRay.captureHTTPsGlobal(require('http'));
AWSXRay.captureHTTPsGlobal(require('https'));
const app = express();
const port = 3000;
app.use(XRayExpress.openSegment('SampleSite'));
app.get('/', (req, res) => res.send('OK'));
app.get('/start/', async (req, res) => {
for(let i =0;i<30; i++) {
console.log(i);
await rp.get('http://www.mocky.io/v2/5ea0939f320000384494b036?test='+crypto.randomBytes(1000).toString('hex'));
}
res.send('DONE');
});
app.use(XRayExpress.closeSegment());
app.listen(port, () => console.log(`Example app listening on port ${port}!`));
```
In my opinion, SubSegments could be chunked and send to daemon in parts.
Any advices?
Regards,
Tomasz
Contributor guide
Assessment
This issue has not been assessed yet.