Maxtonx
Argument error in genserver start_link call
I’m using a Romeo library to connect to an XMPP client GitHub - scrogson/romeo: An XMPP Client for Elixir · GitHub.
the connection is simple when I’m using the mention steps in docs
alias Romeo.Stanza
alias Romeo.Connection, as: Conn
opts = [jid: "romeo@montague.lit", password: "iL0v3JuL137"]
# Start the client
{:ok, pid} = Conn.start_link(opts)
Till this, it’s working fine.
So now the same thing I’m doing using genserver
def start_link(config) do
GenServer.start_link(__MODULE__, xmpp_config, name: @name)
end
def init(config) do
opts = [jid: xmpp_config.jid, password: xmpp_config.password]
{:ok, conn} = Conn.start_link(opts)
{:ok, %{conn: conn, user_name: xmpp_config.user_name, rooms: [], queue: []}}
end
config = [jid: “romeo@montague.lit”, password: “iL0v3JuL137”]
trying to pass this config calling start_link function and passing config as the argument. But I’m getting argument error
{:error,
{:badarg,
[
{:erlang, :apply,
[[jid: "romeo@montague.lit", password: "iL0v3JuL137"], :jid, []], []},
{Testapp.XMPPClient, :init, 1,
[file: 'lib/testapp_web/channels/xmpp_client.ex', line: 12]},
{:gen_server, :init_it, 2, [file: 'gen_server.erl', line: 374]},
{:gen_server, :init_it, 6, [file: 'gen_server.erl', line: 342]},
{:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 249]}
]}}
** (EXIT from #PID<0.1152.0>) shell process exited with reason: an exception was raised:
** (ArgumentError) argument error
:erlang.apply([jid: "romeo@montague.lit", password: "iL0v3JuL137"], :jid, [])
(testapp 0.1.0) lib/testapp_web/channels/xmpp_client.ex:12: Testapp.XMPPClient.init/1
(stdlib 3.12.1) gen_server.erl:374: :gen_server.init_it/2
(stdlib 3.12.1) gen_server.erl:342: :gen_server.init_it/6
(stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
What am I missing here?
Marked As Solved
lud
Your config seems to be a Keyword and not a Map, so I guess you have to call config[:jid] and not config.jid.
0
Last Post!
Maxtonx
Popular in Questions
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
If I have a post route which an argument:
post /my_post_route/:my_param1, MyController.my_post_handler
How would get the post params ...
New
Hi,
I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
Hello all!
I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
Hello everyone,
I try to use an Javascript Event Handler in my root.html.leex file.
Therefore I created a function in the app.js file: ...
New
Hi!
Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]
15:22:35.803 [error] gen_event {lager_file_backend...
New
Other popular topics
Hi,
I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
What is the proper way to load a module from a file in to IEX?
In the python world, doing something like this pretty standard:
from ....
New
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
i’m a new one to elixir
which editor can i use
vs code? or atom?
Thanks! :smiley:
New
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
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex










