Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
520 views
in Technique[技术] by (71.8m points)

pymongo - ClientError 404, cannot connect mongodb to neo4j

Rather than going into painful process of bringing everything into neo4j, we I resorted to easier solution. As configuration is not my expertise https://medium.com/neo4j/transform-mongodb-collections-automagically-into-graphs-9ea085d6e3ef

I followed instructions from here to configure (I want to import data in mongo to neo4j). I am in OSX Catalina. What endpoint should I be using? Following is my settings:

I have a virutal environment created with pipenv.

mongo-connector version: 3.1.1
Python version: 3.9.1 
pymongo version: 3.11.3
MongoDB version: 4.4.3

neo4j_doc_manager version: unknown (well installed following instructions from the above).

Now when I try to connect and run following

mongo-connector -m localhost:27017 -t http://localhost:11005/data/db -d neo4j_doc_manager

I used endpoint because I have following endpoints

bolt: https://localhost:11004
http: https://localhost:11005
https: https://localhost:7473

my neo4j location

/Users/Library/Application Support/com.Neo4j.Relate/Data/dbmss/dbms-bbb9318b-9083-4ebf-a934-e17ef055ae22

I have disabled authentication:

dbms.security.auth_enabled=false

I have no idea why I get HTTP 404:

2021-02-05 08:11:15,577 [ALWAYS] mongo_connector.connector:50 - Starting mongo-connector version: 3.1.1
2021-02-05 08:11:15,578 [ALWAYS] mongo_connector.connector:50 - Python version: 3.9.1 (default, Jan  8 2021, 17:17:17) 
[Clang 12.0.0 (clang-1200.0.32.28)]
2021-02-05 08:11:15,612 [ALWAYS] mongo_connector.connector:50 - Platform: macOS-10.15.7-x86_64-i386-64bit
2021-02-05 08:11:15,612 [ALWAYS] mongo_connector.connector:50 - pymongo version: 3.11.3
2021-02-05 08:11:15,619 [ALWAYS] mongo_connector.connector:50 - Source MongoDB version: 4.4.3
2021-02-05 08:11:15,619 [ALWAYS] mongo_connector.connector:50 - Target DocManager: mongo_connector.doc_managers.neo4j_doc_manager version: unknown
2021-02-05 08:11:15,633 [CRITICAL] mongo_connector.oplog_manager:713 - Exception during collection dump
Traceback (most recent call last):
  File "/Users/.local/share/virtualenvs/insiderTrading-L0T4T-gI/lib/python3.9/site-packages/py2neo/core.py", line 258, in get
    response = self.__base.get(headers=headers, redirect_limit=redirect_limit, **kwargs)
  File "/Users/.local/share/virtualenvs/insiderTrading-L0T4T-gI/lib/python3.9/site-packages/py2neo/packages/httpstream/http.py", line 966, in get
    return self.__get_or_head("GET", if_modified_since, headers, redirect_limit, **kwargs)
  File "/Users/.local/share/virtualenvs/insiderTrading-L0T4T-gI/lib/python3.9/site-packages/py2neo/packages/httpstream/http.py", line 943, in __get_or_head
    return rq.submit(redirect_limit=redirect_limit, **kwargs)
  File "/Users/.local/share/virtualenvs/insiderTrading-L0T4T-gI/lib/python3.9/site-packages/py2neo/packages/httpstream/http.py", line 452, in submit
    return Response.wrap(http, uri, self, rs, **response_kwargs)
  File "/Users/.local/share/virtualenvs/insiderTrading-L0T4T-gI/lib/python3.9/site-packages/py2neo/packages/httpstream/http.py", line 489, in wrap
    raise inst
