.NET 코어 2.2 웹 API에서 Neo4j Aura 인스턴스에 연결하려고합니다. Neo4j .Net Driver v4.0.0-alpha01이 필요하다는 것을 알고 있지만 연결할 수없는 것 같습니다. 이 드라이버는 새롭고 Aura도 그렇기 때문에 많은 예제가 없습니다.
나는 계속 얻는다 : Failed after retried for 6 times in 30000 ms. Make sure that your database is online and retry again.
드라이버를 이렇게 구성합니다.
public void ConfigureServices(IServiceCollection services)
{
string uri = "neo4j://1234567.databases.neo4j.io:7687";//not actual subdomain
string username = "neo4j";
string password = "seeeeeeecret";//not actual password
services.AddCors();
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
services.AddSingleton(GraphDatabase.Driver(uri, AuthTokens.Basic(username, password)));
}
내 테스트 컨트롤러에서 나는 이것을 실행합니다.
private async Task<string> Neo4JTestAsync()
{
string db = "MyDb";
string message = "TESTMESSAGE";
IAsyncSession session = _driver.AsyncSession(o => o.WithDatabase(db));
try
{
var greeting = session.WriteTransactionAsync(async tx =>
{
var result = tx.RunAsync("CREATE (a:Greeting) " +
"SET a.message = $message " +
"RETURN a.message + ', from node ' + id(a)",
new { message });
var res = await result;
return "return something eventually";
});
return await greeting;
}
catch (Exception e)
{
return e.Message; // throws "Failed after retried for 6 times in 30000 ms. Make sure that your database is online and retry again"
}
finally
{
await session.CloseAsync();
}
}
정확한 오류 메시지를 받을 수는 없지만 이것이 암호화 때문이라고 확신합니다. 1.x
와 4.x
드라이버 의 큰 차이점 중 하나는 암호화 의 기본 위치이며 현재 기본적으로 꺼져 있습니다.
따라서 초기화를 다음과 같이 변경해야합니다.
services.AddSingleton(GraphDatabase.Driver(uri, AuthTokens.Basic(username, password), config => config.WithEncryptionLevel(EncryptionLevel.Encrypted)));
그것은 당신을 가야합니다. 또한- neo4j://
프로토콜 을 고수 해야 올바르게 라우팅됩니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다