Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Neo4j 4 drops bolt version 1, perhaps default to higher version? #21

Closed
esjmb opened this issue Feb 22, 2020 · 8 comments
Closed

Neo4j 4 drops bolt version 1, perhaps default to higher version? #21

esjmb opened this issue Feb 22, 2020 · 8 comments

Comments

@esjmb
Copy link

esjmb commented Feb 22, 2020

I understand that neo4j 4 has dropped support for bolt version 1, which causes hasbolt connections to fail with the default version 1 requested.

Perhaps it's time to default to version 2?

I would also like to suggest that current error message be adjusted.

It presently reads "Cannot connect: unsupported server version".

I think that's misleading, and would suggest instead "Cannot connect: Requested Bolt protocol version unsupported".

thanks for the great work,
Stephen.

@esjmb
Copy link
Author

esjmb commented Feb 24, 2020

On further investigation, Neo4j 4.0.0.0 is only returning bolt protocols version 3 and 4.

@zmactep
Copy link
Owner

zmactep commented Feb 25, 2020

Hi Stephen!

Thank you for the feedback. I think you are right and it's time to move to BOLTv3. I'll make the commit with this change after several neo4j versions testing.

@zmactep
Copy link
Owner

zmactep commented Feb 27, 2020

The problem is deeper that I thought. BOLT v3 (and v4) is binary incompatible with BOLT v1. Also all versions except v1 are still undocumented. You may find a bit more on this problem here.

So I have to investigate neo4j sources a bit to find the differences and understand the way to make changes.

@esjmb
Copy link
Author

esjmb commented Feb 28, 2020

Appreciate that - had a bit of a play with connect and could see the server failing to follow through on standard v1 type interaction following bolt protocol negotiation.

Are these the relevant sources?

https://github.com/neo4j/neo4j/tree/4.0/community/bolt/src/main/java/org/neo4j/bolt

@normenmueller
Copy link

normenmueller commented Jul 26, 2020

I’m following this documentation but after sending the four magic bytes and the version proposal (1, 0, 0, 0) it seems like the server responses with a ‘0’. Could that be the case?

main :: IO ()
main = do
    pipe <- connect withConfig
    close pipe

withConfig :: BoltCfg
withConfig = def {user = "neo4j", password = "scratch"}

[...]
-- at `Database.Bolt.Connection.Pipe` 
handshake :: MonadPipe m => Pipe -> BoltCfg -> m ()
handshake pipe bcfg = do let conn = connection pipe
                         C.send conn (encodeStrict $ magic bcfg)
                         C.send conn (boltVersionProposal bcfg)
                         serverVersion <- decodeStrict <$> recvChunk conn 4
                         when (serverVersion /= version bcfg) $
                           throwError $ UnsupportedServerVersion (T.pack . show $ serverVersion)
                                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                         flush pipe (createInit bcfg)
                         response <- fetch pipe
                         unless (isSuccess response) $
                           throwError AuthentificationFailed

executing with this minor adaptation yield

▶ stack exec scratch-exe
errata-exe: Cannot connect: server version '0' is not supported

Changing to version '4' and commenting out flushing in the handshake yields

instance Default BoltCfg where
  def = BoltCfg { magic         = 1616949271
                , version       = 4

[...]
-- at `Database.Bolt.Connection.Pipe` 
handshake :: MonadPipe m => Pipe -> BoltCfg -> m ()
handshake pipe bcfg = do let conn = connection pipe
                         C.send conn (encodeStrict $ magic bcfg)
                         C.send conn (boltVersionProposal bcfg)
                         serverVersion <- decodeStrict <$> recvChunk conn 4
                         when (serverVersion /= version bcfg) $
                           throwError $ UnsupportedServerVersion (T.pack . show $ serverVersion)
                                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                         -- flush pipe (createInit bcfg)
                         -- response <- fetch pipe
                         -- unless (isSuccess response) $
                         --   throwError AuthentificationFailed

and executing those adaptations yields, at least no error

▶ stack exec scratch-exe

@OscarSouth
Copy link

Popping in here to link to this Issue:
neo4j/neo4j#12361

Which announces official Bolt documentation here: https://7687.org/

@zmactep
Copy link
Owner

zmactep commented May 23, 2021

Hi, everyone!

So, I've found a couple of evenings and made the initial support of protocol version 3 (not the 4). It's still lots of work, but you can use hasbolt with the latest neo4j version for now.

I want to say thanks to all who have written me e-mails with questions about the library. It's very motivating. Hope, we'll make the further work much faster.

@flip111
Copy link

flip111 commented Feb 23, 2023

https://7687.org/ is down and used to go upto neo4j 4.4 https://web.archive.org/web/20221017144413/https://7687.org/

For neo4j 5.0 - 5.3 with bolt 5.0 this website seems up to date https://neo4j.com/docs/bolt/current/bolt/ because it referenced changes made to 5.0 in a few places.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants