SessionExpired: Failed to read from defunct connection IPv4Address(('ae3cd622.databases.neo4j.io', 7687)) (ResolvedIPv4Address(('34.126.64.110', 7687)))
Labels: name: area: embeddings, name: auto:bug

### Checked other resources

- [X] I added a very descriptive title to this issue.
- [X] I searched the LangChain documentation with the integrated search.
- [X] I used the GitHub search to find a similar question and didn't find it.

### Example Code

```
from langchain.embeddings import HuggingFaceEmbeddings
neo4j_db = Neo4jVector.from_documents(
    documents,
    HuggingFaceEmbeddings(),
    url=os.environ["NEO4J_URI"],
    username=os.environ["NEO4J_USERNAME"],
    password=os.environ["NEO4J_PASSWORD"],
    database="neo4j",  
    index_name="graphdb",  
    node_label="huggingface_dataset", 
    text_node_property="info",  
    embedding_node_property="vector",  
    create_id_index=True,  
)
```



### Description

```
ERROR:neo4j.io:Failed to read from defunct connection IPv4Address(('ae3cd622.databases.neo4j.io', 7687)) (ResolvedIPv4Address(('34.126.64.110', 7687)))
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
[/usr/local/lib/python3.10/dist-packages/neo4j/_sync/io/_common.py](https://localhost:8080/#) in _buffer_one_chunk(self)
     50                     # Determine the chunk size and skip noop
---> 51                     receive_into_buffer(self._socket, self._buffer, 2)
     52                     chunk_size = self._buffer.pop_u16()

16 frames
[/usr/local/lib/python3.10/dist-packages/neo4j/_sync/io/_common.py](https://localhost:8080/#) in receive_into_buffer(sock, buffer, n_bytes)
    327             if n == 0:
--> 328                 raise OSError("No data")
    329             buffer.used += n

OSError: No data

The above exception was the direct cause of the following exception:

SessionExpired                            Traceback (most recent call last)
[<ipython-input-43-6c577b606d00>](https://localhost:8080/#) in <cell line: 1>()
----> 1 neo4j_db = Neo4jVector.from_documents(
      2     documents,
      3     HuggingFaceEmbeddings(),
      4     url=os.environ["NEO4J_URI"],
      5     username=os.environ["NEO4J_USERNAME"],

[/usr/local/lib/python3.10/dist-packages/langchain_community/vectorstores/neo4j_vector.py](https://localhost:8080/#) in from_documents(cls, documents, embedding, distance_strategy, ids, **kwargs)
    815         metadatas = [d.metadata for d in documents]
    816 
--> 817         return cls.from_texts(
    818             texts=texts,
    819             embedding=embedding,

[/usr/local/lib/python3.10/dist-packages/langchain_community/vectorstores/neo4j_vector.py](https://localhost:8080/#) in from_texts(cls, texts, embedding, metadatas, distance_strategy, ids, **kwargs)
    679         embeddings = embedding.embed_documents(list(texts))
    680 
--> 681         return cls.__from(
    682             texts,
    683             embeddings,

[/usr/local/lib/python3.10/dist-packages/langchain_community/vectorstores/neo4j_vector.py](https://localhost:8080/#) in __from(cls, texts, embeddings, embedding, metadatas, ids, create_id_index, search_type, **kwargs)
    471             )
    472 
--> 473         store.add_embeddings(
    474             texts=texts, embeddings=embeddings, metadatas=metadatas, ids=ids, **kwargs
    475         )

[/usr/local/lib/python3.10/dist-packages/langchain_community/vectorstores/neo4j_vector.py](https://localhost:8080/#) in add_embeddings(self, texts, embeddings, metadatas, ids, **kwargs)
    520         }
    521 
--> 522         self.query(import_query, params=parameters)
    523 
    524         return ids

[/usr/local/lib/python3.10/dist-packages/langchain_community/vectorstores/neo4j_vector.py](https://localhost:8080/#) in query(self, query, params)
    272         with self._driver.session(database=self._database) as session:
    273             try:
--> 274                 data = session.run(query, params)
    275                 return [r.data() for r in data]
    276             except CypherSyntaxError as e:

[/usr/local/lib/python3.10/dist-packages/neo4j/_sync/work/session.py](https://localhost:8080/#) in run(self, query, parameters, **kwargs)
    311         bookmarks = self._get_bookmarks()
    312         parameters = dict(parameters or {}, **kwargs)
--> 313         self._auto_result._run(
    314             query, parameters, self._config.database,
    315             self._config.impersonated_user, self._config.default_access_mode,

[/usr/local/lib/python3.10/dist-packages/neo4j/_sync/work/result.py](https://localhost:8080/#) in _run(self, query, parameters, db, imp_user, access_mode, bookmarks, notifications_min_severity, notifications_disabled_categories)
    179         self._pull()
    180         self._connection.send_all()
--> 181         self._attach()
    182 
    183     def _pull(self):

[/usr/local/lib/python3.10/dist-packages/neo4j/_sync/work/result.py](https://localhost:8080/#) in _attach(self)
    296         if self._exhausted is False:
    297             while self._attached is False:
--> 298                 self._connection.fetch_message()
    299 
    300     def _buffer(self, n=None):

[/usr/local/lib/python3.10/dist-packages/neo4j/_sync/io/_common.py](https://localhost:8080/#) in inner(*args, **kwargs)
    176             def inner(*args, **kwargs):
    177                 try:
--> 178                     func(*args, **kwargs)
    179                 except (Neo4jError, ServiceUnavailable, SessionExpired) as exc:
    180                     assert not asyncio.iscoroutinefunction(self.__on_error)

[/usr/local/lib/python3.10/dist-packages/neo4j/_sync/io/_bolt.py](https://localhost:8080/#) in fetch_message(self)
    844 
    845         # Receive exactly one message
--> 846         tag, fields = self.inbox.pop(
    847             hydration_hooks=self.responses[0].hydration_hooks
    848         )

[/usr/local/lib/python3.10/dist-packages/neo4j/_sync/io/_common.py](https://localhost:8080/#) in pop(self, hydration_hooks)
     70 
     71     def pop(self, hydration_hooks):
---> 72         self._buffer_one_chunk()
     73         try:
     74             size, tag = self._unpacker.unpack_structure_header()

[/usr/local/lib/python3.10/dist-packages/neo4j/_sync/io/_common.py](https://localhost:8080/#) in _buffer_one_chunk(self)
     66         ) as error:
     67             self._broken = True
---> 68             Util.callback(self.on_error, error)
     69             raise
     70 

[/usr/local/lib/python3.10/dist-packages/neo4j/_async_compat/util.py](https://localhost:8080/#) in callback(cb, *args, **kwargs)
    116     def callback(cb, *args, **kwargs):
    117         if callable(cb):
--> 118             return cb(*args, **kwargs)
    119 
    120     @staticmethod

[/usr/local/lib/python3.10/dist-packages/neo4j/_sync/io/_bolt.py](https://localhost:8080/#) in _set_defunct_read(self, error, silent)
    870             self.unresolved_address, self.server_info.address
    871         )
--> 872         self._set_defunct(message, error=error, silent=silent)
    873 
    874     def _set_defunct_write(self, error=None, silent=False):

[/usr/local/lib/python3.10/dist-packages/neo4j/_sync/io/_bolt.py](https://localhost:8080/#) in _set_defunct(self, message, error, silent)
    922         else:
    923             if error:
--> 924                 raise SessionExpired(message) from error
    925             else:
    926                 raise SessionExpired(message)

SessionExpired: Failed to read from defunct connection IPv4Address(('ae3cd622.databases.neo4j.io', 7687)) (ResolvedIPv4Address(('34.126.64.110', 7687)))
```

### System Info

```
Windows: 11
pip == 23.3.1
python == 3.10.10
langchain == 0.1.0
transformers == 4.36.2
sentence_transformers == 2.2.2
Neo4j == 5
```

### Related Components

- [ ] LLMs/Chat Models
- [X] Embedding Models
- [ ] Prompts / Prompt Templates / Prompt Selectors
- [ ] Output Parsers
- [ ] Document Loaders
- [X] Vector Stores / Retrievers
- [ ] Memory
- [ ] Agents / Agent Executors
- [X] Tools / Toolkits
- [ ] Chains
- [ ] Callbacks/Tracing
- [ ] Async