Packard_Goose

Packard_Goose

Issue with Websockex and json encoding

I’m trying to send a message using websockex but I’m getting an error when I try to send out my json string (I used Jason), what could I possibly be missing?

"{\"action\":\"subscribe\",\"options\":{\"accounts\":[\"nano_1qzfp3op48im348qdybmrheu9dogtopj1jyioguq9pyo5i7mkqgo4jaswp4a\"],\"all_local_accounts\":true},\"topic\":\"confirmation\"}"
** (ArgumentError) argument error
    :erlang.send(MitoNode.Client, {:"$websockex_cast", "{\"action\":\"subscribe\",\"options\":{\"accounts\":[\"nano_1qzfp3op48im348qdybmrheu9dogtopj1jyioguq9pyo5i7mkqgo4jaswp4a\"],\"all_local_accounts\":true},\"topic\":\"confirmation\"}"})
    (websockex) lib/websockex/utils.ex:57: WebSockex.Utils.send/2
    (websockex) lib/websockex.ex:398: WebSockex.cast/2

Marked As Solved

NobbZ

NobbZ

That just delegates the start of the client to its start_link/1, IIRC.

But in that, do you actually name the started process?

Last Post!

CamonZ

CamonZ

You can also use the pid of the WebSockex process and WebSockex.send_frame/2 to send the data. e.g.

{:ok, pid} = MyWebSockexWrapper.start_link()


msg = Jason.encode!(%{
    "action" => "subscribe",
    "topic" => "confirmation",
    "options" => %{
      "all_local_accounts" => true,
      "accounts" => [
        "nano_1qzfp3op48im348qdybmrheu9dogtopj1jyioguq9pyo5i7mkqgo4jaswp4a"
      ]
    })

WebSockex.send_frame(pid, {:text, msg})

Where Next?

Popular in Questions Top

RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
joeerl
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
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New

Other popular topics Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
Darmani72
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
sergio_101
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
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

We're in Beta

About us Mission Statement