py2neo.packages.httpstream.http.ClientError: 404 Not Found

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/.local/share/virtualenvs/insiderTrading-L0T4T-gI/lib/python3.9/site-packages/mongo_connector/util.py", line 33, in wrapped
    return f(*args, **kwargs)
  File "/Users/.local/share/virtualenvs/insiderTrading-L0T4T-gI/lib/python3.9/site-packages/mongo_connector/doc_managers/neo4j_doc_manager.py", line 78, in bulk_upsert
    tx = self.graph.cypher.begin()
  File "/Users/.local/share/virtualenvs/insiderTrading-L0T4T-gI/lib/python3.9/site-packages/py2neo/core.py", line 661, in cypher
    metadata = self.resource.metadata
  File "/Users/.local/share/virtualenvs/insiderTrading-L0T4T-gI/lib/python3.9/site-packages/py2neo/core.py", line 213, in metadata
    self.get()
  File "/Users/.local/share/virtualenvs/insiderTrading-L0T4T-gI/lib/python3.9/site-packages/py2neo/core.py", line 267, in get
    raise_from(self.error_class(message, **content), error)
  File "/Users/.local/share/virtualenvs/insiderTrading-L0T4T-gI/lib/python3.9/site-packages/py2neo/util.py", line 235, in raise_from
    raise exception
py2neo.error.GraphError: HTTP GET returned response 404

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/.local/share/virtualenvs/insiderTrading-L0T4T-gI/lib/python3.9/site-packages/mongo_connector/oplog_manager.py", line 668, in do_dump
    upsert_all(dm)
  File "/Users/.local/share/virtualenvs/insiderTrading-L0T4T-gI/lib/python3.9/site-packages/mongo_connector/oplog_manager.py", line 651, in upsert_all
    dm.bulk_upsert(docs_to_dump(from_coll), mapped_ns, long_ts)
  File "/Users/.local/share/virtualenvs/insiderTrading-L0T4T-gI/lib/python3.9/site-packages/mongo_connector/util.py", line 44, in wrapped
    raise new_type(str(exc_value)).with_traceback(exc_tb)
  File "/Users/.local/share/virtualenvs/insiderTrading-L0T4T-gI/lib/python3.9/site-packages/mongo_connector/util.py", line 33, in wrapped
    return f(*args, **kwargs)
  File "/Users/.local/share/virtualenvs/insiderTrading-L0T4T-gI/lib/python3.9/site-packages/mongo_connector/doc_managers/neo4j_doc_manager.py", line 78, in bulk_upsert
    tx = self.graph.cypher.begin()
  File "/Users/.local/share/virtualenvs/insiderTrading-L0T4T-gI/lib/python3.9/site-packages/py2neo/core.py", line 661, in cypher
    metadata = self.resource.metadata
  File "/Users/.local/share/virtualenvs/insiderTrading-L0T4T-gI/lib/python3.9/site-packages/py2neo/core.py", line 213, in metadata
    self.get()
  File "/Users/.local/share/virtualenvs/insiderTrading-L0T4T-gI/lib/python3.9/site-packages/py2neo/core.py", line 267, in get
    raise_from(self.error_class(message, **content), error)
  File "/Users/.local/share/virtualenvs/insiderTrading-L0T4T-gI/lib/python3.9/site-packages/py2neo/util.py", line 235, in raise_from
    raise exception
mongo_connector.doc_managers.error_handler.Neo4jOperationFailed: HTTP GET returned response 404
2021-02-05 08:11:15,634 [ERROR] mongo_connector.oplog_manager:723 - OplogThread: Failed during dump collection cannot recover! Collection(Database(MongoClient(host=['localhost:27017'], document_class=dict, tz_aware=False, connect=True, replicaset='rs0'), 'local'), 'oplog.rs')
2021-02-05 08:11:16,630 [ERROR] mongo_connector.connector:408 - MongoConnector: OplogThread <OplogThread(Thread-2, started 123145708253184)> unexpectedly stopped! Shutting down
question from:https://stackoverflow.com/questions/66064172/clienterror-404-cannot-connect-mongodb-to-neo4j

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You should check whether the version of py2neo you are using is compatible with the version of Neo4j. I suspect it isn't, since py2neo.packages.httpstream is a wildly out of date package name, and probably refers too a deprecated/removed HTTP endpoint.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...