necromorph23

necromorph23

Hello Everyone,

I am trying to create a Chat app like whatsapp and i have bascially read every other discussion on the forum regarding this topic and decided to use ejabberd (because i want to store messages when the reciever is offline , and security was also an issue.). I have also watched few implementations of Ejabberd in Phoenix Application.

Though i still have few doubts, i am already halfway through my application (its an application with many features chat is just a part of it) and i have my own Auth system in application which is working, my question is do i still need to use something like ejabberd.auth() and get JID from it to initiate my Chat stuff and from where can anyone give me some resources to understand the docs.

There is a lot of stuff and it’s quite overwhelming, also if anyone can give me some github link or anything if this stuff has already been implemented by someone else so that i can have a look.

Any help would be appreciated. Thanks for listening.

Showing Posts 1 to 8

derek-zhou

derek-zhou

It seems like you have a lot to share; why not share whatever you have first?

necromorph23

necromorph23 OP

Alright let’s start with the simple stuff

  1. My application is what you could say is like Reddit + WA. I am almost done with the reddit part and decided to look into how am i going to implement the WA one.

  2. Initially i thought i could just work with Websockets but they don’t provide all the services i needed. Like media transfers and how am i going to store messages for offline users and then deliver it.

  3. Thats why i researched more and decided to go with Ejabberd.

The difficult stuff.

  1. I have seen little bit of documentation and few implementation of Ejabberd in elixir but still not able to understand how am i going to implement one-to-one chat and multi user chat and also Video/Voice calls.

  2. Researched a little bit more then i came to know about JID (Jabber ID) and then i realized (i might be wrong here) that Ejabberd basically calls functions like
    ejabberdctl send_message chat 192.168.33.50 user1@192.168.33.50 “subject” “message from server”

and i guess here “user1@192.168.33.50” is acting like the JID.

The confusion part:-

  1. I already have implemented basic Auth system with email and password but for chat functionality i think i need to generate somekind of JID as well i guess?

  2. Even after i generate JID lets say how do i implement these one-to-one and multi user chat in my application because Ejabberd docs are some what confusing to me.

This basically sums up my problem.
Now few additional questions that i have if anyone can answer them
Q1) Should i use MNESIA or Postgresql as Database? (For my reddit part i am using PostgreSQL)

Q2) Do we generate JID again and again when user connects to the internet or it is generated only once when user first registers?

derek-zhou

derek-zhou

You ask a lot of questions like “Should I …” These questions are generally unanswerable because we do not know your situation as good as you. If you can re-phrase your question into non-subjective and isolated question you can greatly increase your chance of getting help, and the helpers and on-lookers, etc can benefit from the discussion as well.

JeyHey

JeyHey

Q1: If you store the messages only until they are delivered and then delete them - giving the client the responsibility to store them (like WA does it) then I would say mnesia is good choice. If you want to store them on the server potentially indefinitely and make the client query them each time (like FB) then I would say Postgres is a better choice. But it is difficult to say and depends on a lot of factors.

Q2: A JID needs to be generated only once per user. But you don’t even need to as you can reuse your existing auth. All you need to do is to store it in a way Ejabberd can access it. Then, with a minimal amount of logic, you can make your client just construct the JID for authentication with Ejabberd und Ejabberd check the credentials. A JID has the following form: [username]@[serverdomain]/[resource]. Make Ejabberd aware of the domain and set a random constant resource.

At the end of the day, Ejabberd implements the XMPP protocol. So it would certainly not be a bad idea to take a look at the following book if you haven’t already: https://www.amazon.com/XMPP-Definitive-Real-Time-Applications-Technologies/dp/059652126X

necromorph23

necromorph23 OP

Thanks for all the insights. Though i am facing a new problem now. I have been trying to install ejabberd in my phoenix app i am getting this error.

I have tried to downgrade ejabberd but it does not seem to be working. This is my mix.exs

defmodule ChatTest.MixProject do
  use Mix.Project

  def project do
    [
      app: :chat_test,
      version: "0.1.0",
      elixir: "~> 1.13.4",
      elixirc_paths: elixirc_paths(Mix.env()),
      compilers: [:gettext] ++ Mix.compilers(),
      start_permanent: Mix.env() == :prod,
      aliases: aliases(),
      deps: deps()
    ]
  end

  # Configuration for the OTP application.
  #
  # Type `mix help compile.app` for more information.
  def application do
    [
      mod: {ChatTest.Application, []},
      extra_applications: [:logger, :runtime_tools, :ejabberd]
    ]
  end

  # Specifies which paths to compile per environment.
  defp elixirc_paths(:test), do: ["lib", "test/support"]
  defp elixirc_paths(_), do: ["lib"]

  # Specifies your project dependencies.
  #
  # Type `mix help deps` for examples and options.
  defp deps do
    [
      {:phoenix, "~> 1.6.13"},
      {:phoenix_ecto, "~> 4.4"},
      {:ecto_sql, "~> 3.6"},
      {:postgrex, ">= 0.0.0"},
      {:phoenix_live_dashboard, "~> 0.6"},
      {:swoosh, "~> 1.3"},
      {:telemetry_metrics, "~> 0.6"},
      {:telemetry_poller, "~> 1.0"},
      {:gettext, "~> 0.18"},
      {:jason, "~> 1.2"},
      {:plug_cowboy, "~> 2.5"},
      {:absinthe, "~> 1.7"},
      {:absinthe_plug, "~> 1.5"},      
      {:ejabberd, "~> 22.5", github: "processone/ejabberd"}
    ]
  end

  # Aliases are shortcuts or tasks specific to the current project.
  # For example, to install project dependencies and perform other setup tasks, run:
  #
  #     $ mix setup
  #
  # See the documentation for `Mix` for more info on aliases.
  defp aliases do
    [
      setup: ["deps.get", "ecto.setup"],
      "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
      "ecto.reset": ["ecto.drop", "ecto.setup"],
      test: ["ecto.create --quiet", "ecto.migrate --quiet", "test"]
    ]
  end
end

Do you have any idea how can i solve this?

Hermanverschooten

Hermanverschooten

Try to remove the version number.

necromorph23

necromorph23 OP

Update: The app has compiled but when i start my phoenix server i am getting this error.

When i commented mod_irc in ejabberd.yml. I got this error.

Just for the context i was referring to this guide
Embedding Ejabberd in your Phoenix App

necromorph23

necromorph23 OP

New updated. I just had to make few changes to ejabberd.yml it seems to be working now. my phoenix app is also running.

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
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
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
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
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
ryanwinchester
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted” Version...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
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
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews