amazon-web-serviceslambdaneo4jgraphenedb

Accessing a Neo4j server in AWS Lambda function


I have a problem with getting access to my Neo4j database in a Lambda function. I want to build an Alexa skill and in that Alexa skill it should be possible to access a graph database like Neo4j. I thought that putting the DB into the cloud (with GrapheneDB) would solve this problem, but now it looks like something is wrong with the certification.

import org.neo4j.driver.v1.*;
import static org.neo4j.driver.v1.Values.parameters;

public class DB {

public static void main(String...args) {

    Config noSSL = Config.build().withEncryptionLevel(Config.EncryptionLevel.NONE).toConfig();

    Driver driver = GraphDatabase.driver("bolt://xyz.dbs.graphenedb.com:24786", AuthTokens.basic("db","pw"), noSSL); 
    try (org.neo4j.driver.v1.Session session = driver.session()) {
    ...
    }

This code works in my IntelliJ IDE, but when I try to put this code in a sample Lambda function, these errors occur:

"errorMessage": "Unable to process request: General SSLEngine problem",
  "errorType": "org.neo4j.driver.v1.exceptions.ClientException",
  "stackTrace": [
    "org.neo4j.driver.internal.connector.socket.SocketClient.start(SocketClient.java:85)",
    "org.neo4j.driver.internal.connector.socket.SocketConnection.<init>(SocketConnection.java:63)",
    "org.neo4j.driver.internal.connector.socket.SocketConnector.connect(SocketConnector.java:52)",
    "org.neo4j.driver.internal.pool.InternalConnectionPool$1.allocate(InternalConnectionPool.java:191)",
    "org.neo4j.driver.internal.pool.InternalConnectionPool$1.allocate(InternalConnectionPool.java:180)",
    "org.neo4j.driver.internal.pool.ThreadCachingPool.allocate(ThreadCachingPool.java:212)",
    "org.neo4j.driver.internal.pool.ThreadCachingPool.acquireFromGlobal(ThreadCachingPool.java:164)",
    "org.neo4j.driver.internal.pool.ThreadCachingPool.acquire(ThreadCachingPool.java:118)",
    "org.neo4j.driver.internal.pool.InternalConnectionPool.acquire(InternalConnectionPool.java:109)",
    "org.neo4j.driver.internal.InternalDriver.session(InternalDriver.java:53)",
    "spacegeek.SpaceGeekSpeechlet.startGraphDB(SpaceGeekSpeechlet.java:122)",
    "spacegeek.SpaceGeekSpeechlet.onSessionStarted(SpaceGeekSpeechlet.java:87)",
    "com.amazon.speech.speechlet.SpeechletToSpeechletV2Adapter.onSessionStarted(SpeechletToSpeechletV2Adapter.java:33)",
    "com.amazon.speech.speechlet.SpeechletRequestDispatcher.dispatchSpeechletCall(SpeechletRequestDispatcher.java:102)",
    "com.amazon.speech.speechlet.SpeechletRequestHandler.internalHandleSpeechletCall(SpeechletRequestHandler.java:152)",
    "com.amazon.speech.speechlet.SpeechletRequestHandler.handleSpeechletCall(SpeechletRequestHandler.java:115)",
    "com.amazon.speech.speechlet.lambda.SpeechletRequestStreamHandler.handleRequest(SpeechletRequestStreamHandler.java:89)"
  ],"errorMessage": "Unable to process request: General SSLEngine problem",
  "errorType": "org.neo4j.driver.v1.exceptions.ClientException",
  "stackTrace": [
    "org.neo4j.driver.internal.connector.socket.SocketClient.start(SocketClient.java:85)",
    "org.neo4j.driver.internal.connector.socket.SocketConnection.<init>(SocketConnection.java:63)",
    "org.neo4j.driver.internal.connector.socket.SocketConnector.connect(SocketConnector.java:52)",
    "org.neo4j.driver.internal.pool.InternalConnectionPool$1.allocate(InternalConnectionPool.java:191)",
    "org.neo4j.driver.internal.pool.InternalConnectionPool$1.allocate(InternalConnectionPool.java:180)",
    "org.neo4j.driver.internal.pool.ThreadCachingPool.allocate(ThreadCachingPool.java:212)",
    "org.neo4j.driver.internal.pool.ThreadCachingPool.acquireFromGlobal(ThreadCachingPool.java:164)",
    "org.neo4j.driver.internal.pool.ThreadCachingPool.acquire(ThreadCachingPool.java:118)",
    "org.neo4j.driver.internal.pool.InternalConnectionPool.acquire(InternalConnectionPool.java:109)",
    "org.neo4j.driver.internal.InternalDriver.session(InternalDriver.java:53)",
    "spacegeek.SpaceGeekSpeechlet.startGraphDB(SpaceGeekSpeechlet.java:122)",
    "spacegeek.SpaceGeekSpeechlet.onSessionStarted(SpaceGeekSpeechlet.java:87)",
    "com.amazon.speech.speechlet.SpeechletToSpeechletV2Adapter.onSessionStarted(SpeechletToSpeechletV2Adapter.java:33)",
    "com.amazon.speech.speechlet.SpeechletRequestDispatcher.dispatchSpeechletCall(SpeechletRequestDispatcher.java:102)",
    "com.amazon.speech.speechlet.SpeechletRequestHandler.internalHandleSpeechletCall(SpeechletRequestHandler.java:152)",
    "com.amazon.speech.speechlet.SpeechletRequestHandler.handleSpeechletCall(SpeechletRequestHandler.java:115)",
    "com.amazon.speech.speechlet.lambda.SpeechletRequestStreamHandler.handleRequest(SpeechletRequestStreamHandler.java:89)"
  ],

Can anybody help with that? Or is there a better way to access a Neo4j DB?


Solution

  • Solved the problem. Simply had to change the encryption settings:

     Config SSL = Config.build().withEncryption().toConfig(); 
    

    Maybe it helps someone.