Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions neo4j/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
BoltRoutingError,
BoltSecurityError,
BoltProtocolError,
BoltHandshakeError,
)
from neo4j.exceptions import (
ServiceUnavailable,
Expand Down Expand Up @@ -168,7 +169,7 @@ def open(cls, address, *, auth=None, timeout=None, **config):
:return:
"""
config = PoolConfig.consume(config)
s, config.protocol_version = connect(address, timeout=timeout, config=config)
s, config.protocol_version, handshake, data = connect(address, timeout=timeout, config=config)

if config.protocol_version == (3, 0):
from neo4j.io._bolt3 import Bolt3
Expand All @@ -180,7 +181,9 @@ def open(cls, address, *, auth=None, timeout=None, **config):
log.debug("[#%04X] S: <CLOSE>", s.getpeername()[1])
s.shutdown(SHUT_RDWR)
s.close()
raise BoltProtocolError("Driver does not support Bolt protocol version: 0x%06X%02X", config.protocol_version[0], config.protocol_version[1])

supported_versions = Bolt.protocol_handlers().keys()
raise BoltHandshakeError("The Neo4J server does not support communication with this driver. This driver have support for Bolt Protocols {}".format(supported_versions), address=address, request_data=handshake, response_data=data)

connection.hello()
return connection
Expand Down Expand Up @@ -849,7 +852,7 @@ def _handshake(s, resolved_address):
"(looks like HTTP)".format(resolved_address))
agreed_version = data[-1], data[-2]
log.debug("[#%04X] S: <HANDSHAKE> 0x%06X%02X", local_port, agreed_version[1], agreed_version[0])
return s, agreed_version
return s, agreed_version, handshake, data


def connect(address, *, timeout=None, config):
Expand Down
26 changes: 16 additions & 10 deletions tests/integration/aio/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,27 @@
# See the License for the specific language governing permissions and
# limitations under the License.


from pytest import fixture
import pytest

from neo4j.aio import Bolt, BoltPool
from neo4j._exceptions import BoltHandshakeError


@fixture
@pytest.fixture
async def bolt(address, auth):
bolt = await Bolt.open(address, auth=auth)
yield bolt
await bolt.close()
try:
bolt = await Bolt.open(address, auth=auth)
yield bolt
await bolt.close()
except BoltHandshakeError as error:
pytest.skip(error.args[0])


@fixture
@pytest.fixture
async def bolt_pool(address, auth):
pool = await BoltPool.open(address, auth=auth)
yield pool
await pool.close()
try:
pool = await BoltPool.open(address, auth=auth)
yield pool
await pool.close()
except BoltHandshakeError as error:
pytest.skip(error.args[0])
Loading