-
Notifications
You must be signed in to change notification settings - Fork 135
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
Can't send large batch requests to GrapheneDB #128
Comments
I think if we add |
Ok, so I found some time.
|
Awesome, that works for me--thank you! |
@maxdemarzi, thanks for dedicating time to this issue. Unfortunately, the latest Git version has the same issue. The first request is still with no authorization headers, and I'm getting the same error with a very large batch. I'm using this source "https://rubygems.org"
gem "debugger"
gem "neography", path: "/mnt/coding/vendor/neography/" And this script: require "debugger"
require "neography"
batch_commands = (1..2000).map {|n| [:create_unique_node, "foo", :_id, n, { _id: n }] }
neo = Neography::Rest.new("http://....:[email protected]:24789")
result = neo.batch(*batch_commands)
p result The connection is still frozen. I replaced the 10.times {|i| neo.create_node(value: i) } And then capture the traffic with |
@ayosec @maxdemarzi I just stumbled over this issue coming from a different problem (neography is working for us but making tons of useless unauthenticated requests that introduce unnecessary latency). The underlying reason for neography's behaviour is inside httpclient's code. Basically it triggers auth only after receiving a challenge from the server (see https://github.com/nahi/httpclient/blob/master/lib/httpclient/auth.rb#L136) and (most importantly for my own problem) it will continue to do so if subsequent requests aren't "sub-uris" of a URI for which a challenge has been seen (see https://github.com/nahi/httpclient/blob/master/lib/httpclient/auth.rb#L274). Since neography doesn't explicitely hit "/", "/db/node" or any such "root URI" it never gets a challenge for the entire URI hierarchy and thus httpclient keep asking for challenges on the first hit to every node, index, etc. I ended up writing the following hack for my case: # Hack to avoid repeating requests to enable HTTP Auth.
# Basically httpclient only presents its credentials in the
# request after it has been challenged by the server on the
# request URL or any 'parent' URL. So let's make it think that
# it has been challenged on '/'.
# neo is an instance of Neography::Rest
root_url = neo.connection.configuration
neo.connection.client.www_auth.basic_auth.challenge(root_url) Of course the above hack only works for basic auth. From a quick glance at httpclient's auth.rb I don't think it is easy to generalize to the other auth methods (digest, oauth). But if you think that a |
Hi @leosoto, Thanks for the hack. It is working on my tests.
IMO, it should be enabled always. If Neo4j is configured with a user/password, there is no reason to try unauthenticated requests. |
I like the idea, on initialization it'll execute the authentication. Send me a pull request :) |
@maxdemarzi There you go :) |
Added updated koality.yml
When I generate a big batch request, like
I get the following error:
With other drivers it works.
For example, with Py2neo I can do
And, with cURL, using a batch file with 999 operations, I can do
Possible cause
The HTTP client tries to send the request with no authorization headers, so GrapheneDB rejects it with an 401 Unauthorized error, and close the connection. However, after capturing the traffic using tcpdump, it seems that the HTTP client is still sending the content, with no reply from the server — the connection is closed as soon as the headers are received.
In the following capture (extracted tcpdump and chaosreader), we can see the response from the server (in blue) almost from the beginning of the connection.
Working versions
With Neography 1.0.5 it works, since the Authorization header is sent from the first request.
The text was updated successfully, but these errors were encountered: