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

500 error logging in #7

Closed
aaronfranco opened this issue Oct 27, 2015 · 15 comments
Closed

500 error logging in #7

aaronfranco opened this issue Oct 27, 2015 · 15 comments
Labels

Comments

@aaronfranco
Copy link

I have the demoApp running on docker. When I log in with Facebook, the Telepat-api server log shows the following error.

| POST /device/register 200 3.243 ms - 50
octopusapi_1           | GET /context/all 304 10.052 ms - -
octopusapi_1           | undefined
octopusapi_1           | POST /user/login 500 20021.805 ms - 151

Then, on the front end, it results in this console error output.


telepat.js:362 Telepat: Login failed with error: Error: Internal Server Error
(anonymous function) @ telepat.js:362
error @ telepat.js:626
(anonymous function) @ telepat.js:912
(anonymous function) @ telepat.js:126
Request.callback @ telepat.js:36995
(anonymous function) @ telepat.js:36647
Emitter.emit @ telepat.js:30687
xhr.onreadystatechange @ telepat.js:37072
telepat.js:362 Telepat: Emitting login_error event

When I list my apps, here are the credentials that I see and use in my demoApp.

➜  telepat-js git:(develop) ✗ telepat list apps
Admin login OK.
[ { name: 'Test Application',
    keys: [ 'testApiKey' ],
    admins: [ 'f4d558ec-49c8-44ae-aaf0-95dca43c00dd' ],
    id: 'b378415b-7f88-4574-a90d-aef470453b2e',
    created: 1445910189,
    modified: 1445910189,
    schema: { comments: [Object], events: [Object] } } ]

Please let me know if I'm missing anything.

@aaronfranco
Copy link
Author

Here is the error message coming back from the server

message: "{"error":{"code":"ENOTFOUND","errno":"ENOTFOUND","syscall":"getaddrinfo","hostname":"graph.facebook.com"}}"

@Mayhem93
Copy link
Member

It seems that your docker machine can't access the outer world (facebook.com more specifically). I'm not a specialist in docker. @andreimarinescu can you have a look ? :)

@aaronfranco
Copy link
Author

I resolved this issue by switching my VM from NAT network to Bridged Network. I'm not 100% sure, but it seems to me that NAT would be the correct setup for a cloud deployment like AWS. However, I'm not sure it works for OSX local deployment.

@aaronfranco
Copy link
Author

I'm not sure that is the correct solution since I'm not getting the 500 error again.

@aaronfranco aaronfranco reopened this Oct 27, 2015
@aaronfranco
Copy link
Author

I have to restart both the backend and worker/api using docker-compose to stop the 500 error. Now I get this error:

Error: User email is not publicly available (insufficient facebook permissions)
octopusapi_1           |     at /usr/src/app/controllers/user.js:85:18
octopusapi_1           |     at /usr/src/app/node_modules/facebook-node/facebook-node.js:531:21
octopusapi_1           |     at Request._callback (/usr/src/app/node_modules/facebook-node/facebook-node.js:348:21)
octopusapi_1           |     at Request.self.callback (/usr/src/app/node_modules/facebook-node/node_modules/request/main.js:120:22)
octopusapi_1           |     at Request.emit (events.js:110:17)
octopusapi_1           |     at Request.<anonymous> (/usr/src/app/node_modules/facebook-node/node_modules/request/main.js:555:16)
octopusapi_1           |     at Request.emit (events.js:107:17)
octopusapi_1           |     at IncomingMessage.<anonymous> (/usr/src/app/node_modules/facebook-node/node_modules/request/main.js:517:14)
octopusapi_1           |     at IncomingMessage.emit (events.js:129:20)
octopusapi_1           |     at _stream_readable.js:908:16
octopusapi_1           |     at process._tickCallback (node.js:355:11)

Which seems like an error with my Facebook app setup, however my app is set up correctly and my email is publicly available, so not sure why that error is occuring.

@aaronfranco
Copy link
Author

perhaps the issue is that the API doesn't explicitly request the "email" field. I noticed on line 85 of the users.js API the code reads:

FB.napi('/me', {access_token: accessToken}, function(err, result) {

Perhaps this should read the following.

FB.napi('/me?fields=name,email,id', {access_token: accessToken}, function(err, result) {

@Mayhem93
Copy link
Member

That just tells facebook you want those respective fields, if they are missing (in your case, email address) you're not getting it anyway. The access_token you give to the API dictates the permissions. You should look how the access_token is requested.

@aaronfranco
Copy link
Author

Actually, in v2.5 of the Facebook API, you need to explicitly request the email field. You can test this in the Facebook Graph explorer.

https://developers.facebook.com/tools/explorer

@Mayhem93
Copy link
Member

Well, if it works you can commit the changes and make a pull request 👍

@aaronfranco
Copy link
Author

will do 👍 👍

@andreimarinescu
Copy link
Member

Thanks, @aaronfranco. This change actually sounds reasonable from my point of view, let us know if we can further help in testing this out.

@aaronfranco
Copy link
Author

Cool, thanks! I think the issue here is that new users can only deploy Facebook v2.5 apps. Even if v2.3 is requested, Facebook automatically upgrades the request to v2.5. This makes it impossible for any new users to properly test the demoApp successfully because the demo and API are built with v2.3 which is now depreciated for all new Facebook apps.

@andreimarinescu
Copy link
Member

@aaronfranco Yes, you can use the shared docker compose file along with a cloned copy of telepat-api. You can also edit the API out of the telepat docker compose file, and just run the workers via docker.
The API, after cloning the repo, has to be configured to work with your kafka and elasticsearch deployments. This can be done by copying the config.example.json to config.json and editing the correct IP addresses, or directly via ENV variables (you can use the Dockerfile for an example of what they are).

Hope this helps!

@aaronfranco
Copy link
Author

Thanks! Sorry about that. I realized that solution after I posted the comment, then I deleted the comment.

@Mayhem93
Copy link
Member

Mayhem93 commented Nov 3, 2015

Should be fixed now, the cause was human error 😝 . I was referring to the wrong variable when looking for the email field.

I included those fields like you suggested. Thanks a lot ! 😀

@Mayhem93 Mayhem93 added the bug label Nov 6, 2015
@Mayhem93 Mayhem93 closed this as completed Nov 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants