Cinderella-Man / hands-on-elixir-and-otp-cryptocurrency-trading-bot

Source code to generate the "Hands-on Elixir & OTP: Cryptocurrency trading bot" book
https://elixircryptobot.com
263 stars 34 forks source link

Unable to start Streamer app with Phoenix.PubSub #21

Closed JoseMPena closed 3 years ago

JoseMPena commented 3 years ago

I've been following along the book as a practice method until I found myself blocked with the following issue: Environment: Elixir 1.11.4 Erlang/OTP 23

Relevant code snippet

# apps/streamer/lib/streamer/application.ex
def start(_type, _args) do
    children = [
      {
        Phoenix.PubSub,
        name: Streamer.PubSub, adapter_name: Phoenix.PubSub.PG2
      }
    ]

    opts = [strategy: :one_for_one, name: Streamer.Supervisor]
    Supervisor.start_link(children, opts)
  end

Expected: iex -S mix starts the application correctly.

Actual result: iex -S mix produces error: ** (Mix) Could not start application streamer: Streamer.Application.start(:normal, []) returned an error: shutdown: failed to start child: Phoenix.PubSub.Supervisor ** (EXIT) shutdown: failed to start child: Phoenix.PubSub.PG2 ** (EXIT) exited in: :gen_server.call(Phoenix.PubSub, {:join_local, Streamer.PubSub.Adapter, #PID<0.251.0>}, :infinity) ** (EXIT) no process: the process is not alive or there's no process currently associated with the given name, possibly because its application isn't started

Besides changing the Elixir/OTP versions, I see no way of debugging this. Any idea?

Cinderella-Man commented 3 years ago

Hello :wave:

Thanks for opening an issue. I assume that you are going through the 3rd chapter? I just cloned the branch, and "it works on my machine"(R), but I have different Elixir/OTP versions. Have you tried to clone the repository(branch called chapter_03) and run it? If it works for you, then you would have a side-by-side chance to debug what's wrong with the code (if anything).

JoseMPena commented 3 years ago

Hello πŸ‘‹

Thanks for opening an issue. I assume that you are going through the 3rd chapter? I just cloned the branch, and "it works on my machine"(R), but I have different Elixir/OTP versions. Have you tried to clone the repository(branch called chapter_03) and run it? If it works for you, then you would have a side-by-side chance to debug what's wrong with the code (if anything).

Hey! Thank you for your quick response! Followed your advice and compared side to side and, as it turns out, I was installing the phoenix_pubsub dependency in the naive application instead of streamer. πŸ€¦β€β™‚οΈ

Now it works as expected.

Cinderella-Man commented 3 years ago

It happens to the best of us :wink: if you don't mind, I will totally steal this ticket template that you used here - I will just add a "chapter" section to it :slightly_smiling_face: Thank you for that :+1:

Happy reading - I hope you will get some value out of it! :rocket:

JoseMPena commented 3 years ago

It happens to the best of us πŸ˜‰ if you don't mind, I will totally steal this ticket template that you used here - I will just add a "chapter" section to it πŸ™‚ Thank you for that πŸ‘

Happy reading - I hope you will get some value out of it! πŸš€

Hi: Please do use the template and adapt it for your needs! BTW Thank you for the book. It's an enjoyable and utterly useful read πŸ˜‰

Best,