thingdom / node-neo4j

[RETIRED] Neo4j graph database driver (REST API client) for Node.js
Apache License 2.0
925 stars 135 forks source link

Made message when there is a networking (proxy?) issue #183

Open jrgleason opened 8 years ago

jrgleason commented 8 years ago

I am working with a local Neo4J and I have an instance inside our local network so I didn't have to use our corporate proxy. Now I need to call external services and use a proxy.

When I try to configure using the HTTP_PROXY and HTTPS_PROXY vars Neo4J starts failing with...

C:\Users\a\dev\code\insight-plus\node_modules\neo4j\lib-new\GraphDatabase.js:268
        for (i = _i = 0, _len = results.length; _i < _len; i = ++_i) {
                                       ^
TypeError: Cannot read property 'length' of undefined
        at C:\Users\a\dev\code\insight-plus\node_modules\neo4j\lib-new\GraphDatabase.js:268:44

Two things

1.) How do I fix this? 2.) Is there a way we can do a null check on results and output a more meaningful message?

aseemk commented 8 years ago

Interesting. It's unexpected (per the Neo4j REST API) that results would ever be null; it's always returned AFAIK, even if empty. But maybe there's a case now or that I missed where that's not true.

Would you mind doing me a favor, and in node_modules\neo4j\lib-new\GraphDatabase.js, just before that line 268, could you console.log(resp.body) and tell me what gets outputted?

Thanks!

jrgleason commented 8 years ago

It could also be the message getting caught somewhere in our proxy and the response never getting received. I am still working to diagnose but it seems to fix itself if I remove my proxy (Neo server in on the intranet)

aseemk commented 8 years ago

Thanks for the update. Good luck diagnosing. =)

In the meantime, still feel free to add the console.log I mentioned above. It'll be useful.

jrgleason commented 8 years ago

I also noticed this, so my theory is that it is related to the general proxy I set up with HTTP_PROXY. I tried creating my GraphDatabase like this...

db = new neo4j.GraphDatabase({
  url: conf.connectionString,
  proxy: ""
})

But now when I try to run it I get.....

{ [Error: tunneling socket could not be established, cause=Parse Error] code: 'ECONNRESET' }
Unhandled rejection neo4j.ClientError: [Neo.ClientError.Statement.ParameterMissing] Expected a parameter named username
   at Function.Error.Error._fromObject (C:\Users\me\dev\code\insight-plus\node_modules\neo4j\lib-new\errors.js:70:14)
jrgleason commented 8 years ago

I will also try to get you that console output tomorrow.

jrgleason commented 8 years ago

neoerror

So it is just undefined (looks funny because the CoffeeScript stuff), I also noticed this error when I stopped there...

Current stackstace: Error
  at ClientRequest.http.ClientRequest.onSocket   (C:\Users\me\AppData\Roaming\nvm\v0.12.4\node_modules\node-inspector\lib\Injections\NetworkAgent.js:391:36)
  at C:\Users\me\dev\code\insight-plus\node_modules\request\node_modules\tunnel-agent\index.js:99:21
  at C:\Users\me\dev\code\insight-plus\node_modules\request\node_modules\tunnel-agent\index.js:205:5
  at ClientRequest.onConnect (C:\Users\me\dev\code\insight-plus\node_modules\request\node_modules\tunnel-agent\index.js:160:7)

So it does look like the request is failing like I would expect and node-neo just can't handle that.

alph486 commented 8 years ago

@aseemk I'm experiencing this too further down in the stacktrace of EntityNotFound Relationship with id x ... Is this considered a bug, or a red herring?

Carter-Wayblazer commented 8 years ago

I left @aseemk a message in the #neo4j-javascript slack channel but for completeness, I added this line console.log(typeof resp.body, resp.body); to right above line 268 and got the attached file's response.

Console.log.txt

alph486 commented 8 years ago

Also FWIW - we believe that the error I previously mentioned (EntityNotFound...) is likely not related to the issue @Carter-Wayblazer is posting; we've seen it happen without that exception as well.

Carter-Wayblazer commented 8 years ago

We (@alph486 and I) were running Neo 2.2.7 in production but just moved to the latest 2.3.1 and have not seen this error since then when we typically saw it once or twice a day. My speculation is it has been fixed by Neo since.