Skip to Content

Problemas al conectar Service Layer en JavaScript / Problems to connect Service Layer in JavaScript

Estoy realizando un conector a ServiceLayer en JavaScript con Node.js y Express. Cuando intenta hacer la conexión se queda un rato esperando respuesta y da el error “SOCKET HANG UP”. Si realizo la misma conexión a través del POSTMAN me funciona correctamente.

He comprobado la configuración del Service Layer según se indicaba en otros blogs. También he buscado por foros y tras probar las distintas soluciones me sigue dando el mismo error.

Adjunto como realizo la conexión:

I’m developing a connector to ServiceLayer in JavaScript with Node.js and Express. When it tries to make the connection it waits for a while waiting for an answer and it gives the error “SOCKET HANG UP”. If I make the same connection through POSTMAN, it works correctly.

I have checked the configuration of the Service Layer as indicated in other blogs. I have also searched through forums and after trying the different solutions I still get the same error.

I attach how I made the connection:

var https = require(‘https‘);

var connected = false;

var SessionID;

var SLServer;

exports.connectSL = function(re, res){




var post_req = null,

post_data = re;

var post_options = {

hostname: ‘’,

port : ‘50000’,

path : ‘b1s/v1/Login’,

method : ‘POST’,

body : post_data,

json : true,

headers : {

‘Content-Type’: ‘application/json‘,

‘Cache-Control’: ‘no-cache’,

‘Content-Length’: post_data.length


rejectUnauthorized: false,

requestCert: true,

agent: false


console.log(‘Realizando conexion‘);


post_req = https.request(post_options, function (res) {

console.log(‘STATUS: ‘ + res.statusCode);

console.log(‘HEADERS: ‘ + JSON.stringify(res.headers));


res.on(‘data’, function (chunk) {

console.log(‘Response: ‘, chunk);



post_req.on(‘error’, function(e) {

console.log(‘problem with request: ‘ + e.message);



Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • May 15, 2018 at 11:28 AM

    I have done a couple of examples with Node and SL.

    Please check:

    here is a tutorial repo:

    Here is another quick sample creating activities and messages:

    And the latest one using Redis to save the sl session in cache (I will write a blog about it) -

    Add comment
    10|10000 characters needed characters exceeded