shutterstock / gremlin-aws-sigv4

Extension for Apache's TinkerPop3 Gremlin JS driver compatible with IAM Database Authentication for Neptune
MIT License
29 stars 16 forks source link

Websocket connection disconnet, Neptune limitation for IAM Authentication enabled #14

Open priyabratap opened 3 years ago

priyabratap commented 3 years ago

First of all, I would like to thank you for the beautiful wrapper connection with IAM authenitcation.

There is an AWS neptune limitation : When IAM authentication is enabled, a WebSocket connection is always disconnected a few minutes more than 10 days after it was established, if it hasn't already been closed by then.

I saw there is one option to enable autoReconnect with a maxRetry (default is 10). Once we reached maxRetry then because of the Neptune Limitation, the connection will be disconnected after 10days.

Very high level, I can think about a solution to make the autoReconnect a default option in case of _closeHandler. Additionally, we can log the _closeHandler behaviour to know about the timing of disconnect exactly after 10days or not.

Love to hear a better solution to address the above issue. Also, I am very interested to contribute here.

fabrice404 commented 3 years ago

Hi @priyabratap, thank you for your comment.

The autoReconnect option should already work as you describe, when the socket is closed, the _closeHandler event is triggered, and a connection attempt is made.

Did you encounter a case that doesn't work like described above? I'd be happy to help you solve your issue.

Also, if you wish to contribute more, you can suggest any pull request or issue, Just please follow the code of conduct

priyabratap commented 3 years ago

Hi @fabrice404 , thank you for the detailed clarification and I got it.

Two generic queries,

  1. Can I go for Singleton Pattern to Create a GraphDBAdapter for my application?
  2. In my case, the dev/testing env does not require IAM Authentication and it's required for Production only. To solve this case Can we have some option to toggle IAM authentication to use or not? (Solution I can think about to add some cond in my code to use gremlin.driver.RemoteConnection directly)
fabrice404 commented 3 years ago
  1. Yes you can totally use the singleton pattern, that's how I use it.
  2. Disabling the IAM authentication seems a bit strange as the main purpose of this project is to provide IAM authentication. I would personally recommend your pre-production clusters to match the configuration of your production cluster, but the solution you suggest would work, although you won't have the same code executed in pre-prod and in prod.
priyabratap commented 3 years ago

Thanks @fabrice404 Now we can close this.

priyabratap commented 3 years ago

Hi @fabrice404

Do you have the typescript support of it? currently, I have installed this one npm install --save @types/gremlin