Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

After initial success, now plotly sets up chart, fails to accept data stream

Hi, thanks for having me on the forum. For a school project, I have been using plotly for approx 2 months with success displaying a serial stream originating from a sensor attached to an Arduino board, which is attached to raspbian Jessie. The pi runs a bare-bones hard-coded server (see code below) All of a sudden, using the same code, same everything, I am not getting stream data to plotly. It sets up the chart, but no data. We’ve tried everything. Worked great before, now we’re dead in water. Thanks in advance for any help

var serialport = require(‘serialport’),
plotly = require(‘plotly’)(‘xxxx’,‘xxxx’),
token = ‘xxxx’;

var portName = ‘/dev/ttyACM0’;
var sp = new serialport.SerialPort(portName,{
baudRate: 9600,
dataBits: 8,
parity: ‘none’,
stopBits: 1,
flowControl: false,
parser: serialport.parsers.readline("\r\n")
});

// helper function to get a nicely formatted date string
function getDateString() {
var time = new Date().getTime();
// 32400000 is (GMT+9 Japan)
// for your timezone just multiply +/-GMT by 36000000
var datestr = new Date(time - 28800000).toISOString().replace(/T/, ’ ').replace(/Z/, ‘’);
return datestr;
}

var initdata = [{x:[], y:[], stream:{token:token, maxpoints: 500}}];
var initlayout = {fileopt : “extend”, filename : “sensor-test”};

plotly.plot(initdata, initlayout, function (err, msg) {
if (err) return console.log(err)

console.log(msg);
var stream = plotly.stream(token, function (err, res) {
    console.log(err, res);
});

sp.on('data', function(input) {
    if(isNaN(input) || input > 1023) return;

var streamObject = JSON.stringify({ x : getDateString(), y : input });
console.log(streamObject);
stream.write(streamObject+'\n');
});

});

1 Like

I’m having the same issue as of a few hours ago, so I think this must be a problem on Plotly’s side…

Having the same issue as well. Plot was running fine for a number of weeks but after resetting on afternoon of 2/13, the chart no longer displays the results sent with the .write() function.

Likewise, have been using Plotly’s python library for streaming for several months. Yesterday, from 2:26pm to 3:28pm the graphs went blank, but then came back (and actually included new data as well). This morning, the graphs are visible, but don’t include new data that is added to the graph each morning.

Currently using latest Python library (plotly 2.0.1). Was originally on 1.11.0 when the issues starting happening yesterday. Upgraded in hopes of fixing them. Like others have said though, it seems like this is an issue on plotly’s side instead of with the client library.

I know that Plotly had a 2.0 release for their Python library recently (https://github.com/plotly/plotly.py/releases), so I went back and compared my code to their sample streaming code (https://plot.ly/python/multiple-trace-streaming/). After a careful comparison, I didn’t see any significant differences between the two.

As a sanity check, I confirmed that I was able to run the sample streaming code. Sure enough, it ran without problems.

At this point, I knew that (1) my code matched the sample streaming code, (2) the sample code ran smoothly, but (3) I was still unable to stream to my existing graphs.

As a last resort, I deleted my existing graphs and reran my scripts (using the same streaming API tokens as before). The new graphs were created successfully. I also confirmed that I was able to stream new data to the graphs afterwards.

I’m having similar issues with stream.plot.ly.

I can successfully create a stream plot and submit data to it, but after a few I get “404”: “streamtoken not registered or valid” when submitting new data. Some of the times the plot will also lose all submitted data, leaving an empty plot that seems not to have any streamToken attached to it.

I’m streaming data using a custom arduino library, but I get the same results when sending data with Postman or curl.

Any idea would be greatly appreciated.

Edit: it seems that even the streaming-demo is having issues: https://plot.ly/~streaming-demos/6/streaming-mock-sensor-data/

I am also experiencing the problems described by @mbdroid. I’m using the same Python code I have been since January (which worked a-okay until a few days ago), but now I’m getting the 404: streamtoken not registered or valid error after a few writes. Any solutions?

same here for me. plotly demos also are not working as they should

I continue to see either the 404 error or just simply a blank graph after a few hours of streaming. this has been occurring for quite a few days now. Anyone find a fix?

I have the same issue trying to stream data to Plot.ly. Is any moderator from Plot.ly watching this?

I’m still experiencing this problem. I’m getting the 404: streamtoken not registered or valid error. Anybody else solved this (or seen it go away)?

I’m still experiencing it as well. Stream will run for a few hours at most and then 404. Now, even in the period before it gives the 404 I’m finding some strange behavior: when I point a browser to the stream, I see an outdated graph. If I click to hide one of the series on the chart, I then see a current graph, but with a big gap in the data. It’s like it’s only streaming if you’re actively watching it with a browser session.