Neo4j-Swift / Neo4j-Swift

Open Source Neo4j driver for iOS, tvOS, Linux and macOS
MIT License
90 stars 14 forks source link

Unable to connect to AuraDB Neo4j instance #12

Open chadobado opened 2 years ago

chadobado commented 2 years ago

Attempted from master and dev/5.2.1 branches, on iOS and MacOS.

Result:

failure(NIOCore.ChannelError.connectTimeout(NIOCore.TimeAmount(nanoseconds: 2500000000))).

Confirmed can reach port from dev machine:

nc -vz 536aec41.databases.neo4j.io 7687
Connection to 536aec41.databases.neo4j.io port 7687 [tcp/*] succeeded!

Would very much like to use your hard work in a SwiftUI project but am unable to move further unfortunately.

joshjacob commented 2 years ago

@chadobado I just did a quick test and didn't have problems. I used Xcode to link latest Bolt-Swift package and Neo4j-Swift from dev/5.2.1 branch.

Here is my test code:

override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.

        do {
            let client = try BoltClient(hostname: "12341234.databases.neo4j.io",
                                            port: 7687,
                                        username: "neo4j",
                                        password: "neo”4j,
                                        encryption: Encryption.certificateIsSelfSigned)

            let result = client.connectSync()
            switch result {
            case let .failure(error):
                print(error)
            case .success(_):
                print("Connected")
            }

            let labels = ["Movie"]
            client.nodesWith(labels: labels, andProperties: [:]) { result in
                switch result {
                case .failure(let error):
                    print(error)

                case .success(let successResult):
                    print("Found \(successResult.count) nodes")
                    if let node = successResult.first {
                        print("    \(node.labels.joined(separator: ","))")
                        for (key,value) in node.properties {
                            print("        \(key) = \(value)")
                        }
                    }
                }
            }
        } catch (let error) {
            print(error)
        }
    }

And using the test movie data from Aura I see:

Connected
Found 25 nodes
    Movie
        title = RescueDawn
        released = 2006
        tagline = Based on the extraordinary true story of one man's fight for freedom

Maybe confirm the encryption type you specified?

philszalay commented 5 months ago

@chadobado I solved this problem by allowing outgoing network connections by adding this line to my entitlements file:

<key>com.apple.security.network.client</key> <true/>