Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App doesn't sign in, although Webinterface does #3

Closed
beniroquai opened this issue Jan 23, 2014 · 37 comments
Closed

App doesn't sign in, although Webinterface does #3

beniroquai opened this issue Jan 23, 2014 · 37 comments

Comments

@beniroquai
Copy link

Hello,

I'm getting 'Error 0 while trying to log in' Error when I try to get into the Heimcontrol installation.
I can access it via the Browser of my phone with same credentials..Is there something I have to follow to get everything write?
It's a Sony Xperia Phone on 4.3 Android by the way.

Thanks, Awesome Project!

@JorisM
Copy link
Owner

JorisM commented Jan 24, 2014

Thanks for your feedback.

Did you try to set the url in the settings page? The icon is on the top right and please note that if your heimcontrol instance is running on something else than port 80, you need to specifiy the port in the url, for example: http://heimcontrol:8080/

@beniroquai
Copy link
Author

Yep! I've tried the DynDns URL as well as the local network URL. Same URL and credentials are working over the browser though..
It's in the form http://mydomain.dyndns.org:8080/, then Email@provider.com and a password which contains signs like ?!§$).. Icannot see any errors in the adb console. The Error is comming in the same moment, when pressing the button connect. I think its not even checking, that the server is availiable..

The adb logs are pointing to something like
01-24 11:13:54.164: D/alsa_ucm(859): Setting mixer control: RX3 MIX1 INP2, value: ZERO
01-24 11:13:54.164: D/alsa_ucm(859): Setting mixer control: LINEOUT1 Volume, value: 0
01-24 11:13:54.164: D/alsa_ucm(859): Setting mixer control: SLIM TX3 MUX, value: ZERO
01-24 11:13:54.174: D/alsa_ucm(859): Setting mixer control: SLIM TX5 MUX, value: ZERO
....

Thanks

@JorisM
Copy link
Owner

JorisM commented Jan 24, 2014

Do you have the newest version of heimcontroljs? We only just recently added the API support, so if you have an older version there won't be an api endpoint.

@beniroquai
Copy link
Author

Installed the app and heimcontrol.js just yesterday. How could I update?

@JorisM
Copy link
Owner

JorisM commented Jan 24, 2014

If you pulled from github then you will have the newest version 👍

Can you try to make a post request in the terminal like:
curl -d '{"email":"youremail@domain.com","password":"your_password"}' http://yoururl/api/login --header "Content-Type:application/json"

and tell me what you get back?
The answer should look similar to this:
{ "token": "your_token_is_here" }

@beniroquai
Copy link
Author

Thank you for this excellent support. Maybe wrong version which is installed? Getting this code:

SyntaxError: Unexpected token }
at Object.parse (native)
at /home/pi/heimcontrol.js/node_modules/connect/lib/middleware/json.js:75:25
at IncomingMessage.onEnd (/home/pi/heimcontrol.js/node_modules/connect/node_modules/raw-body/index.js:109:7)
at IncomingMessage.g (events.js:175:14)
at IncomingMessage.EventEmitter.emit (events.js:92:17)
at _stream_readable.js:883:14
at process._tickCallback (node.js:415:13)curl: (6) Couldn't resolve host 'api'

@JorisM
Copy link
Owner

JorisM commented Jan 24, 2014

Check whether in the heimcontrol.js file (in your local heimcontrol js repo) around line 147 you find this route:
app.post('/api/login', Routes.createAuthToken);

If you don't have this route you have a wrong version of heimcontroljs.

@beniroquai
Copy link
Author

Thank you ver much again! I checked and decided to reinstall heimcontrol.js.. I'll get back. By the way. Is there a chance to push a http-request directly to the Pi? I opened an issue for this. I would like to switch a rc-socket by an url or so. Do you know if this is possible?

@JorisM
Copy link
Owner

JorisM commented Jan 24, 2014

I don't think heimcontrol supports this yet, although I think one could pretty easily add that. I don't have an rc socket that I could try it out with, but I might have some time next week to look into it (if you can wait that long ;)). If you feel like you could do it on your own, I could give you some tips to point you in the right direction on how to implement it. Once it's implemented in heimcontrol, I think I could pretty easily add the functionality to the heimdroid app.

