3

I'm relatively new at Elixir and Phoenix (which is probably the reason I have no idea what's going on).

I'm trying to set up Ueberauth on a Phoenix app with Google authentication.

I followed the sample app https://github.com/ueberauth/ueberauth_example as faithfully as I could figure.

I prepared the app for Heroku like the Phoenix docs say. The home page shows up properly. When I click on my button to start the auth process, I get as far as Google and Google asks me if I do want to authenticate. When I click yes, I get an internal server error and I don't really know what's going on with it.

Here's what I have in the logs:

2016-03-24T04:02:14.429507+00:00 app[web.1]: 04:02:14.429 [error] #PID<0.364.0> running GreatStrides.Endpoint terminated

2016-03-24T04:02:14.429520+00:00 app[web.1]: Server: MYHEROKUAPP:80 (http)

2016-03-24T04:02:14.429521+00:00 app[web.1]: Request: GET /auth/google/callback?code=ACODEGOESHERE

2016-03-24T04:02:14.429522+00:00 app[web.1]: ** (exit) exited in: :gen_server.call(:hackney_manager, {:new_request, #PID<0.364.0>, #Reference<0.0.1.2373>, {:client, :undefined, {:metrics_ng, :metrics_dummy}, :hackney_ssl_transport, 'accounts.google.com', 443, "accounts.google.com", [], nil, nil, nil, true, :hackney_pool, 5000, false, 5, false, 5, nil, nil, nil, :undefined, :start, nil, :normal, false, false, false, :undefined, false, nil, :waiting, nil, 4096, "", [], :undefined, nil, nil, nil, nil, :undefined, nil}}, :infinity)

2016-03-24T11:54:59.195968+00:00 app[web.1]: ** (EXIT) no process

What's going on here?

Trevoke
  • 4,115
  • 1
  • 27
  • 48

1 Answers1

2

This should be a comment, but it was too long.

Do you have any other errors? Because this looks incomplete.

When something is wrong in Elixir application, supervision tree makes sure that all processes that encountered the error die. That is why you can see the first line GreatStrides.Endpoint terminated.

Second and third line is just a normal log.

Fourth line is an error calling gen_server. It prints the function call with all three arguments: server, request, timeout. You can inspect arguments if they are correct, but those are some internals of hackneys client record. GenServer client just waits for answer here for infinite amount of time - nothing should go wrong.

This means there should be another crash report from inside GenServer. It can be similar to previous one. There you should be able to find actual reason. If the GenServer crashes while doing its work, all clients waiting for answer are notified that it exited.

EDIT: After edits by @Trevoke

The problem was that the hackney gen_server was not running and this caused the error. Checking with Application.loaded_applications proved that hackney application is not running at all and it needs to be added to applications section in mix.exs.

tkowal
  • 9,129
  • 1
  • 27
  • 51
  • That's part of the problem. That's all the logs I see. The line right before it is "GET /auth/google/callback". I don't know how to increase logging, and I can't tell how to try and test this locally, either. – Trevoke Mar 24 '16 at 11:53
  • Okay, there was one more line. I added it. It says `(EXIT) no process". – Trevoke Mar 24 '16 at 12:26
  • This means that the `:hackney_manager` process never existed. Is it started? Can you check `Application.loaded_applications`? Is `:hackney` there? What happens when you type `Application.start(:hackney)`? – tkowal Mar 24 '16 at 15:10
  • I used `iex -S mix` to check. `:hackney` is not in the list. Trying to start hackney yields this: `{:error, {:not_started, :idna}}` – Trevoke Mar 25 '16 at 22:06
  • Okay, so: I added `:httpoison` to the list of applications in `mix.exs` and that did the trick. Now I just don't know *why* this happened and why I have this mismatch between my code and the sample app I linked to above. – Trevoke Mar 25 '16 at 23:54
  • If at least one of dependencies in entire tree of dependencies starts hackney (lists it in applications in `mix.exs`), it should be available for entire system. Not sure what more I can do to debug this. – tkowal Mar 26 '16 at 09:05
  • Well, you've been instrumental. The rest is a conversation I need to have upstream. Thank you for your help! I'm going to mark your answer as accepted; I would request that you edit it to add that the problem is `:hackney` not running, along with the `Application.loaded_applications` command. – Trevoke Mar 26 '16 at 11:41