Comments (4)
Instead of passing in the agent itself, just pass in agentOptions: {maxSockets: 5}
. The HTTP Agent provided by node.js does not use keep-alive by default, which may explain why you're running out of sockets. The agent
option is only really useful if you want to provide your own agent implementation (which is not normally necessary).
from arangojs.
Thanks Alan. I did as suggested, below is the script:
var moment = require('moment');
var db = require('arangojs')({
url: 'http://localhost:8000',
agentOptions: {maxSockets: 5},
databaseName: 'loadtest'
});
var recs = 1000000,
startDoc = 10122492 + 1,
currentDoc = 0,
type,
start = new Date(),
collection;
function save() {
type = Math.round(Math.random() * 10) + 1;
collection
.save({
'id': startDoc + currentDoc,
'type': type,
'connections': [
Math.round(Math.random() * 100) + 1,
Math.round(Math.random() * 100) + 1,
Math.round(Math.random() * 100) + 1,
Math.round(Math.random() * 100) + 1
],
'positions': [
{
'time': new Date(),
'type': type,
'position': {'lat': -122.423246, 'lng': 37.779388, 'radius': 250}
}
]
},
function (err, result) {
if (err || result.error) {
return console.error(err);
}
console.log('inserted ' + currentDoc + ' of ' + recs);
if (currentDoc === recs) {
return console.log('inserted ' + currentDoc + ' in ' + moment.utc(moment(new Date(), "DD/MM/YYYY HH:mm:ss").diff(moment(start, "DD/MM/YYYY HH:mm:ss"))).format("HH:mm:ss"));
}
currentDoc++;
save();
});
}
db.collection('load', function (err, result) {
if (err) {
console.error(err);
return;
}
collection = result;
console.info('starting: ' + start);
save();
});
after a few seconds I get:
{ [Error: connect ETIMEDOUT]
code: 'ETIMEDOUT',
errno: 'ETIMEDOUT',
syscall: 'connect',
request:
{ domain: null,
_events: { response: [Object], error: [Function] },
_maxListeners: 10,
output: [],
outputEncodings: [],
writable: true,
_last: false,
chunkedEncoding: false,
shouldKeepAlive: true,
useChunkedEncodingByDefault: true,
sendDate: false,
_headerSent: true,
_header: 'POST /_db/loadtest/_api/document/?collection=load HTTP/1.1\r\ncontent-type: application/json\r\ncontent-length: 170\r\nx-arango-version: 20300\r\nHost: localhost:8000\r\nConnection: keep-alive\r\n\r\n',
_hasBody: true,
_trailer: '',
finished: true,
_hangupClose: false,
socket:
{ _connecting: false,
_handle: null,
_readableState: [Object],
readable: false,
domain: null,
_events: [Object],
_maxListeners: 10,
_writableState: [Object],
writable: false,
allowHalfOpen: false,
onend: [Function: socketOnEnd],
destroyed: true,
bytesRead: 0,
_bytesDispatched: 0,
_pendingData: 'POST /_db/loadtest/_api/document/?collection=load HTTP/1.1\r\ncontent-type: application/json\r\ncontent-length: 170\r\nx-arango-version: 20300\r\nHost: localhost:8000\r\nConnection: keep-alive\r\n\r\n{"id":10136661,"type":6,"connections":[11,38,2,42],"positions":[{"time":"2015-06-21T15:33:36.022Z","type":6,"position":{"lat":-122.423246,"lng":37.779388,"radius":250}}]}',
_pendingEncoding: 'utf8',
parser: [Object],
_httpMessage: [Circular],
ondata: [Function: socketOnData],
_idleNext: null,
_idlePrev: null,
_idleTimeout: -1 },
connection:
{ _connecting: false,
_handle: null,
_readableState: [Object],
readable: false,
domain: null,
_events: [Object],
_maxListeners: 10,
_writableState: [Object],
writable: false,
allowHalfOpen: false,
onend: [Function: socketOnEnd],
destroyed: true,
bytesRead: 0,
_bytesDispatched: 0,
_pendingData: 'POST /_db/loadtest/_api/document/?collection=load HTTP/1.1\r\ncontent-type: application/json\r\ncontent-length: 170\r\nx-arango-version: 20300\r\nHost: localhost:8000\r\nConnection: keep-alive\r\n\r\n{"id":10136661,"type":6,"connections":[11,38,2,42],"positions":[{"time":"2015-06-21T15:33:36.022Z","type":6,"position":{"lat":-122.423246,"lng":37.779388,"radius":250}}]}',
_pendingEncoding: 'utf8',
parser: [Object],
_httpMessage: [Circular],
ondata: [Function: socketOnData],
_idleNext: null,
_idlePrev: null,
_idleTimeout: -1 },
agent:
{ domain: null,
_events: [Object],
_maxListeners: 10,
options: [Object],
requests: {},
sockets: [Object],
maxSockets: 5,
createConnection: [Function] },
socketPath: undefined,
method: 'POST',
path: '/_db/loadtest/_api/document/?collection=load',
_headers:
{ 'content-type': 'application/json',
'content-length': 170,
'x-arango-version': 20300,
host: 'localhost:8000' },
_headerNames:
{ 'content-type': 'content-type',
'content-length': 'content-length',
'x-arango-version': 'x-arango-version',
host: 'Host' },
parser:
{ _headers: [],
_url: '',
onHeaders: [Function: parserOnHeaders],
onHeadersComplete: [Function: parserOnHeadersComplete],
onBody: [Function: parserOnBody],
onMessageComplete: [Function: parserOnMessageComplete],
socket: [Object],
incoming: null,
maxHeaderPairs: 2000,
onIncoming: [Function: parserOnIncomingClient] } } }
Process finished with exit code 0
This is only the case when wait for sync is set to false.
from arangojs.
The ETIMEDOUT confirms that the root issue is on the server and that the EADDRNOTAVAIL was just a symptom caused by using node's default behaviour. I'm closing this issue in favour of the arangodb issue. Thanks for bringing this to our attention.
from arangojs.
Cool, will keep track of the progress
from arangojs.
Related Issues (20)
- Replace XHR with Fetch HOT 1
- How to use "ForceOneShardAttributeValue" option in aqlQuery? HOT 3
- Better handling of arangojs' connection pool to avoid "socket hang up?" HOT 2
- Update driver Version in Tutorial
- db.exists() no longer a function? HOT 3
- collection.document failing with options HOT 2
- Infinite loop in connection.js:177 HOT 3
- connect ECONNREFUSED error HOT 1
- Type issue after updating to v8.4.0 HOT 3
- Are there any code examples demonstrating how to include AQL queries in a stream transaction? HOT 2
- Getting error "expecting POST /_api/cursor" from Arangojs HOT 14
- Jest detecting open handles HOT 3
- outEdges and inEdges not working HOT 2
- Getting error "expecting POST /_api/cursor" HOT 1
- Documentation is unclear about when actual server connection occurs HOT 2
- Rollup Error: Could not resolve "./analyzer" from "./analyzer?commonjs-external" HOT 1
- Separate Typescript definitions of a Collection's Documents, vs the object passed to the save function
- Nesting of AQL literal does not work HOT 2
- Link to documentation is down
- Batching requests for GraphQL server resolvers queries
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arangojs.