@beniroquai
Copy link
Author

I would love to try, but I'm not the kind of programmer. More consumer ;)..

Checked the file:
sudo nano ~/heimcontrol.js

Around Line 147
app.post('/api/login', Routes.createAuthToken);

Seems to be correct!

Another Issue:
After a post somewhere in a forum I added this: (or else I will get the error: "events.js:2817: Uncaught Error: Cannot open /dev/")

sudo nano ~/heimcontrol.js/node_modules/duino/lib/board.js
search around line 75 for 'ls /dev | grep ACM' or similar and change it to:
'ls /dev | grep -e usb -e USB -e ACM'

Same again, Browser is working, App not. Seems API is missing. Wonder why?!

@JorisM
Copy link
Owner

JorisM commented Jan 24, 2014

Alright, did you check for this line app.post('/api/login', Routes.createAuthToken); though in heimcontrol.js? Try the curl request again

I will look into the rx socket feature when I have some spare time.

@beniroquai
Copy link
Author

Hm. I'm getting a Token now. So thats alright. But App..Still not working.
I did the following:
1.)Settings-> URL: http://myname.dyndns.org:8080/ (also tried without /)
2.)Login: MyEmail@bla.com
3.)Password: MyPW

Still Error 0 :D.. Sorry dude..

I think there is no connection to the network..although my phone is connected to it. How can I check it?

@JorisM
Copy link
Owner

JorisM commented Jan 24, 2014

Alright, getting a token is a good sign:)
If you can access heimcontrol through your browser on your phone the app should work as well.

@beniroquai
Copy link
Author

I'm sorry. I tried everything. Token is there, browser access works, but the app still doesnt sign in. Is there a problem in Android 4.3 or so? Server Adress is 100 % correct, Credentials as well. Reinstalled the app, still no success. Is there a permission missing?

@JorisM
Copy link
Owner

JorisM commented Jan 25, 2014

I actually run 4.3 myself, and I have tried it on 4.2 and 4.4 on other phones as well, it seems to work fine, although I've never tried it with dynds but a direct ip instead and always connected to the wifi on the same network. I think you might be running into some problem with your router firewall or the firewall of the host you are running heimcontrol on. Are you running heimcontrol on a raspberry? What linux distribution?

@beniroquai
Copy link
Author

Hi. I really tried everything. Even enterring a random URL. The Error comes in the exact same moment. I will attache some screenshots of my nexus 7 which runs on cyanogen (perhaps thats the issue here?)

screenshot_2014-01-25-11-09-58
screenshot_2014-01-25-11-10-49
screenshot_2014-01-25-11-12-01
screenshot_2014-01-25-11-12-08

Sorry, I think it's a problem with my devices. Bummer ;)

@JorisM
Copy link
Owner

JorisM commented Jan 25, 2014

Thanks for the screenshots, they help. I assume you tried to add a / at the end of the url, so ...8080/.

In the terminal window where you started heimconroljs with node, what does it print out the moment you hit the button?

Lastly, one thing you could try to do is change your heimcontrol instance to port 80 and try again without a port.

Bear with me, i still hope to figure out where the problem is.

@JorisM
Copy link
Owner

JorisM commented Jan 25, 2014

Ps: i run the pacman mod myself, so the mod shouldnt be a problem

@beniroquai
Copy link
Author

Well, actually I don't know how to change the port. I'm also running a small apache websever on port 80.. NATTING the port in the router doesnt help? I hope Apache, doesn't interfer with the API? Yes, I tried with and witout the :8080/

What do you mean by printing out when hitting the button? The Login-button in the App? Terminal-Windows stays the same. Can I get a logfile from the app? In Logcat I can't see any errors..
When I type the curl .. then the Terminal-Windows says "POST /api/login 200 139ms - 81b" so API is working.

@JorisM
Copy link
Owner

JorisM commented Jan 25, 2014

