Giter VIP home page Giter VIP logo

romeo's People

Contributors

bobbprice avatar dch avatar djmaze avatar jbr avatar jhowarth avatar kelsadita avatar picaoao avatar sabudaye avatar scrogson avatar tsharju avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

romeo's Issues

error function :crypto.rand_bytes/1 is undefined or private

Hi i'm trying to use romeo for fcm.

With:
{:ok, pid} = Conn.start_link(params)
i receive this log:


[info] Established connection to fcm-xmpp.googleapis.com
[info] Negotiating secure connection
[info] Connection successfully secured
[debug] [[email protected]]
[OUTGOING] "<stream:stream to='gcm.googleapis.com' version='1.0' xml:lang='en' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
[debug] [[email protected]]
[INCOMING] "<stream:stream from=\"gcm.googleapis.com\" id=\"7Bxxxx147A02E00A\" version=\"1.0\" xmlns:stream=\"http://etherx.jabber.org/streams\" xmlns=\"jabber:client\">"
[debug] [[email protected]]
[INCOMING] "<stream:features><mechanisms xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\"><mechanism>X-OAUTH2</mechanism><mechanism>X-GOOGLE-TOKEN</mechanism><mechanism>PLAIN</mechanism></mechanisms></stream:features>"
[info] Authenticating with PLAIN
[debug] [[email protected]]
[OUTGOING] "<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>xxxxxx</auth>"
[debug] [[email protected]]
[INCOMING] "<success xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\"/>"
[info] Authenticated successfully
[debug] [[email protected]]
[OUTGOING] "<stream:stream to='gcm.googleapis.com' version='1.0' xml:lang='en' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"
[debug] [[email protected]]
[INCOMING] "<stream:stream from=\"gcm.googleapis.com\" id=\"xxxxxBAA404\" version=\"1.0\" xmlns:stream=\"http://etherx.jabber.org/streams\" xmlns=\"jabber:client\">"
[debug] [[email protected]]
[INCOMING] "<stream:features><bind xmlns=\"urn:ietf:params:xml:ns:xmpp-bind\"/><session xmlns=\"urn:ietf:params:xml:ns:xmpp-session\"/></stream:features>"
[error] GenServer #PID<0.1127.0> terminating
** (UndefinedFunctionError) function :crypto.rand_bytes/1 is undefined or private
    (crypto) :crypto.rand_bytes(2)
    (romeo) lib/romeo/stanza.ex:340: Romeo.Stanza.id/0
    (romeo) lib/romeo/stanza.ex:148: Romeo.Stanza.iq/2
    (romeo) lib/romeo/transports/tcp.ex:119: Romeo.Transports.TCP.bind/1
    (romeo) lib/romeo/transports/tcp.ex:66: 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:249: :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: "fcm-xmpp.googleapis.com", jid: "[email protected]", legacy_tls: true, nickname: "", owner: #PID<0.1126.0>, parser: nil, password: "xxxx", port: 5235, preferred_auth_mechanisms: [], require_tls: true, resource: "", rooms: [], socket: nil, socket_opts: [], ssl_opts: [], stream_id: nil, timeout: 5000, transport: Romeo.Transports.TCP}
[info] Application 

Is there a problem in romeo?
Thanks

Useful to add connection info to messages sent to owner

This has come up for us in testing where we start multiple Romeo.Connections in a test. It's difficult to verify which connection received a stanza or bound to a resource. Could we add the underlying connection to the messages or a ref?

Could not compile dependency :fast_xml

Hi, I got the following an error when do mix deps.get

Log :

===> Fetching rebar3_hex ({pkg,<<"rebar3_hex">>,<<"6.8.0">>})
===> Version cached at /home/caramel/.cache/rebar3/hex/default/packages/rebar3_hex-6.8.0.tar is up to date, reusing it
===> Fetching hex_core ({pkg,<<"hex_core">>,<<"0.5.0">>})
===> Version cached at /home/caramel/.cache/rebar3/hex/default/packages/hex_core-0.5.0.tar is up to date, reusing it
===> Fetching verl ({pkg,<<"verl">>,<<"1.0.1">>})
===> Version cached at /home/caramel/.cache/rebar3/hex/default/packages/verl-1.0.1.tar is up to date, reusing it
===> Compiling verl
===> Compiling hex_core
===> Compiling rebar3_hex
===> Fetching pc ({pkg,<<"pc">>,<<"1.10.0">>})
===> Version cached at /home/caramel/.cache/rebar3/hex/default/packages/pc-1.10.0.tar is up to date, reusing it
===> Compiling pc
===> Compiling fast_xml
===> Compiling /home/caramel/Projects/xmpp_client_elixir/deps/fast_xml/c_src/fxml.c
===> In file included from /usr/lib/erlang/erts-10.4.4/include/erl_nif.h:31:0,
                 from /home/caramel/Projects/xmpp_client_elixir/deps/fast_xml/c_src/fxml.c:18:
/usr/lib/erlang/erts-10.4.4/include/erl_drv_nif.h:158:12: fatal error: sys/types.h: No such file or directory
 #  include <sys/types.h>
            ^~~~~~~~~~~~~
compilation terminated.

** (Mix) Could not compile dependency :fast_xml, "/home/caramel/.mix/rebar3 bare compile --paths="/home/caramel/Projects/xmpp_client_elixir/_build/dev/lib/*/ebin"" command failed. You can recompile this dependency with "mix deps.compile fast_xml", update it with "mix deps.update fast_xml" or clean it with "mix deps.clean fast_xml"

Can you determine what actually happens? Thank you

Anonymous login not working

In case we use anonymous login, the Stanza.auth method is throwing an exception saying that the :xmlel is not valid. This is because in this case the body field of the method is not being set in case we use this type of authentication.

certificate unknown - failed_to_decode_certificate

The hedwig project uses XMPP adapter. Self-signed certificate are used for Openfire.

  • Elixir 1.5
  • Erlang/OTP 20
config :mybot, MyBot.Robot,
  adapter: Hedwig.Adapters.XMPP,
  name: "jbot",
  aka: "/",
  jid: "[email protected]",
  port: 5222,
  password: "secret",
  require_tls: true,
  responders: [
    {Hedwig.Responders.Help, []},
    {Hedwig.Responders.Ping, []}
  ]
17:25:14.426 [info]  Negotiating secure connection

17:25:14.468 [error] SSL: :certify: ssl_handshake.erl:420:Fatal error: certificate unknown - failed_to_decode_certificate


17:25:14.469 [error] GenServer #PID<0.193.0> terminating
** (MatchError) no match of right hand side value: {:error, {:tls_alert, 'certificate unknown'}}
    (romeo) lib/romeo/transports/tcp.ex:99: Romeo.Transports.TCP.upgrade_to_tls/1
    (romeo) lib/romeo/transports/tcp.ex:90: Romeo.Transports.TCP.maybe_start_tls/1
    (romeo) lib/romeo/transports/tcp.ex:64: 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: nil, jid: "[email protected]", legacy_tls: false, nickname: "jbot", owner: #PID<0.192.0>, parser: nil, password: "secret", port: 5222, preferred_auth_mechanisms: [], require_tls: true, resource: "", rooms: [], socket: nil, socket_opts: [], ssl_opts: [], stream_id: nil, timeout: 5000, transport: Romeo.Transports.TCP}

17:25:14.470 [error] GenServer #PID<0.194.0> terminating
** (MatchError) no match of right hand side value: {:error, {:tls_alert, 'certificate unknown'}}
    (romeo) lib/romeo/transports/tcp.ex:99: Romeo.Transports.TCP.upgrade_to_tls/1
    (romeo) lib/romeo/transports/tcp.ex:90: Romeo.Transports.TCP.maybe_start_tls/1
    (romeo) lib/romeo/transports/tcp.ex:64: 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: {:EXIT, #PID<0.191.0>, {{:badmatch, {:error, {:tls_alert, 'certificate unknown'}}}, [{Romeo.Transports.TCP, :upgrade_to_tls, 1, [file: 'lib/romeo/transports/tcp.ex', line: 99]}, {Romeo.Transports.TCP, :maybe_start_tls, 1, [file: 'lib/romeo/transports/tcp.ex', line: 90]}, {Romeo.Transports.TCP, :start_protocol, 1, [file: 'lib/romeo/transports/tcp.ex', line: 64]}, {Romeo.Connection, :connect, 2, [file: 'lib/romeo/connection.ex', line: 90]}, {Connection, :enter_connect, 5, [file: 'lib/connection.ex', line: 622]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 247]}]}}
State: {:state, {#PID<0.194.0>, Supervisor.Default}, :simple_one_for_one, [{:child, :undefined, Hedwig.Responder, {Hedwig.Responder, :start_link, []}, :transient, 5000, :worker, [Hedwig.Responder]}], {:dict, {:dict, 2, 16, 16, 8, 80, 48, {[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []}, {{[], [], [], [[#PID<0.195.0>, Hedwig.Responders.Help, {"/", "jbot", [], #PID<0.191.0>}]], [[#PID<0.196.0>, Hedwig.Responders.Ping, {"/", "jbot", [], #PID<0.191.0>}]], [], [], [], [], [], [], [], [], [], [], []}}}}, 3, 5, [], 0, Supervisor.Default, {[{Hedwig.Responder, {Hedwig.Responder, :start_link, []}, :transient, 5000, :worker, [Hedwig.Responder]}], [strategy: :simple_one_for_one]}}

Accessing XML?

Hey, this is a super basic question, but I'm not super familiar with Elixir and Erlang yet.

How do I actually access the message_type part of the response below thats buried in the JSON. Parsing the JSON is easy but is there an easy way to get at that? I tried looking for some methods to convert xml to map but didnt see it

%Romeo.Stanza.Message{
  body: "",
  delayed?: false,
  from: nil,
  html: nil,
  id: "",
  to: nil,
  type: "normal",
  xml: {:xmlel, "message", [],
   [
     {:xmlel, "gcm",
      [{"xmlns", "google:mobile:data"}, {"xmlns:data", "google:mobile:data"}],
      [
        xmlcdata: "{\"message_type\":\"nack\",\"from\":\"00000000000:00000000000000000000000000000000000000000000000-00000000000000000000000000000000000000-00000000000000000000000000000000000000000000000000000\",\"message_id\":\"5feef900-1a19-43b7-b2ef-d3e3d7997620\",\"error\":\"BAD_REGISTRATION\",\"error_description\":\"\"}"
      ]}
   ]}
}

Error while connecting to server

I tried to connect to my XMPP server (running Prosody) via romeo 0.5 and it failed with the following error:

`iex(5)> {:ok, pid} = Conn.start_link(opts)
{:ok, #PID<0.195.0>}
iex(6)>
19:06:58.679 [info] Established connection to SERVERURL

19:06:58.680 [debug] [NAME@SERVERURL][OUTGOING] "<stream:stream to='SERVERURL' version='1.0' xml:lang='en' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>"

19:06:58.727 [debug] [NAME@SERVERURL][INCOMING] {:xmlstreamstart, "stream:stream", [{"xmlns:stream", "http://etherx.jabber.org/streams"}, {"xmlns", "jabber:client"}, {"version", "1.0"}, {"from", "SERVERURL"}, {"id", "SOMEID"}, {"xml:lang", "en"}]}

19:07:03.730 [info] Authenticating with PLAIN

19:07:03.730 [debug] [NAME@SERVERURL][OUTGOING] "SOMESTRING=="

19:07:03.774 [debug] [NAME@SERVERURL][INCOMING] {:xmlel, "stream:features", [], [{:xmlel, "starttls", [{"xmlns", "urn:ietf:params:xml:ns:xmpp-tls"}], [{:xmlel, "required", [], []}]}]}
** (EXIT from #PID<0.182.0>) an exception was raised:
** (CaseClauseError) no case clause matching: "stream:features"
(romeo) lib/romeo/auth.ex:62: anonymous fn/2 in Romeo.Auth.success?/1
(romeo) lib/romeo/auth.ex:32: Romeo.Auth.do_authenticate/2
(romeo) lib/romeo/transports/tcp.ex:94: Romeo.Transports.TCP.authenticate/1
(romeo) lib/romeo/transports/tcp.ex:54: Romeo.Transports.TCP.start_protocol/1
(romeo) lib/romeo/connection.ex:84: Romeo.Connection.connect/2
(connection) lib/connection.ex:623: Connection.enter_connect/5
(stdlib) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
`

opts was: [jid: "NAME@SERVERURL", password: "PASSWORD", nickname: "NICKNAME", require_tls: true]

Is this an error of romeo or did I somehow use it wrongly?

FunXMPP support

I'm not a XMPP expert, I'm just learning right now.
Recently, I've been doing research on creating alternative Whatsapp clients and discovered they use a modified XMPP called FunXMPP, which is basically a modified XMPP where instead of using raw ASCII XML they replace some keywords by single bytes and represent xml structures using lists of lists.

Given that, I'd guess that is not completely impossible to implement some middleware to adapt Romeo to FunXMPP. I'm willing to contribute with that but don't know much about it right now.

Do you think it is viable to implement that here and if I do so, are you willing to merge it?

(I'm also accepting directions to which modules I should be looking to add support to FunXMPP, hahaha)

Create room and set it's configuration

Is there a way to create groupchat room and set it's configuration? I've created one using Hedwig but can't send message because room is locked. I guess it needs configuration set first. Also I'm interested how to invite users to that room? I couldn't find it in source but maybe I'm missing something.

Thanks

Error when authenticating

I've got this error when authenticating into my xmpp server.

GenServer #PID<0.191.0> terminating                                                                                                                                        
** (FunctionClauseError) no function clause matching in anonymous fn/2 in Romeo.                                                                                                                Auth.success?/1                                                                                                                                                                                 
    (romeo) lib/romeo/auth.ex:91: anonymous fn(%Romeo.Connection{component: fals                                                                                                                e, features: %Romeo.Connection.Features{amp?: false, compression?: false, mechan                                                                                                                isms: ["PLAIN"], registration?: false, stream_management?: false, tls?: false},                                                                                                                 host: 'xmpp.dev.radiumchat.net', jid: "[email protected]", legacy_tls:                                                                                                                 false, nickname: "", owner: #PID<0.185.0>, parser: #Reference<0.21324546.708444                                                                                                                164.221664>, password: "eyJhbGciOiJSUzI1NiIsImtpZCI6IjcyNTc5MjI3ZmFiYmI5NWVjMTFm                                                                                                                NjQzMGQ4MjAxMWU2NDMzYWM1MDMiLCJ0eXAiOiJKV1QifQ.eyJpYXQiOjE1MzUwODM1MDMsInN1YiI6I                                                                                                                jUyZWVlZTVkNDNmMiIsInRlcm1pbmFsIjoiYjg3Y2E4NjAzMGRmIn0.QnL9eMcgUPXgVjomzWd4cEoK8                                                                                                                Nj32Q8UIoZeGIGj9bmJhYwb74r3ffNGqxeRVxymb4mg1s4Spx1ZtEA0IQq_mdxX77Pu2-SuZIoJxLsdb                                                                                                                7WLURZQmaq7acjx1K45uVbYWyyXghv8UOt7k2QURj6eUN1Dp4Rk0camZwxr2RDU4rQ", port: 5222,                                                                                                                 preferred_auth_mechanisms: [], require_tls: false, resource: "", rooms: [], soc                                                                                                                ket: {:gen_tcp, #Port<0.7>}, socket_opts: [], ssl_opts: [], stream_id: "QM-dvX-Z                                                                                                                SG-BqKhEB_trxQ", timeout: 5000, transport: Romeo.Transports.TCP}, "\n") in Romeo                                                                                                                .Auth.success?/1                                                                                                                                                                                
    (romeo) lib/romeo/auth.ex:62: Romeo.Auth.do_authenticate/2```

Not handling possible error when calling `:gen_tcp.send/2` in `Romeo.Transports.TCP.send/2`

Sometimes when Romeo.Transports.TCP.send/2 gets called in my application, my socket returns {:error, :closed}, and thus, a pattern match is not found.

11:38:56.986 [error] GenServer #PID<0.674.0> terminating
** (MatchError) no match of right hand side value: {:error, :closed}
    (romeo) lib/romeo/transports/tcp.ex:197: Romeo.Transports.TCP.send/2
    (romeo) lib/romeo/transports/tcp.ex:73: Romeo.Transports.TCP.start_stream/2
    (romeo) lib/romeo/transports/tcp.ex:62: 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: nil, jid: "test@localhost", legacy_tls: false, nicknam
e: "", owner: #PID<0.673.0>, parser: nil, password: "password", port: nil, preferred_auth_mechanisms: [], require_tls: false, resource: "", rooms: [], socket: nil, socket_opts: [], ssl_opts: [], stream_id: nil, timeout: 5000, transport: Romeo.Transports
.TCP}

The line in question is here.

What do you think we should do to handle this?

FCM connection

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.