You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
Is there a way to reuse the connection and still flush the buffer (using JavaScript on AWS)? I tried to provide a custom connection header (Connection: Keep-Alive) and it did not work. The connection was closed anyway (I tested this on local InfluxDB 2.0.8 in docker). Does this behavior differ between InfluxDB OSS and Cloud?
I am currently creating the instance of write api like this
Thank you @xjohnp00 for using the client and posting an issue. Node.js HTTP client OOTB does not reuse connections, you can change the default with a help of an Agent. Your client code would then look like this:
const{Agent}=require('http')...constagent=newAgent({keepAlive: true,keepAliveMsecs: 20*1000,// 20 seconds keep alive})constwriteApi=newInfluxDB({
url,
token,transportOptions: {agent},}).getWriteApi(org,bucket,'ns')...// It is good practice, to destroy() an Agent instance when it is no longer in use,// because unused sockets consume OS resources.// process.on( 'SIGINT', function() {// agent.destroy()// })
There is no need to specify the Connection header, the agent does it. I double-checked it with a modified write.js example and a fake HTTP server:
constexpress=require('express')constport=8086constapp=express()app.post('/api/v2/write',(req,resp)=>{console.log(req.path,req.headers)resp.sendStatus(204)})app.listen(port,()=>{console.log(`listening on http://localhost:${port}`)})
Hi,
Is there a way to reuse the connection and still flush the buffer (using JavaScript on AWS)? I tried to provide a custom connection header (Connection: Keep-Alive) and it did not work. The connection was closed anyway (I tested this on local InfluxDB 2.0.8 in docker). Does this behavior differ between InfluxDB OSS and Cloud?
I am currently creating the instance of write api like this
And flushing written points using
I tried providing
Connection: Keep-Alive
header by passing myWriteOptions
toInfluxDB.getWriteApi()
Thanks.
The text was updated successfully, but these errors were encountered: