0

I received the following error when using gremlin_python to run a a Gremlin query to save a property to an existing vertex using Gremlin Server inside a docker container on my local machine.

   traversal.next()
.venv/lib/python3.9/site-packages/gremlin_python/process/traversal.py:88: in next
    return self.__next__()
.venv/lib/python3.9/site-packages/gremlin_python/process/traversal.py:47: in __next__
    self.traversal_strategies.apply_strategies(self)
.venv/lib/python3.9/site-packages/gremlin_python/process/traversal.py:548: in apply_strategies
    traversal_strategy.apply(traversal)
.venv/lib/python3.9/site-packages/gremlin_python/driver/remote_connection.py:63: in apply
    remote_traversal = self.remote_connection.submit(traversal.bytecode)
.venv/lib/python3.9/site-packages/gremlin_python/driver/driver_remote_connection.py:60: in submit
    results = result_set.all().result()
../../.pyenv/versions/3.9.2/lib/python3.9/concurrent/futures/_base.py:440: in result
    return self.__get_result()
../../.pyenv/versions/3.9.2/lib/python3.9/concurrent/futures/_base.py:389: in __get_result
    raise self._exception
.venv/lib/python3.9/site-packages/gremlin_python/driver/resultset.py:90: in cb
    f.result()
../../.pyenv/versions/3.9.2/lib/python3.9/concurrent/futures/_base.py:433: in result
    return self.__get_result()
../../.pyenv/versions/3.9.2/lib/python3.9/concurrent/futures/_base.py:389: in __get_result
    raise self._exception
../../.pyenv/versions/3.9.2/lib/python3.9/concurrent/futures/thread.py:52: in run
    result = self.fn(*self.args, **self.kwargs)
.venv/lib/python3.9/site-packages/gremlin_python/driver/connection.py:82: in _receive
    data = self._transport.read()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <gremlin_python.driver.aiohttp.transport.AiohttpTransport object at 0x1096b28e0>

    def read(self):
        # Inner function to perform async read.
        async def async_read():
            async with async_timeout.timeout(self._read_timeout):
                return await self._websocket.receive()
    
        # Execute the async read synchronously.
        msg = self._loop.run_until_complete(async_read())
    
        # Need to handle multiple potential message types.
        if msg.type == aiohttp.WSMsgType.close:
            # Server is closing connection, shutdown and throw exception.
            self.close()
            raise RuntimeError("Connection was closed by server.")
        elif msg.type == aiohttp.WSMsgType.closed:
            # Should not be possible since our loop and socket would be closed.
>           raise RuntimeError("Connection was already closed.")
E           RuntimeError: Connection was already closed.
Sam Martin
  • 1,238
  • 10
  • 19

1 Answers1

0

After some digging I came across this stackoverflow which wasn't relating to gremlin python but lead me to the correct answer. After changing the maxContentLength in my gremlin-server.yaml and re-running the query, the error went away.

Sam Martin
  • 1,238
  • 10
  • 19
  • 1
    By default, the Gremlin Python Client uses a 10mb max content length. The latest version of Gremlin Server has been updated to also have that setting. So once the next Apache TInkerPop release comes out, the server should have a bigger default maximum. Did the server side logs have a better message that would have given a clue as to the actual issue? – Kelvin Lawrence Nov 06 '21 at 22:25
  • The gremlin server container stdout didn’t show anything that corresponded with the error. The server config I had was only a maxContentLength of 64kb which was why I ran up against it! – Sam Martin Nov 07 '21 at 07:05
  • It looks like it's been updated relatively recently in the dockerfile to be the size you mention https://github.com/apache/tinkerpop/commit/fd1fd10e23fe15822ded07527574c6ccdf5c4484#diff-fda67ac603922d601d1402f6c1bc59f33114c9e09501ec971f2f4ea4697d6f1dL48 but the docker image on docker hub hasn't been released since so it's still 65536 `$ docker run -it --entrypoint cat tinkerpop/gremlin-server /opt/gremlin-server/conf/gremlin-server.yaml | grep maxContentLength maxContentLength: 65536` – Sam Martin Nov 07 '21 at 07:14