Security

node.js login error: no session key available

hm_splunk
Engager

I am getting error: No session key available. Below is the node.js code in app.js. I'm getting the error at service.login() and then log the error. Please help.

var splunkjs = require('splunk-sdk'), 
Class = splunkjs.Class,
utils = splunkjs.Utils,
Async = splunkjs.Async;

app.get('/splunk', function(request, response) {
  // Create a Service instance and log in 
var service = new splunkjs.Service({
  scheme:"https",
  host:"<internal splunk address host>",
  port:"8089",
  username:"dashboard",
  password:"1234",
  version:"4.0"
});

//var service = new splunkjs.Service({username: "admin", password: "changeme"});
service.login(function(err, success) {
    if (err || !success) {
        console.log('Error: ' + err);
    }

    console.log("Login was successful: " + success);
    service.jobs().fetch(function(err, jobs) {
        var jobList = jobs.list();
        for(var i = 0; i < jobList.length; i++) {
            console.log("Job " + i + ": " + jobList[i].sid);
        }
    });
});
});
0 Karma
1 Solution

smohamed_splunk
Splunk Employee
Splunk Employee

I was able to reproduce your issue.
Which version of Splunk are you using? Make sure that matches the value you set for version in the splunkjs.service constructor.

Try setting version to "default" and see if that solves your issue.

View solution in original post

smohamed_splunk
Splunk Employee
Splunk Employee

I was able to reproduce your issue.
Which version of Splunk are you using? Make sure that matches the value you set for version in the splunkjs.service constructor.

Try setting version to "default" and see if that solves your issue.

ineeman
Splunk Employee
Splunk Employee

If you are using 4.3, then you need to install the xml2json app. If you set it to 4.3 and it gives you a 404, that is likely the issue.

hm_splunk
Engager

That gives me a "404 not found" response.

0 Karma

smohamed_splunk
Splunk Employee
Splunk Employee

In that case, I would try setting version to "4.3.2" instead of "4.0"

0 Karma

hm_splunk
Engager

The splunk version is:
Copyright © 2005-2013 Splunk Inc. All rights reserved.
version 4.3.2, build 123586

I tried the "default" version but that didn't work

0 Karma
Get Updates on the Splunk Community!

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...