在 AWS Lambda 函数中访问 Neo4j 服务器
Accessing a Neo4j server in AWS Lambda function
我在使用 Lambda 函数访问我的 Neo4j 数据库时遇到问题。我想建立一个 Alexa 技能,并且在那个 Alexa 技能中应该可以访问像 Neo4j 这样的图形数据库。
本来以为把DB放到云端(用GrapheneDB)就可以解决这个问题了,现在看来认证有问题
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()) {
...
}
此代码在我的 IntelliJ IDE 中有效,但当我尝试将此代码放入示例 Lambda 函数时,出现以下错误:
"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.allocate(InternalConnectionPool.java:191)",
"org.neo4j.driver.internal.pool.InternalConnectionPool.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.allocate(InternalConnectionPool.java:191)",
"org.neo4j.driver.internal.pool.InternalConnectionPool.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)"
],
有人可以帮忙吗?或者有更好的方法来访问 Neo4j 数据库吗?
问题解决了。只需更改加密设置:
Config SSL = Config.build().withEncryption().toConfig();
也许对某人有帮助。
我在使用 Lambda 函数访问我的 Neo4j 数据库时遇到问题。我想建立一个 Alexa 技能,并且在那个 Alexa 技能中应该可以访问像 Neo4j 这样的图形数据库。 本来以为把DB放到云端(用GrapheneDB)就可以解决这个问题了,现在看来认证有问题
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()) {
...
}
此代码在我的 IntelliJ IDE 中有效,但当我尝试将此代码放入示例 Lambda 函数时,出现以下错误:
"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.allocate(InternalConnectionPool.java:191)",
"org.neo4j.driver.internal.pool.InternalConnectionPool.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.allocate(InternalConnectionPool.java:191)",
"org.neo4j.driver.internal.pool.InternalConnectionPool.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)"
],
有人可以帮忙吗?或者有更好的方法来访问 Neo4j 数据库吗?
问题解决了。只需更改加密设置:
Config SSL = Config.build().withEncryption().toConfig();
也许对某人有帮助。