You started heimcontrol with node heimcontrol.js. Afther you saw a screen where it gave you the /dev/ access denied error. That terminal session will log any requests going into heimcontroljs. If you hit the log in button, or go onto the heimcontrol webpage you should see every request being made (and errors if there are any).

@beniroquai
Copy link
Author

I tried the Terminal-thing, but as I described whithout any success. When I log in via the browser and via the "curl", that it gives me a feedback, but when I try to login with the app, there is nothing, no GET/POST message from the APP

I also tried another port (80), but there is no server-ping I guess..Hm. Well. Anyway. Never mind! ;)

@JorisM
Copy link
Owner

JorisM commented Jan 30, 2014

I'm going to close this for now, I'll let you know when I figure out what the problem might be.

@JorisM JorisM closed this as completed Jan 30, 2014
@beniroquai
Copy link
Author

Hi. Just wanted to get back. I completely reinstalled everything, but still doesn't work ;)..
In Addition: I had the idea to get a http-request to control a state. Like https://blalba/switch1_on.php or something. Right now it's not secure, because it's just a php-exec which calls duino. Do you have any clue how to do this with the API? Together with email and password though? I'm using tasker for this. So, when I'm entering my flat. Music is already running :D

@JorisM
Copy link
Owner

JorisM commented Feb 6, 2014

With the token you get, you can send a socket event called gpio-toggle to the server to changes the toggle state. Use the token from the api as the auth token and find a socket library to make the request. Check out the heimcontrol docs to figure out which fields to pass (I think it's value (1 or 0 depending whether you want to turn it on or off) and id for which toggle you want to trigger).

@beniroquai
Copy link
Author

Oh. Man you're fast ;).. I looked it up as you said. But honestly I don't really know how to start this (I've hardly knowledge of Javascript or Node.js). If you have some spare time, could you feed me with the right keywords I've to search for on google?

Do I need to write a script and place it on the webserver or can I call the heimcontrol.js app directly with an URL which contains the information of the token and GPIO on/off?

The passage you told me says the following:

/**

  • Parse GPIO the ports that are used as input and send the result to the client websocket
    *
  • @method parse
    */
    Gpio.prototype.parse = function() {
    var that = this;
    if (that.app.get('clients').length > 0) {
    that.app.get('db').collection(this.collection, function(err, collection) {
    collection.find({
    direction: 'input'
    }).toArray(function(err, result) {
    result.forEach(function(item) {
    gpio.setDirection(parseInt(item.pin), "input", function(err) {
    gpio.read(parseInt(item.pin), function(err, value) {
    if (!err) {
    that.values[item._id] = value;
    that.app.get('sockets').emit('gpio-input', {
    id: item._id,
    value: value
    });
    }
    });
    });
    });
    });
    });
    }
    };

/**

  • Manipulate the items array before render
    *
  • @method beforeRender
  • @param {Array} items An array containing the items to be rendered
  • @param {Function} callback The callback method to execute after manipulation
  • @param {String} callback.err null if no error occured, otherwise the error
  • @param {Object} callback.result The manipulated items
    */
    Gpio.prototype.beforeRender = function(items, callback) {
    var that = this;
    items.forEach(function(item) {
    item.value = that.values[item._id] ? that.values[item._id] : 0;
    });
    return callback(null, items);
    };

/**

  • API functions of the GPIO Plugin
    *
  • @method api
  • @param {Object} req The request
  • @param {Object} res The response
    */

Gpio.prototype.api = function(req, res, next) {
/*

  • GET
    */
    if (req.method == 'GET') {
    this.app.get('db').collection(this.collection, function(err, collection) {
    collection.find({}).toArray(function(err, items) {
    if (!err) {
    res.send(200, items);
    } else {
    res.send(500, '[]');
    }
    });
    });
    } else {
    next();
    }
    };

var exports = Gpio;

return exports;

});

found here: http://ni-c.github.io/heimcontrol.js/api/files/plugins_gpio_index.js.html#l114

Thank you very much! :)

@JorisM
Copy link
Owner

JorisM commented Feb 6, 2014

