I recently migrated from stardog3 to stardog5 and I am having issues with all of my "update" functionality. My read queries are working and my update queries work if I execute them directly in my stardog5 console.
Here is what I am doing:
var agent = new http.Agent({ maxSockets: 15 });
var con = new stardog.Connection();
con.setEndpoint(config.URL); // This is set to my stardog instance: http://stardog5.mysite.com:5000
con.setCredentials(config.user, config.pass); //username, pass
var queryString = updatePublicationsQueryFile.toString() // Where this is my query, that I have tested it works.
con.query({
database: config.db,
query: queryString,
agent: agent
},
function (results) {
console.log(results)
});
This gets me the following error:
Cannot execute update query on read endpoint stardog
It looks like you are using the legacy 0.x version of stardog.js. We have since put out a 1.0 release that was made to work with Stardog 5. Check it out here or here!
What you have looks OK to me at first glance. Could be something with fs with which I’m unfamiliar. Is your console.log(queryString) line being printed to the console? If so, what if you add a catch to the end of the query.execute promise chain? Does that surface an error?
Sorry for the slow response, yes the queryString is printed and it is populated correctly. I updated the code with your recommendation and I added a catch however it is being printed as undefined:
{ FetchError: request to http://mypage.onbc.io:5820/DEV/query?limit=1000&offset=0 failed, reason: read ECONNRESET
at ClientRequest. (/project_files/midas/obc-api/node_modules/node-fetch/index.js:133:11)
at emitOne (events.js:96:13)
at ClientRequest.emit (events.js:188:7)
at Socket.socketErrorListener (_http_client.js:306:9)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at emitErrorNT (net.js:1272:8)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
name: 'FetchError',
message: 'request to http://mypage.onbc.io:5820/DEV/query?limit=1000&offset=0 failed, reason: read ECONNRESET',
type: 'system',
errno: 'ECONNRESET',
code: 'ECONNRESET' }