bananaphone
I am trying to wrap the WebSockex library so that it is initialized asynchronously, and if the websocket source is unavailable or becomes unavailable, the application stays alive and just retries in 60 seconds. To this end I have created a GenServer, and in its init callback I am doing Process.send_after(self(), :websocket_connect, 0) and my handle_info looks like this:
try do
with {:ok, pid} <-
WebSockex.start_link(
url,
MyHandler,
{},
async: false,
handle_initial_conn_failure: true
) do
Logger.info("Success starting websocket.")
...
rescue
e ->
Logger.error("Runtime error establishing websocket connection")
Process.send_after(self(), :websocket_connect, 60_000)
{:noreply, state}
end
If I call WebSockex.start_link inside a GenServer start_link the command works. If I put it in my handle_info callback it fails with:
14:21:38.470 [error] ** (WithClauseError) no with clause matching: {:function_clause, {WebSockex, :call, [%WebSockex.Conn{conn_mod: :gen_tcp, host: (bunch of websocket connection info)
What am I doing wrong? Is it not possible to call this function outside of another start_link? Or is this an issue with WebSockex?
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex










Showing Posts 1 to 3- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
al2o3cr
How is the code you’ve posted connected to the error message? It’s tricky to say for sure without a stack trace, but I don’t see any
withstatements inside the implementation ofWebSockex.start_linkso it doesn’t seem directly related.The error is also concerning: the thing it’s trying to match looks like an exception payload (
{:function_clause, {WebSockex, :call, [%WebSockex.Conn{) caused by something trying to callWebSockex.call(conn, ...)which isn’t a function defined inWebSockex.bananaphone
Yeah from what I can tell it looks like WebSockex is trying to do a callback on the module its
start_linkis called from, although when I look through the code on GitHub I don’t see it doing that, I am new to Elixir so I’m not so great at reading it yet though. (EDIT: it is not doing this.)Mainly I was hoping someone on here could tell me if, categorically, calling
start_linkon a process thingy in ahandle_infois not allowed or this is probably some kind of WebSockex problem. Now I am leaning toward WebSockex problem. The docs for WebSockex say it is implemented as a “special process.”Basically I am trying to write wrapper code that asynchronously starts websocket connections and can just retry on a delay if the remote connection isn’t available yet, as a way to make my application more resilient, as it should continue to run even if it can’t establish a websocket connection yet. This thread and comment was the impetus: How to make a Supervisor **never** die? - #23 by brucepomeroy
WebSockex doesn’t seem amenable to this since I can’t start it outside
start_linkso I might have to just get better at Elixir and fork the project.bananaphone
Completely by accident I found the problem, I really was using the library wrong. I completely restructured the code and then Dialyzer told me I was doing something wrong (don’t know why it didn’t complain before or why the original error message was so misleading.) The mistake is not relevant to the question so I won’t clutter the thread with it.