coen.bakker
Presence in LiveView: `ERROR: 1st argument: the table identifier does not refer to an existing ETS table`
I am trying to use the Phoenix.Presence behaviour in my LiveView. I intend to use it to track a channel topic on the LiveSocket, rather than initiating a new socket connection (i.e. UserSocket). There are several online resources covering this topic (e.g. Phoenix Presence with Phoenix LiveView · FullstackPhoenix), but I keep running into an error.
The error in a nutshell: 1st argument: the table identifier does not refer to an existing ETS table. I believe this ‘1st argument’ refers to self() in:
Presence.track(
self(),
"story",
socket.assigns.current_user.id,
%{}
)
I have been looking around for solutions and trying to debug the code, but the error remains. I would like to understand what the issue is.
Below all the relevant source code and error messaging.
defmodule TodayCostoryWeb.Presence do
use Phoenix.Presence, otp_app: :today_costory,
pubsub_server: TodayCostory.PubSub
end
defmodule TodayCostory.Application do
use Application
@impl true
def start(_type, _args) do
children = [
...
{Phoenix.PubSub, name: TodayCostory.PubSub},
TodayCostoryWeb.Presence,
TodayCostoryWeb.Endpoint
]
opts = [strategy: :one_for_one, name: TodayCostory.Supervisor]
Supervisor.start_link(children, opts)
end
end
defmodule TodayCostoryWeb.StoryLive do
use TodayCostoryWeb, :live_view
alias TodayCostoryWeb.Presence
...
def mount(_params, session, socket) do
socket =
assign_new(
socket,
:current_user,
fn ->
Accounts.get_user_by_session_token(session["user_token"])
end
)
if connected?(socket) do
Presence.track(
self(),
"story",
socket.assigns.current_user.id,
%{}
)
TodayCostoryWeb.Endpoint.subscribe("story")
end
...
{:ok, socket}
end
[error] GenServer #PID<0.20718.0> terminating
** (ArgumentError) errors were found at the given arguments:
* 1st argument: the table identifier does not refer to an existing ETS table
(stdlib 3.17.1) :ets.lookup(TodayCostoryWeb.Presence, :pool_size)
(phoenix_pubsub 2.1.1) lib/phoenix/tracker.ex:314: Phoenix.Tracker.pool_size/1
(phoenix_pubsub 2.1.1) lib/phoenix/tracker.ex:134: Phoenix.Tracker.track/5
(today_costory 0.1.0) lib/today_costory_web/live/story_live.ex:27: TodayCostoryWeb.StoryLive.mount/3
(phoenix_live_view 0.17.11) lib/phoenix_live_view/utils.ex:301: anonymous fn/6 in Phoenix.LiveView.Utils.maybe_call_live_view_mount!/5
(telemetry 1.1.0) /Users/macbookpro2021/Documents/dev/today_costory/deps/telemetry/src/telemetry.erl:320: :telemetry.span/3
(phoenix_live_view 0.17.11) lib/phoenix_live_view/channel.ex:1001: Phoenix.LiveView.Channel.verified_mount/8
(phoenix_live_view 0.17.11) lib/phoenix_live_view/channel.ex:59: Phoenix.LiveView.Channel.handle_info/2
(stdlib 3.17.1) gen_server.erl:695: :gen_server.try_dispatch/4
(stdlib 3.17.1) gen_server.erl:771: :gen_server.handle_msg/6
(stdlib 3.17.1) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Last message: {Phoenix.Channel, %{"params" => %{"_csrf_token" => "IhU7Am8bOgAoPxABEhstPCURMnkEGgN5AAtP9UMemjDxpQbrGzPI5J25", "_mounts" => 0, "_track_static" => ["http://localhost:4000/assets/app.css", "http://localhost:4000/assets/app.js"]}, "session" => "SFMyNTY.g2gDaAJhBXQAAAAIZAACaWRtAAAAFHBoeC1GeElZMkZVZE9GVng4M1RuZAAMbGl2ZV9zZXNzaW9uaAJkAAdkZWZhdWx0bggAhhhAP7ANEhdkAApwYXJlbnRfcGlkZAADbmlsZAAIcm9vdF9waWRkAANuaWxkAAlyb290X3ZpZXdkACBFbGl4aXIuVG9kYXlDb3N0b3J5V2ViLlN0b3J5TGl2ZWQABnJvdXRlcmQAHUVsaXhpci5Ub2RheUNvc3RvcnlXZWIuUm91dGVyZAAHc2Vzc2lvbnQAAAAAZAAEdmlld2QAIEVsaXhpci5Ub2RheUNvc3RvcnlXZWIuU3RvcnlMaXZlbgYAVK7dD4MBYgABUYA.cGrahkmk2vmiMJkMvsmJaMN21ic8YHPR_DiblXj6QrU", "static" => "SFMyNTY.g2gDaAJhBXQAAAADZAAKYXNzaWduX25ld2wAAAABZAAMY3VycmVudF91c2VyamQABWZsYXNodAAAAABkAAJpZG0AAAAUcGh4LUZ4SVkyRlVkT0ZWeDgzVG5uBgBUrt0PgwFiAAFRgA.xlF3G3iTjebpn47eOjRIqvj9YPL2nRKS1sX1qlvl1aY", "url" => "http://localhost:4000/"}, {#PID<0.20712.0>, #Reference<0.2939426857.1123287043.49659>}, %Phoenix.Socket{assigns: %{}, channel: Phoenix.LiveView.Channel, channel_pid: nil, endpoint: TodayCostoryWeb.Endpoint, handler: Phoenix.LiveView.Socket, id: "users_sessions:i0LCd7tjBpn7KYtPTQtTT_eJmxSlFOVAB6pG_SIV0vU=", join_ref: "4", joined: false, private: %{connect_info: %{session: %{"_csrf_token" => "cTORVNweEUTybJONbkb01P1L", "live_socket_id" => "users_sessions:i0LCd7tjBpn7KYtPTQtTT_eJmxSlFOVAB6pG_SIV0vU=", "user_token" => <<139, 66, 194, 119, 187, 99, 6, 153, 251, 41, 139, 79, 77, 11, 83, 79, 247, 137, 155, 20, 165, 20, 229, 64, 7, 170, 70, 253, 34, 21, 210, 245>>}}}, pubsub_server: TodayCostory.PubSub, ref: nil, serializer: Phoenix.Socket.V2.JSONSerializer, topic: "lv:phx-FxIY2FUdOFVx83Tn", transport: :websocket, transport_pid: #PID<0.20712.0>}}
State: #Reference<0.2939426857.1123287043.49661>
[error] an exception was raised:
** (ArgumentError) errors were found at the given arguments:
* 1st argument: the table identifier does not refer to an existing ETS table
(stdlib 3.17.1) :ets.lookup(TodayCostoryWeb.Presence, :pool_size)
(phoenix_pubsub 2.1.1) lib/phoenix/tracker.ex:314: Phoenix.Tracker.pool_size/1
(phoenix_pubsub 2.1.1) lib/phoenix/tracker.ex:134: Phoenix.Tracker.track/5
(today_costory 0.1.0) lib/today_costory_web/live/story_live.ex:27: TodayCostoryWeb.StoryLive.mount/3
(phoenix_live_view 0.17.11) lib/phoenix_live_view/utils.ex:301: anonymous fn/6 in Phoenix.LiveView.Utils.maybe_call_live_view_mount!/5
(telemetry 1.1.0) /Users/macbookpro2021/Documents/dev/today_costory/deps/telemetry/src/telemetry.erl:320: :telemetry.span/3
(phoenix_live_view 0.17.11) lib/phoenix_live_view/channel.ex:1001: Phoenix.LiveView.Channel.verified_mount/8
(phoenix_live_view 0.17.11) lib/phoenix_live_view/channel.ex:59: Phoenix.LiveView.Channel.handle_info/2
(stdlib 3.17.1) gen_server.erl:695: :gen_server.try_dispatch/4
(stdlib 3.17.1) gen_server.erl:771: :gen_server.handle_msg/6
(stdlib 3.17.1) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Marked As Solved
coen.bakker
Thank you for your replies.
It ended up being the most ‘are you sure it’s plugged into the wall?’ type of situations. I forgot to restart the server. It works now.
Hope this thread saves somebody in the future some time.
Also Liked
al2o3cr
The “1st argument” here refers to the first argument being passed to :ets.lookup inside the implementation of Tracker:
I’m not sure how this could go wrong, given that the table is created a handful of lines above in Tracker.init ![]()
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









