phoenix-chat-example icon indicating copy to clipboard operation
phoenix-chat-example copied to clipboard

Feedback from a beginner

Open rub1e opened this issue 7 years ago • 6 comments

@nelsonic As promised, here is some feedback:

Getting started

I already had Phoenix and Elixir installed, and that's straightforward anyway.

Postgres, on the other hand :confounded:

I did have postgres installed from testing out the dwylbot docs, so I just started psql and ran lsof -i :5432. No output at all.

So I did various things like checking ports were open and restarting the services and a dozen things I found in SO answers or linux blogs etc. No change.

So I figured that it might be because there were multiple postgres instances or I'd set it up wrong in the first place - so I purged postgres entirely and started from scratch.

Now, this may be because I'm not amazing with linux or just generally quite mediocre at doing the coding things, but I still couldn't get any output from running the lsof command, unless I switched to the postgres user by sudo -i -u postgres.

(I had precisely followed https://github.com/dwyl/learn-postgresql all the way up to, but not including, installing PostGIS).

Sod it

By this point I'd spend far more than a single :tomato:, so I figured I'd just start the server without the database and just play around with that until it broke.

The server very kindly decided to run and let me access the page despite the c. 100 postgres-related errors in the terminal.

Because of the generosity of the whole thing not crashing despite multiple errors, I was then able to follow the tutorial quite easily and get the app working to an extent.

Until...

ecto.create

BOOM :boom: :boom:

Once I ran that, all the postgres errors disappeared and lsof -i :5432 output the right thing and the whole app worked as it should and I was able to complete the tutorial (though I haven't had time to deploy to heroku).

Recommendations

Once I'd a) ignored the errors and then b) fixed the errors, the tutorial was great - easy to follow and with good, clear explanations.

Breakdowns like the one at https://github.com/dwyl/phoenix-chat-example#7-generate-database-schema-to-store-chat-history are very useful, for example.

So for me the key amendments needed are:

  • Getting postgres up and running. I'm happy to attribute my failure to operator error, but I really did try everything I could find online to get it started.
    • If you can guess what I did wrong, perhaps include a warning
    • If not, perhaps consider adding some guidance in case the "pre-flight checks" fail
    • Or maybe move the mix ecto.create command earlier (though I accept that doing this would mess with the flow of the tutorial)
  • Getting everything up and running generally - might be an idea to tell people which steps of the installation guides to follow - specifically maybe say "Follow the postgres tutorial but stop before installing postGIS"?
  • Small point, and probably because I only skimmed the basics of Phoenix/Elixir, but when we had to update the room_channel.ex and message.ex files, I added the new functions def outside the module def (i.e. at the very bottom of the file)
    • Now, because I'm not totally devoid of coding instincts, I noticed my error quite swiftly (because I figured defmodule probably defs a whole module duh) - but it might be worth adding a note to point out precisely where the function goes

rub1e avatar Mar 03 '18 12:03 rub1e

Hi @rub1e thanks (so much) for making time to go through the tutorial steps on your machine!! 🎉

Are you still using a ChromeBook (running Ubuntu via "Crouton"?) ? (that should be fine, especially if you were able to run the dwylbot project ...)

I think we need to improve our Linux instructions on https://github.com/dwyl/learn-postgresql ... 🤔 Struggling for more than a 🍅 just to get PostgreSQL to cooperate is painful! 😞

I suspect that the issue might be that your PostgreSQL on localhost is not using the default username & password (expected by phoenix to be postgres and postgres as per: dev.exs#L54-L55 ...)

Good point on "follow" PostgreSQL installation instructions except PostGIS. I feel the instructions in the learn-postgresql should be improved first for clarity. 👍

Well spotted on the placement of the functions in room_channel.ex and messages.ex ... 🙄 Must make that clearererer. thanks!

nelsonic avatar Mar 06 '18 12:03 nelsonic

Are you still using a ChromeBook

Yeah, but not for this - I used a proper machine with 8gb ram and everything! 😊

I think we need to improve our Linux instructions

Maybe, but I'm inclined to think my issues arose because of me rather than you 😉 . Basic installation really wasn't that hard to follow

rub1e avatar Mar 06 '18 18:03 rub1e

I'm getting this error (FunctionClauseError) no function clause matching in ChatWeb.RoomChannel.handle_info/2

mjames21 avatar Mar 19 '18 17:03 mjames21

@mjames21 thanks for sharing your feedback! Would you mind opening a new issue and giving a bit more detail?

  • please give the full "stack trace"
  • which stage in the tutorial did you get the error?
  • which OS you are using Thanks!

nelsonic avatar Mar 20 '18 11:03 nelsonic

It is fixed now, I missed out some detail before. I'm using Ubuntu 16

Thanks for the concern [warn] Ignoring unmatched topic "topic:subtopic" in ChatWeb.UserSocket [info] JOIN "room:lobby" to ChatWeb.RoomChannel Transport: Phoenix.Transports.WebSocket (2.0.0) Serializer: Phoenix.Transports.V2.WebSocketSerializer Parameters: %{} [info] Replied room:lobby :ok [error] GenServer #PID<0.392.0> terminating ** (FunctionClauseError) no function clause matching in ChatWeb.RoomChannel.handle_info/2 (chat) lib/chat_web/channels/room_channel.ex:26: ChatWeb.RoomChannel.handle_info(:after__join, %Phoenix.Socket{assigns: %{}, channel: ChatWeb.RoomChannel, channel_pid: #PID<0.392.0>, endpoint: ChatWeb.Endpoint, handler: ChatWeb.UserSocket, id: nil, join_ref: "30", joined: true, private: %{log_handle_in: :debug, log_join: :info}, pubsub_server: Chat.PubSub, ref: nil, serializer: Phoenix.Transports.V2.WebSocketSerializer, topic: "room:lobby", transport: Phoenix.Transports.WebSocket, transport_name: :websocket, transport_pid: #PID<0.372.0>, vsn: "2.0.0"}) (phoenix) lib/phoenix/channel/server.ex:258: Phoenix.Channel.Server.handle_info/2 (stdlib) gen_server.erl:616: :gen_server.try_dispatch/4 (stdlib) gen_server.erl:686: :gen_server.handle_msg/6 (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3 Last message: :after__join State: %Phoenix.Socket{assigns: %{}, channel: ChatWeb.RoomChannel, channel_pid: #PID<0.392.0>, endpoint: ChatWeb.Endpoint, handler: ChatWeb.UserSocket, id: nil, join_ref: "30", joined: true, private: %{log_handle_in: :debug, log_join: :info}, pubsub_server: Chat.PubSub, ref: nil, serializer: Phoenix.Transports.V2.WebSocketSerializer, topic: "room:lobby", transport: Phoenix.Transports.WebSocket, transport_name: :websocket, transport_pid: #PID<0.372.0>, vsn: "2.0.0"} [info] JOIN "room:lobby" to ChatWeb.RoomChannel Transport: Phoenix.Transports.WebSocket (2.0.0) Serializer: Phoenix.Transports.V2.WebSocketSerializer Parameters: %{} [info] Replied room:lobby :ok

mjames21 avatar Mar 20 '18 11:03 mjames21

Hi @rub1e thanks (so much) for making time to go through the tutorial steps on your machine!! tada

Are you still using a ChromeBook (running Ubuntu via "Crouton"?) ? (that should be fine, especially if you were able to run the dwylbot project ...)

I think we need to improve our Linux instructions on https://github.com/dwyl/learn-postgresql ... thinking Struggling for more than a tomato just to get PostgreSQL to cooperate is painful! disappointed

I suspect that the issue might be that your PostgreSQL on localhost is not using the default username & password (expected by phoenix to be postgres and postgres as per: dev.exs#L54-L55 ...)

Good point on "follow" PostgreSQL installation instructions except PostGIS. I feel the instructions in the learn-postgresql should be improved first for clarity. +1

Well spotted on the placement of the functions in room_channel.ex and messages.ex ... roll_eyes Must make that clearererer. thanks!

Here is how to set postgres default password, that should be postgres:

https://stackoverflow.com/questions/12720967/how-to-change-postgresql-user-password

hgc2002 avatar Aug 18 '19 19:08 hgc2002

What if we provide alternate steps to using a Postgres docker image via the 'Docker Desktop'? A UI is more beginner-friendly and would give some minor exposure to Docker containers.

Edit: I know I am ~4 years late :)

EarliestFall988 avatar Jan 09 '23 17:01 EarliestFall988

@EarliestFall988 good question. ❓ We tend to try and minimise the number of dependencies/requirements in our tutorials so adding Docker would be a pretty major side-quest for many beginners who have zero experience of any of this. Even though we have a dwyl/learn-docker repo, Docker Desktop is massive so people with lower internet bandwidth (believe-it-or-not there are still people on 500kbs connections with download caps!) would suffer if we implied that it was a requirement for running this example. 💭

nelsonic avatar Jan 10 '23 04:01 nelsonic

@rub1e thanks again for this valuable feedback. 🙏 We will make it clearer that Postgres is a requirement in the next iteration of this tutorial. #149 👍

nelsonic avatar Feb 03 '23 07:02 nelsonic