I used to work at a small company. We had a few remote embedded devices that did work and sent data back to the mothership over the internet. Their firmware could be remotely updated, but we were always very careful.
Well one day a mistake was finally made. Some of the devices went into a sort of loop. They’d start running the important process, something would go wrong, and they’d just retry every few minutes. We caught the issue almost instantly since we were watching the deploy, and were able to stop updates before any other devices picked it up. But those that already got it were down. We could ask the devices to send us the output of a command remotely, but it was too limited to be able to send back an error log. We didn’t have time to send back like 255 characters at a time or whatever, we needed to get it fixed ASAP. And that’s when the genius stupid hack was suggested. While we couldn’t send up a full log file, we could certainly send up something the length of a URL. So what if we sent down a little command to stick the log on PasteBin and send up the URL to us? Worked like a charm. We could identify what was going wrong and fix it in just a few minutes. After some quick (but VERY thorough) testing everything was fixed.
How you could have enough control over the machine to reroute the error log to (what I assume was) a Pastebin api, while also lacking access to any of the files on the machine? In my mind you'd be required to ssh into the machine to upload, and if you're ssh'd in, why not just cat the log?
Good question! We couldn’t SSH in, which is too bad this would all be trivial. We had no direct access to the boxes, they were often behind firewalls. In fact that was the suggested placement for security reasons. They weren’t full servers, just little embedded things.
We had a little HTTP API that it was always talking to. It would call the API to send data back to us or just check in regularly, and we would return to it a little bit of status stuff like the current time to keep clocks in sync, and a list of which “commands” they need to run. Mostly the commands were things like “your calibration data is out of data, pull an update“ or “a firmware update is available“. But one of them let us run arbitrary shell commands. The system was very limited. I wasn’t a developer directly on the project but I think it was just our custom software plus busy box and a handful of other things our normal shell scripts used. I assume it had been added after some previous incident. I believe the basic idea was that during troubleshooting you could tell a box to return the output of “cat /etc/resolv.conf” or something else that we hadn’t preplanned for without having to send someone into the field. But since it was only for small things like that it couldn’t return a full file. Luckily one of the commands was either curl or wget. So we could send down “curl -whatever /log/path https://pastebin/upload” or whatever it was. I don’t remember if we signed up for a pastebin account so we knew where it would show up or if we had it return URL to us in the output of the curl command. This suggestion was literally a joke. We were all beating our heads against the wall trying to help and someone just said “why don’t we just stick it on pastebin“ out of frustration, and the developer on the project realized we had what we needed to do that and it would work.
> In my mind you'd be required to ssh into the machine to upload, and if you're ssh'd in, why not just cat the log?
Ssh on remote IoT class devices is works. The problem is rarely ssh, the problem is always some form of key management plus NATs in-between. If you've got a few thousand devices in the field, public key management can become a a real pain, especially when you want to revoke keys.
I was doing some proxy soak testing for a company once where we had to run the tests from the server room but there was no non-proxy connectivity from that room to where we were monitoring the tests. Simple solution: output the progress to Dropbox, watch the same file upstairs. Bit of delay, sure, but better than having no idea how things are going until the 30-60min test is done (and no, we weren't allowed to sit in the server room watching it.)
There's a zillion things that you can't necessarily test for locally. When you have a fleet of IoT devices deployed in other people's environments, there's literally no way to test everything.
Your question comes down to "Why didn't you just deploy bug free code using perfect processes? That's what I always do." I mean, cmon.
OP's description suggests it was an error that's common to all the deployed instances that received the update, rather than some specific combination of environment and that deployment. It would have allowed them to run the same deployment locally and use physical access (serial, a display, sd card, whatever) to capture the error log. What they came up with is clever but it's very surprising that they needed it, especially given that they have very limited remote access to the units that are in the wild.
As a kid I acquired my parent’s login to the school platform meaning I could call in sick myself. However one day I actually got sick so they had to call it in which means they would’ve seen all previous calls.
So I downloaded the HTML for all pages required for this exact flow and removed the previous sick days. I then changed my etc/hosts file, gave them my computer and prayed that they wouldn’t try to visit any other page than the ones I downloaded. Worked like a charm. Later I called in sick myself.
That’s good. I took AP computer science in high school thinking we would learn how to make apps with graphical user interfaces (didn’t know there was any other kind) so I was uninterested and never payed attention/studied since when we only learned Java and not the kind for making UI’s.
I had a friend whose mom was a programmer and she would help us get the answers to homework problems. I would change variable names and a few other things, but one time we still got caught with way too similar answers. In order not to get my friend and his mom in trouble, I told the teacher that I had in fact cheated but not from my friend. I stayed up for a few nights learning HTML and other things (well, modifying other code I found) in order to make a blog where a similar question as the homework problem was discussed, so that I could cite it as my source. At first I tried using blogging software but the timestamps are automatically coded as the current date, which wouldn’t work. So I had to make my own blog-looking site from scratch complete with several months worth of content, which was pretty much plagiarized I think. It was way more effort than actually doing the homework would have been.
I had an old boiler that would sometimes trip and lock out the heat until someone went down and power cycled it. (It was its own monstrous hack of a gas burner fitted to a 1950s oil boiler and I think a flame proving sensor was bad.)
Every time it happened, it made for a long heat up cycle to warm the water and rads and eventually the house. So I built an Arduino controlled NC relay that removed power for 1 minute out of every 120. That was often enough to eliminate the effect of the fault, but not so often that I had concerns about filling too much gas if the boiler ever failed to ignite. 12 failed ignitions per day wouldn’t give a build up to be worried about. That ~20 lines of code kept it working for several years until the boiler was replaced.
Our boiler has a pump to cycle hot water around the house - this makes it so you get warm water right away when you turn on a faucet and also prevents pipes in exterior walls from freezing in the winter. This stopped working, the pump is fine but the boiler was no longer triggering it. I just wired up mains through an esp32 relay board to the pump and configured a regular timer via esphome. Temperature based logic would be even better but I didn't find a good way to measure pipe temperature yet.
IIRC, I used an RTD that I had left over from a 3D printer upgrade, but an 18B20 would fine as well. A 10K NTC resistor might even be good enough. For what I needed (and I think for what you need), just fixing the sensor to the outside of the pipe [if metal] will give you a usable signal. That sensor was just metal HVAC taped to the front cast iron door of the burner chamber. But a dead-simple timer solution gets you pretty far as you know.
The pipes are insulated and I didn't want to cut into that, but maybe a small hole for a sensor wouldn't be too bad.
But as you say, timer works good enough and that means little motivation to continue to work on it -- countless other projects await :) BTW I've also tuned the timer to run for longer in the morning to get a hot shower ready. Edit: nice dashboard, what are you using for the chart? I like the vintage look.
I'm thiiiiiiis close to installing a circulating pump. I plan to power it off the bathroom lightswitch, which I might just replace with a motion sensor.
I implemented an enterprise data migration in javascript, running in end-user's browsers. (So no server-side node.js or such.)
It was a project scheduled for 2-3 months, for a large corporation. The customer wanted a button that a user would click in the old system, requesting a record to be copied over to the new system (Dynamics CRM).
Since the systems would be used in parallel for a time, it could be done repeatedly, with later clicks of the button sending updates to the new system. I designed it to run on an integration server in a dedicated WS, nothing extraordinary. But 3 days before the scheduled end of the project, it became clear that the customer simply will not have the server to run the WS on. They were incapable of provisioning it and configuring the network. So I came up with a silly solution: hey, the user will already be logged in to both systems, so let's do it in their browser.
The user clicked the button in the old system, which invoked a javascript that prepared the data to migrate into a payload (data -> JSON -> Base64 -> URL escape) and GET-ed it in a URL parameter onto a 'New Record' creation form into the new system. That entire record type was just my shim; when its form loaded, it woke another javascript up, which triggered a Save, which triggered a server-side plugin that decoded and parsed the data, which then processed them, triggering like 30 other plugins that were already there - some of them sending data on into a different system. I coded this over the weekend and handed it in, with the caveat that since it has to be a GET request, it simply will not work if the data payload exceeds the maximum URL length allowed by the server, ha ha.
You will not be surprised to learn the payload contained large HTMLs from rich text editors, so it did happen a few times.
But it ran successfully for over a year until the old system eventually was fully deprecated. (Shout out to my boss, who was grateful for the solution and automatically offered to pay for the overtime.)
I think the OP (hat off!) needed a way to transfer data to the front-end of another application. Since there's no back end involved, the only available channel is the request URL
> Since there's no back end involved, the only available channel is the request URL
Not quite. I have a system that uses a custom userscript to create an extra button on certain webpages that, when clicked, scrapes some data from the current page and copies a lightly encoded version to the user's clipboard. They then switch to another webpage and paste it in a box. I've also gotten data from place to place using scraping from temporary iframes (same site).
Comments (499) 174 threads
Earlier commentsWell one day a mistake was finally made. Some of the devices went into a sort of loop. They’d start running the important process, something would go wrong, and they’d just retry every few minutes.
We caught the issue almost instantly since we were watching the deploy, and were able to stop updates before any other devices picked it up. But those that already got it were down.
We could ask the devices to send us the output of a command remotely, but it was too limited to be able to send back an error log. We didn’t have time to send back like 255 characters at a time or whatever, we needed to get it fixed ASAP.
And that’s when the genius stupid hack was suggested. While we couldn’t send up a full log file, we could certainly send up something the length of a URL. So what if we sent down a little command to stick the log on PasteBin and send up the URL to us?
Worked like a charm. We could identify what was going wrong and fix it in just a few minutes. After some quick (but VERY thorough) testing everything was fixed.
We had a little HTTP API that it was always talking to. It would call the API to send data back to us or just check in regularly, and we would return to it a little bit of status stuff like the current time to keep clocks in sync, and a list of which “commands” they need to run.
Mostly the commands were things like “your calibration data is out of data, pull an update“ or “a firmware update is available“.
But one of them let us run arbitrary shell commands. The system was very limited. I wasn’t a developer directly on the project but I think it was just our custom software plus busy box and a handful of other things our normal shell scripts used. I assume it had been added after some previous incident.
I believe the basic idea was that during troubleshooting you could tell a box to return the output of “cat /etc/resolv.conf” or something else that we hadn’t preplanned for without having to send someone into the field. But since it was only for small things like that it couldn’t return a full file.
Luckily one of the commands was either curl or wget. So we could send down “curl -whatever /log/path https://pastebin/upload” or whatever it was. I don’t remember if we signed up for a pastebin account so we knew where it would show up or if we had it return URL to us in the output of the curl command.
This suggestion was literally a joke. We were all beating our heads against the wall trying to help and someone just said “why don’t we just stick it on pastebin“ out of frustration, and the developer on the project realized we had what we needed to do that and it would work.
Ssh on remote IoT class devices is works. The problem is rarely ssh, the problem is always some form of key management plus NATs in-between.
If you've got a few thousand devices in the field, public key management can become a a real pain, especially when you want to revoke keys.
Your question comes down to "Why didn't you just deploy bug free code using perfect processes? That's what I always do."
I mean, cmon.
OP's description suggests it was an error that's common to all the deployed instances that received the update, rather than some specific combination of environment and that deployment.
It would have allowed them to run the same deployment locally and use physical access (serial, a display, sd card, whatever) to capture the error log.
What they came up with is clever but it's very surprising that they needed it, especially given that they have very limited remote access to the units that are in the wild.
Continue this thread — 6 replies
So I downloaded the HTML for all pages required for this exact flow and removed the previous sick days. I then changed my etc/hosts file, gave them my computer and prayed that they wouldn’t try to visit any other page than the ones I downloaded.
Worked like a charm. Later I called in sick myself.
I used to do the same with school report cards, which began being delivered electronically when I was in Middle School ;^)
I had a friend whose mom was a programmer and she would help us get the answers to homework problems. I would change variable names and a few other things, but one time we still got caught with way too similar answers.
In order not to get my friend and his mom in trouble, I told the teacher that I had in fact cheated but not from my friend. I stayed up for a few nights learning HTML and other things (well, modifying other code I found) in order to make a blog where a similar question as the homework problem was discussed, so that I could cite it as my source. At first I tried using blogging software but the timestamps are automatically coded as the current date, which wouldn’t work. So I had to make my own blog-looking site from scratch complete with several months worth of content, which was pretty much plagiarized I think.
It was way more effort than actually doing the homework would have been.
Every time it happened, it made for a long heat up cycle to warm the water and rads and eventually the house.
So I built an Arduino controlled NC relay that removed power for 1 minute out of every 120. That was often enough to eliminate the effect of the fault, but not so often that I had concerns about filling too much gas if the boiler ever failed to ignite. 12 failed ignitions per day wouldn’t give a build up to be worried about.
That ~20 lines of code kept it working for several years until the boiler was replaced.
Our boiler has a pump to cycle hot water around the house - this makes it so you get warm water right away when you turn on a faucet and also prevents pipes in exterior walls from freezing in the winter.
This stopped working, the pump is fine but the boiler was no longer triggering it.
I just wired up mains through an esp32 relay board to the pump and configured a regular timer via esphome.
Temperature based logic would be even better but I didn't find a good way to measure pipe temperature yet.
IIRC, I used an RTD that I had left over from a 3D printer upgrade, but an 18B20 would fine as well. A 10K NTC resistor might even be good enough. For what I needed (and I think for what you need), just fixing the sensor to the outside of the pipe [if metal] will give you a usable signal. That sensor was just metal HVAC taped to the front cast iron door of the burner chamber.
But a dead-simple timer solution gets you pretty far as you know.
But as you say, timer works good enough and that means little motivation to continue to work on it -- countless other projects await :)
BTW I've also tuned the timer to run for longer in the morning to get a hot shower ready.
Edit: nice dashboard, what are you using for the chart? I like the vintage look.
Continue this thread — 1 reply
It was a project scheduled for 2-3 months, for a large corporation. The customer wanted a button that a user would click in the old system, requesting a record to be copied over to the new system (Dynamics CRM). Since the systems would be used in parallel for a time, it could be done repeatedly, with later clicks of the button sending updates to the new system.
I designed it to run on an integration server in a dedicated WS, nothing extraordinary. But 3 days before the scheduled end of the project, it became clear that the customer simply will not have the server to run the WS on. They were incapable of provisioning it and configuring the network.
So I came up with a silly solution: hey, the user will already be logged in to both systems, so let's do it in their browser. The user clicked the button in the old system, which invoked a javascript that prepared the data to migrate into a payload (data -> JSON -> Base64 -> URL escape) and GET-ed it in a URL parameter onto a 'New Record' creation form into the new system. That entire record type was just my shim; when its form loaded, it woke another javascript up, which triggered a Save, which triggered a server-side plugin that decoded and parsed the data, which then processed them, triggering like 30 other plugins that were already there - some of them sending data on into a different system.
I coded this over the weekend and handed it in, with the caveat that since it has to be a GET request, it simply will not work if the data payload exceeds the maximum URL length allowed by the server, ha ha. You will not be surprised to learn the payload contained large HTMLs from rich text editors, so it did happen a few times. But it ran successfully for over a year until the old system eventually was fully deprecated.
(Shout out to my boss, who was grateful for the solution and automatically offered to pay for the overtime.)
I’m not quite sure I understand why it was GET though. No way of running something like fetch or (more likely) XMLHTTPRequest?
Not quite. I have a system that uses a custom userscript to create an extra button on certain webpages that, when clicked, scrapes some data from the current page and copies a lightly encoded version to the user's clipboard. They then switch to another webpage and paste it in a box.
I've also gotten data from place to place using scraping from temporary iframes (same site).
Continue this thread — 1 reply
All comments shown.
Couldn't load more comments. Check your connection and try again.