I think it would be much easier to get the app working than try to implement something yourself with socket. Sockets can be somewhat tricky to work with. I've been kind of busy with work, but I will try a dyndns setup as soon as possible to figure out what your problem might have to do with. I'm guessing it's a firewall or selinux issue, hard to tell.

@p33k
Copy link

p33k commented Feb 11, 2014

I have the same problem. Just installed the latest heimcontrol.js on my new raspberry pi and set everything up.
Connecting via PC, Laptop, Smartphones, Tablets all works with the browser but with the app (apk from your homepage) I get the error 0.
set the raspberry pi IP in the options: http://192.168.2.10:8080 and tried even with different users, but I always directly get the error 0.
On my PI console with heimcontrol running I see no reaction.

What firewall could be a problem? I don't have a firewall active on my smartphone and router firewall should be no problem? Is there a firewall on the raspberry pi with raspberian that could be a problem?

@JorisM JorisM reopened this Feb 12, 2014
@JorisM
Copy link
Owner

JorisM commented Feb 13, 2014

Alright, I think I might have found the bug.

Can one of you try to install version 0.1.2 (newest link) and report back please?

@p33k
Copy link

p33k commented Feb 13, 2014

http://jorism.github.io/Heimdroid/app/heimdroid.apk
is this the current version? I download it and install it directly on my phone.
Android app settings shows me version 0.1.2.
The error 0 is still there with that version.
Furthermore, if I type in 192.168.2.10:8080 without the http:// the app crashes.

@JorisM
Copy link
Owner

JorisM commented Feb 13, 2014

0.1.2 is the correct version. does the app have full network access?
screenshot_2014-02-13-19-00-46

@p33k
Copy link

p33k commented Feb 13, 2014

correction: with my android tablet the login worked immediately with the use of alias instead of IP
http://homecontrol:8080
Then after some trying it works on my smartphone too?!?!
Edit: and now it even works with the IP.
But now I have another problem after login it goes to a screen with the headline "Switches" on top but the the rest is white.

I currently use webcam, RGB, and Arduino modules on the home screen of heimcontrol

screenshot_2014-02-13-22-06-50

@beniroquai
Copy link
Author

Same here. Although i use switches. But great for the solution to login
Am 13.02.2014 22:05 schrieb "p33k" notifications@github.com:

correction: with my android tablet the login worked immediately with the
use of alias instead of IP
http://homecontrol:8080

Then after some trying it works on my smartphone too?!?!

But now I have another problem after login it goes to a screen with the
headline "Switches" on top but the the rest is white.

I currently use webcam, RGB, and Arduino modules on the home screen of
heimcontrol

Reply to this email directly or view it on GitHubhttps://github.com//issues/3#issuecomment-35025729
.

@p33k
Copy link

p33k commented Feb 13, 2014

Third correction: my mistake, heimdroid currently only supports GPOI switches?
Added some for test reasons, that works!

screenshot_2014-02-13-22-25-17

Is webcam, arduino, etc support planned? Or would I have to try to do it on my own?

@JorisM
Copy link
Owner

JorisM commented Feb 14, 2014

Alright, thank you very much for your help!

I only use the GPIO toggles, so far I didn't have a reason for implementing any other features.
I was planning on adding other modules as well, which one would be the most useful for you right now?

@JorisM JorisM closed this as completed Feb 14, 2014
@beniroquai
Copy link
Author

Awesome work mate. Rcswitch for duino would be perfekt <3
Am 14.02.2014 09:06 schrieb "Joris" notifications@github.com:

Alright, thank you very much for your help!

I only use the GPIO toggles, so far I didn't have a reason for
implementing any other features.
I was planning on adding other modules as well, which one would be the
most useful for you right now?

Reply to this email directly or view it on GitHubhttps://github.com//issues/3#issuecomment-35063728
.

@beniroquai
Copy link
Author

I don't know if anybody saw it. But power consumption of the app seems very high although the Phone is in Standby.

@JorisM
Copy link
Owner

JorisM commented Feb 14, 2014

This is because the socket is always open even in standy. I can add a feature to turn this off and only reconnect when the app is resumed. Can you please open an issue for this? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants