scrogson/romeo

FCM connection

callmeahab opened this issue · 3 comments

Hi,

I'm pretty new to XMPP, so this question might be a bit dumb, but I'm having issue connecting to firebase cloud messaging. I'm currently doing:

    opts = [
      jid: "#{sender_id}@gcm-preprod.googleapis.com",
      password: fcm_server_key,
      host: "gcm-preprod.googleapis.com",
      port: 5236,
      legacy_tls: true,
      require_tls: true,
      preferred_auth_mechanisms: ['PLAIN']
    ]

    {:ok, pid} = Conn.start_link(opts)

    case Conn.send(pid, Stanza.presence) do
      {:error, :closed} ->
        IO.puts(:closed)
      :ok ->
        IO.puts(:ok)
    end

And I'm getting the error:

GenServer #PID<0.193.0> terminating
** (Romeo.Auth.Error) Failed to authenticate using mechanism: "PLAIN"
    (romeo) lib/romeo/auth.ex:64: Romeo.Auth.do_authenticate/2
    (romeo) lib/romeo/transports/tcp.ex:108: Romeo.Transports.TCP.authenticate/1
    (romeo) lib/romeo/transports/tcp.ex:65: Romeo.Transports.TCP.start_protocol/1
    (romeo) lib/romeo/connection.ex:90: Romeo.Connection.connect/2
    (connection) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Last message: nil
State: %Romeo.Connection{component: false, features: %Romeo.Connection.Features{amp?: false, compression?: false, mechanisms: [], registration?: false, stream_management?: false, tls?: false}, host: "gcm-preprod.googleapis.com", jid: "####@gcm-preprod.googleapis.com", legacy_tls: true, nickname: "", owner: #PID<0.192.0>, parser: nil, password: "AAAA_GDKHvs:######", port: 5236, preferred_auth_mechanisms: ['PLAIN'], require_tls: true, resource: "", rooms: [], socket: nil, socket_opts: [], ssl_opts: [], stream_id: nil, timeout: 5000, transport: Romeo.Transports.TCP}

It would also help if someone could point me to an example of using fcm xmpp. I'm trying to send push notifications over fcm.

Thanks

Ok, figured out the connection issue, was supposed to use gcm.googleapis.com instead of gcm-preprod.googleapis.com.
Would still like help with my second question though.

Hi @callmeahab, sorry for the delay. I've posted an answer to your question here: https://elixirforum.com/t/how-can-i-do-xmpp-push-notifications-to-firebase/4329/9

9mm commented

Hey @scrogson I have 2 questions for you:

  1. Do you know how I could implement "CONNECTION_DRAINING" with Romeo? I realize I'm just parsing the XML, but I'm more concerned about the logistics of the actual connection (search "draining" on https://firebase.google.com/docs/cloud-messaging/server)

  2. How do I actually 'intercept' and parse all the replies?

This is a super helpful library, thank you so much for making it!