TheThingSystem / steward

The Thing System is a set of software components and network protocols that aims to fix the Internet of Things. Our steward software is written in node.js making it both portable and easily extensible. It can run on your laptop, or fit onto a small single board computer like the Raspberry Pi.
http://thethingsystem.com
Other
346 stars 81 forks source link

Trying to get started... #255

Closed LarrySteeze closed 10 years ago

LarrySteeze commented 10 years ago

I have an issue I was hoping I could git a bit of help with.

Monday night, I downloaded the newest version of the Raspberry Pi (model B) image (1.9) and hoped to familiarize myself with the user side of the steward and how it worked before hopefully diving into the developer side at a later time. Unfortunately, I’ve run into a couple issues, one of which was my fault.

First, I couldn’t figure out why mdns was not working for me (was running on a newly formatted windows machine, without Bonjour installed). This one was my fault. I didn’t realize this was happening until this morning when it clicked, so I will install Bonjour or try it on another machine tonight.

Second, when I manually type in the IP address, I use port 8888, and the initial page loads up just fine. However, when I click through to create an account, it directs me to 127.0.0.1:8887 and does not load appropriately. When I then change the domain back to the IP and the port back to 8888, it brings me to the account (master) creation page. I’m not sure why this happens this way, it could be in the code, specifying localhost (or the IP) as opposed to “./” or something of the sort, or could be something completely different.

