On a cold start, my Lambda functions will return this error when trying to initialize a connection with Neptune. After that, the connection succeeds with no error. If the Lambda goes cold again the error returns.
const dc = new DriverRemoteConnection(
`wss://${process.env.NEPTUNE_ENDPOINT}:${process.env.NEPTUNE_PORT}/gremlin`,
{}
);
const graph = new Graph();
const g = graph.traversal().withRemote(dc);
g.V();
dc.close();
Using gremlin@^3.4.6
and Node 12.x. I found a similar error being reported against the ws package which was dismissed as an implementation error.
https://github.com/websockets/ws/issues/1410
Do we need to somehow verify connections in advance when using Gremlin?
Edit: This problem seems to have started with gremlin@3.4.6
. If I downgrade to gremlin@3.4.5
the problem goes away.
Edit 2: Got the error again with 3.4.5. 3.4.4 seems better.
DriverRemoteConnection.close() is async operation, so you have to use await. Something like:
const dc = new DriverRemoteConnection(
`wss://${process.env.NEPTUNE_ENDPOINT}:${process.env.NEPTUNE_PORT}/gremlin`,
{}
);
const graph = new Graph();
const g = graph.traversal().withRemote(dc);
await g.V().limit(1).next();
await dc.close();
This helped me with the very same error