Test channel got unnatural about that

I had follow guide to test channel, easy way to edit code,
and static compile seems done, then i cant get anything message output in browser console. If its right, it need output ‘Joined successfully’ in console.

20 Dec 06:47:35 - info: compiling
20 Dec 06:47:36 - info: compiled 6 files into 2 files, copied 3 in 7 sec

seems have not seeing socket.js file in firebug network.

channel.join()
  .receive("ok", resp => { console.log("Joined successfully", resp) })
  .receive("error", resp => { console.log("Unable to join", resp) })

already un comment app.js

added room_channel.ex file in web\channels\room_channel.ex

  def join("rooms:lobby", _message, socket) do
    {:ok, socket}
  end
  def join("rooms:" <> _private_room_id, _params, _socket) do
    {:error, %{reason: "unauthorized"}}
  end
end
1 Like

did you remember to un comment or add
import socket from “./socket”
in app.js ?

1 Like

today im restart the project, the console output this msg,

[warn] Ignoring unmatched topic "rooms:lobby" in HelloPhoenix.UserSocket

the browser showing

Unable to join Object { reason="unmatched topic"}
  1. does my static files not compiled before ?
  2. why the webSocket unable to join it ?

The error means that your “rooms:lobby” isn`t defined the same way on the client and server.

if you want to you could share the code with me and we`ll look at it together. would be good practice for me as well. I struggled a bit with the same thing.

If you was occured the same question, you must have to go through the topic that you defined in every where, Actually, when you figured it out, You will found this problem.