Third, typing in the account, then the description and continuing gives me the success message and a QR code! Yay! I use Google Authenticator to generate a time-based password, and that’s where things get quirky. When I test the password (verifying the username is correct, including the /#), it tells me it is an invalid pair and to check the time. I verify the time on my phone. I log in to the console and check the time. Odd, it’s set to GMT…so I set the time zone to EST (my time zone) and reboot the steward. I then try again. Unfortunately, I get the same issue, so I check the time again. This time, it reports the correct time zone (good, at least I did that correctly), but unfortunately, the time sync appears to be off, as the Pi thinks it’s 4 hours earlier than it is. I take the opportunity to correct the pi and set the time manually this time. I test it without rebooting. Then I test it again with rebooting. Unfortunately, it never works to get through the account creation form. I tried this a few times (re-flashing the image to the sd card a few times) and completing all of the timezone/set steps before reflashing as well.

Has anyone else experienced this issue with a resolution? Am I doing something wrong?

Much appreciated in advance. Cheers,

LarrySteeze

cubeinhabitant commented 10 years ago

I too am currently the authentication problem on my Pi as well right now. For the time being I have been choosing to not use authentication to get around the problem so that I can continue using the Steward, but I have been hoping that this issue would be tracked down.

Issue #254 reported a similar problem but the user closed the issue because after reinstalling the image and starting from scratch on the Pi the authentication issue went away. But knowing why this issue appears may be helpful in case it pops up again for other users.

LarrySteeze commented 10 years ago

Thanks for the response cubeinhabitant. I had seen that issue, but as it was closed, I figured it best to start a new issue. In addition, I did try exactly as he had to no avail.

As a quick update, I installed the bonjour printer service on my windows machine and mdns worked with no issue and eliminated the 127.0.0.1 redirect. Unfortunately, that's the only issue it resolved.

mrose17 commented 10 years ago

hi. sorry for the delay in replying. sorry to hear that you're having these difficulties.

the time-based one-time passwords require that the clocks be a few seconds within each other; otherwise, it's a #sadfail.

let me make sure i understand your environment:

  1. you are running the steward on an RPi, using the 1.9 image. you are trying to access the steward via a web browser on another system on the same network.
  2. initially, when you were trying to use steward.local, the browser failed because your browser's computer didn't have mDNS installed, so you switched to using the IP address of the RPI, e.g., http://192.168.1.7:8887
  3. did that redirect you to https://127.0.0.1:8888 or https://192.168.1.7:8888 - it should have done the latter, if not let me know.
  4. when you finally got through to https://192.168.1.7:8888, you got to client.html and created an account with a QR code and google authenticator liked it!
  5. however, the RPi doesn't seem to want to keep time/timezone correctly. if you set the correct information, then after a reboot, it goes sideways again.

is that the gist of it? if so, very frustrating, sorry!

first, let me know about the answer to #3.

second, the first thing to do is to get the timezone correct. this is what i do:

    % ssh pi@192.168.1.7
    pi@steward ~ $ sudo bash
    root@steward:/etc# cd /etc
    root@steward:/etc# rm localtime
    root@steward:/etc# ln -s /usr/share/zoneinfo/PST8PDT localtime

you will want to use the correct file from /usr/share/zoneinfo for your timezone. after that, when you do date, you'll see something like this:

    pi@steward ~ $ date
    Thu Jul 10 09:35:57 PDT 2014

the next step is to see if that time matches (more or less) what's on your phone. if not, use the date command as root to set it. at this point, when the pi reboots, the time should be OK.

you may also want to look at http://www.kossboss.com/linux---maintaining-time-on-debian---datetime-and-ntp-client-and-server - which indicates how to set-up ntpdate, etc.,

let me know how it goes. thanks!

LarrySteeze commented 10 years ago

Thanks for the response! My answers are as follows:

  1. Yes. I am running the 1.9 image on an rpi. The laptop and rpi are sharing a switch on my network during initial setup.
  2. Correct. mDNS was not working because it was not set up on my machine. I’ve got this resolved.
  3. Not quite. Typing in the IP address worked for the initial screen. I did not type port 8887, I used port 8888. Unfortunately, when I clicked client (as opposed to developer), it redirected me to the “localhost” ip address and port. More specifically, https://127.0.0.1:8887. I manually changed them back to the actual static IP I assigned the rpi, a la https://192.168.1.5:8888/[whatever followed by default], which resolved my issue. I’m not sure if leaving the port “as-is” would have redirected me but I can test tonight if needed. I was trying to do it the “right way” before trying to break it.
  4. Correct. Authenticator liked it.
  5. Sort of. The rpi is syncing with ntp servers but seems to have my timezone wrong by default, throwing me in GMT. I change the timezone using dpkg-reconfigure ntp and it holds my timezone, reporting as EST. After a reboot, it still lists as EST. Unfortunately, both before and after the reboot, it was showing as 4 hours earlier than it really was (it was about 10:30 PM and was reporting at 6:30 PM. Odd. Next, I manually changed the time manually, syncing to the second to my android phone, but received the same time issue. Date reports the correct time after doing it manually, but on every one of these steps, I’m receiving the same error on the steward login.

I’ll test with your method of changing the time zone tonight and report back once I have the opportunity. Hopefully I can get it working as I’d rather spend my time trying to add new devices than just getting in. :-)

LarrySteeze commented 10 years ago

Ok. I've tried several more times today. Each time with the same result as the other day. The time matches up within a second (less than a second actually). It holds on to the time zone through a reboot.

I still can't authenticate.The exact error is "invalid clientID/response pair (check your clock)"

mrose17 commented 10 years ago

i'm not sure what's going on with the authentication, so let's bypass it. try this:

    % sudo sh /etc/init.d/steward stop
    % rm steward/steward/db/users.db
    % sudo sh /etc/init.d/steward start

then go to https://192.168.1.5:8888/ and select developer mode. from that point on, you ought to be able to get some work done.

mrose17 commented 10 years ago

@ae9f - danny: may i impose on you to take a look at this one issue. start with a vanilla RPi, go to https://192.168.1.xyz:888 and you see this: 1 if you then click on create account, you get this: 2 in which you are reditected to 127.0.0.1:8887/client.html?clientURL=... thanks!

LarrySteeze commented 10 years ago

@mrose17 I reverted to 1.8 and got it to work the first time. Then I tried again with a vanilla 1.9 image and returned to the same issues.

Perhaps it's worth taking some time to look at the changelog then go through commits. has anyone else successfully completed the steps on a vanilla 1.9 image?

mrose17 commented 10 years ago

i thought i had checked that. let me check again. thanks for your patience!

mrose17 commented 10 years ago

definitely something fishy here...

mrose17 commented 10 years ago

got it.... sorry about that. if you go back to 1.9, do

    % cd steward ; git pull

and it will update you to "the latest". it's a one-line fix, but it went it with a bunch of other things...

LarrySteeze commented 10 years ago

I'll check on it tonight. Thanks.

Nice to not have to compile!

mrose17 commented 10 years ago

agreed! - thank @aallan for doing all the hard work (it takes about a day to do each image!)

LarrySteeze commented 10 years ago

Hmm.

I don't have a beaglebone or most of the devices that are currently supported, but I'm happy to help with the creation of the raspi images in the future.