0

BrightSign doesn't display html from Nodejs localhost

I have a simple NodeJS/express app running on an XT1144 (Boot Version: 8.0.94 | BrightSign OS Version: 8.5.47). I can browse to the IP address:port of the device from a PC on the same network and display the content for each endpoint (192.168.x.xxx:9090/endpoint). However, if I create a presentation with HTML5 widgets pointing to localhost:9090/test or /dashboard or /files, nothing is displayed on the device. I have the HTML5 widget sandwiched between two google.com in the presentation, so I know the device is displaying pages, just not from localhost.

index.js:

var express = require('express');
const fs = require('fs');
var app = express();

function main() {
//app.use(express.static('/storage/sd/node-server'));
app.get('/dashboard', function(req, res) {
  console.log('GET: dashboard');
  try{
    res.sendFile('/storage/sd/node-server/dashboard.html');
  }
  catch(err){
    console.log(err);
  }
  finally{
    console.log('displayed dashboard');
  }
  })

app.get('/test', function(req, res) {
  console.log('GET: test');
  res.send('<h1>Hello, World!</h1>');
  })

app.get('/files', function(req, res) {
  const directoryPath = '/storage/sd/node-server';
  fs.readdir(directoryPath, function(err, files) {
    if (err) {
      console.log('Error getting directory files:', err);
      res.status(500).send('Error getting directory files');
    } else {
      res.send(files);
    }
  });
  });

app.listen(9090, function() {
  console.log('Example app listening on port 9090!');
});
}

// exchange below line to 'window.main = main;' if using node-server.html
// as the application entry point.
window.main = main();

Checking the logs for the unit, the device is hitting the express endpoints and receiving console.log output.

Log snippet:


[28222.098] BSPLAY: http://localhost:9090/dashboard
[28222.201] [INFO] [source file:///sd:/node-server/bundle.js:2]: GET: dashboard
[28222.202] [INFO] [source file:///sd:/node-server/bundle.js:2]: displayed dashboard 

 

Note that we are using BSNEE and BA 5, not Cloud/BA:Connected. I ran some tests with BA Connected and had no issues setting this up. Unfortunately, we cannot use it in our environment and must rely on BA 5.

2 comments

  • 0
    Avatar
    Bright Scripters

    Examining the console in DevTools might provide more insight.
    Also, is referencing the app using file:///…. an option?
    Without the need for the 9090 server….

    For DevTools / Web Inspector
    https://brightsign.atlassian.net/wiki/spaces/DOC/pages/370672286/HTML+Best+Practices#Debugging-Webpages

  • 0
    Avatar
    ryan.bishop

    The issue was the presentation background was black, like the text I was displaying. I changed the background color of the HTML and the content is displaying.

    The strange thing was when I used web inspector to monitor the device, I clicked the "Inspect" button for the pages I was attempting to display, it opened up devTools with no helpful info, but when I closed devTools the page displayed on the BrightSign.

    Thanks for your help

Please sign in to leave a comment.