1

I have been trying to use a Neo4j database as my database in an Azure Mobile service. I was following this tutorial and I cant seem to get it to work. Basically what the tutorial does is:

  • Creates a VM hosted by Azure, running ubuntu and neo4j.
  • Creates an Azure mobile service with an SQL table.
  • Writes an insert script for the SQL table that uses node.js to connect to the Neo4j VM and past the data there.

Unfortunately mine does not seem to work. The data gets posted to the mobile services SQL table but the script to post to the Neo4j server on the VM does not seem to work. I also know that the VM is setup correctly because I can connect to it in the Neo4j web admin page.

Here is the code for the script:

    function insert(item, user, request) {
    //comment to trigger .js creation
    var neo4j = require('neo4j');
    var db = new neo4j.GraphDatabase('http://<username>:<password>@http://neo4jmobile.cloudapp.net:7474');
    var node = db.createNode({ name: item.name });
    node.save(function (err, node) {
        if (err) {
            console.error('Error saving new node to database:', err);
        }
        else {
            console.log('Node saved to database with id:', node.id);
        }
    });

    request.execute();

}

Does any one have any experience with this? Is there something wrong with my script? With the tutorials approach? Any help would be appreciated.

EDIT: There was a problem with the line: console.err('Error saving new node to database:', err); which had to be replace with console.err('Error saving new node to database:', err);. However I am now getting this error message:

Error saving new node to database: { [Error: connect ETIMEDOUT]
  stack: [Getter/Setter],
  code: 'ETIMEDOUT',
  errno: 'ETIMEDOUT',
  syscall: 'connect',
  __frame:
   { name: 'GraphDatabase_prototype__getRoot__1',
     line: 76,
     file: '\\\\10.211.156.195\\volume-0-default\\bf02c8bd8f7589d46ba1\\4906fa4587734dd087df8e641513f602\\site\\wwwroot\\App_Data\\config\\scripts\\node_modules\\neo4j\\lib\\GraphDatabase.js',
     prev:
      { name: 'GraphDatabase_prototype_getServices__2',
        line: 99,
        file: '\\\\10.211.156.195\\volume-0-default\\bf02c8bd8f7589d46ba1\\4906fa4587734dd087df8e641513f602\\site\\wwwroot\\App_Data\\config\\scripts\\node_modules\\neo4j\\lib\\GraphDatabase.js',
        prev: [Object],
        active: false,
        offset: 5,
        col: 12 },
     active: false,
     offset: 5,
     col: 12 },
  rawStack: [Getter] }

Once again, any help would be appreciated!

7
  • Are you seeing anything in your Mobile Service's logs?
    – Chris
    Jan 24, 2014 at 18:13
  • Your URL is wrong. It should be: http://<username>:<password>@neo4jmobile.cloudapp.net:7474 Jan 25, 2014 at 1:48
  • @MichaelHunger I have change the URL, unfortunately that was not the problem. Jan 27, 2014 at 7:53
  • @Chris I am new to azure so I didnt even know that was there. Thanks for the help. I am getting this error: TypeError: Object [object Object] has no method 'err' at </table/person.insert.js>:17:25 at __$Node_prototype_save__1 Do you think you can help me? :) Jan 27, 2014 at 7:55
  • @Chris I have fized that problem. I needed to say console.error() rather than console.err(). However I now have a new problem. I have edited the original post to show it. Jan 27, 2014 at 9:55

2 Answers 2

1

Did you enable source control and npm install the neo4j module?

Miranda

1
  • I did. I was getting an error in the logs Error in script '/table/person.insert.js'. Error: Cannot find module 'neo4j' [external code] at insert (</table/person.insert.js>:5:21) at </table/person.insert.js>:1:8 [external code] but that is no longer a problem. Thanks though. Jan 27, 2014 at 7:53
1

Ok I managed to figure it out. The problem was that the tutorial (and documentation for neo4j for node.js) had a typo. The code should have been console.error() rather than console.err().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.