Giter Club home page Giter Club logo

Comments (8)

bmrsny avatar bmrsny commented on July 16, 2024 2

I ran into this same issue. In my case opening a connection when the port is a string caused this error
configs = [username: "guest", password: "guest", host: "localhost", port: "5673"]
AMQP.Connection.open(configs)

 ** (FunctionClauseError) no function clause matching in :amqp_gen_connection.terminate/2
            (amqp_client) /Users/bmrsny/Projects/rolodex/deps/amqp_client/src/amqp_gen_connection.erl:239: :amqp_gen_connection.terminate({:function_clause, [{:inet_tcp, :getserv, ["5673"], [file: 'inet_tcp.erl', line: 55]}, {:gen_tcp, :connect1, 4, [file: 'gen_tcp.erl', line: 158]}, {:gen_tcp, :connect, 4, [file: 'gen_tcp.erl', line: 145]}, {:amqp_network_connection, :do_connect, 4, [file: '/Users/bmrsny/Projects/rolodex/deps/amqp_client/src/amqp_network_connection.erl', line: 132]}, {:amqp_gen_connection, :handle_call, 3, [file: '/Users/bmrsny/Projects/rolodex/deps/amqp_client/src/amqp_gen_connection.erl', line: 171]}, {:gen_server, :try_handle_call, 4, [file: 'gen_server.erl', line: 636]}, {:gen_server, :handle_msg, 6, [file: 'gen_server.erl', line: 665]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 247]}]}, {#PID<0.651.0>, {:amqp_params_network, "guest", "guest", "/", 'localhost', "5673", 0, 0, 0, :infinity, :none, [&:amqp_auth_mechanisms.plain/3, &:amqp_auth_mechanisms.amqplain/3], [], []}})

where as an Integer works as expected
configs = [username: "guest", password: "guest", host: "localhost", port: 5673]
AMQP.Connection.open(configs)
{:ok, %AMQP.Connection{pid: #PID<0.658.0>}}

from amqp.

ConnorRigby avatar ConnorRigby commented on July 16, 2024

Whoah that is pretty ugly. Let me try to format that a bit

from amqp.

ConnorRigby avatar ConnorRigby commented on July 16, 2024
  {{:function_clause,
    [
      {:amqp_gen_connection, :terminate,
       [
         {:function_clause,
          [
            {:inet_dns, :encode_labels,
             [
               <<"LONG BINARY">>,
               {4,
                {["brisk-bear", "rmq", "cloudamqp", "com", "", "home"], 12, nil,
                 {["rmq", "cloudamqp", "com", "", "home"], 23,
                  {["cloudamqp", "com", "", "home"], 27, nil,
                   {["com", "", "home"], 37, nil, nil}}, nil}}},
               41,
               ["", "home"]
             ], [file: 'inet_dns.erl', line: 694]},
            {:inet_dns, :encode_name, 4, [file: 'inet_dns.erl', line: 675]},
            {:inet_dns, :encode_query_section, 3, [file: 'inet_dns.erl', line: 269]},
            {:inet_dns, :encode, 1, [file: 'inet_dns.erl', line: 240]},
            {:inet_res, :make_query, 5, [file: 'inet_res.erl', line: 670]},
            {:inet_res, :make_query, 4, [file: 'inet_res.erl', line: 638]},
            {:inet_res, :res_query, 6, [file: 'inet_res.erl', line: 622]},
            {:inet_res, :res_getby_query, 4, [file: 'inet_res.erl', line: 589]}
          ]},
         {pid,
          {:amqp_params_network, "device_863", "BINARYTOKEN", "vbzcxsqr",
           'brisk-bear.rmq.cloudamqp.com', 5672, 0, 0, 0, :infinity, :none,
           [&:amqp_auth_mechanisms.plain/3, &:amqp_auth_mechanisms.amqplain/3], [], []}}
       ], [file: 'src/amqp_gen_connection.erl', line: 239]},
      {:gen_server, :try_terminate, 3, [file: 'gen_server.erl', line: 648]},
      {:gen_server, :terminate, 10, [file: 'gen_server.erl', line: 833]},
      {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 247]}
    ]}, {:gen_server, :call, [pid, :connect, :infinity]}}

from amqp.

ConnorRigby avatar ConnorRigby commented on July 16, 2024

I don't think that is what is happening to me, but i'll make sure to check this out.

from amqp.

ono avatar ono commented on July 16, 2024

Hi. Can you provide a sample code(including mix.lock) and steps to reproduce the issue? Would be helpful to know the environment too (OS, RabbitMQ version, Elixir version etc.)

from amqp.

ConnorRigby avatar ConnorRigby commented on July 16, 2024

I haven't been able to reproduce this personally. I received it in a bug report. A particular user get this exception for some reason. FWIW,

"amqp": {:hex, :amqp, "1.0.0-pre.2", "952180aac9b3a1faea96522f589327e8286457b8bd0fd84bf0560e06d02f5a5a", [], [{:amqp_client, "~> 3.6.8", [hex: :amqp_client, repo: "hexpm", optional: false]}, {:rabbit_common, "~> 3.6.8", [hex: :rabbit_common, repo: "hexpm", optional: false]}], "hexpm"},
  "amqp_client": {:hex, :amqp_client, "3.6.12", "dfdfe7be661feb96ece404092a47431a73797ad412959732d940f96f80290da0", [], [{:rabbit_common, "3.6.12", [hex: :rabbit_common, repo: "hexpm", optional: false]}], "hexpm"}

The device is running elixir 1.5.1 and OTP 20.1, connecting to RabbitMQ 3.6.12, Erlang 19.3.

here is how i'm opening the connection to rabbit.

opts = [
      host: "brisk-bear.rmq.cloudamqp.com",
      username: "device_863",
      password: "BASE64ENCODED JSON WEB TOKEN",
      virtual_host: "vbzcxsqr"]
AMQP.Connection.open(opts)

Also i just looked at the Erlang source described in that stack trace And it looks like my issue is caused by the token being to large.

from amqp.

ConnorRigby avatar ConnorRigby commented on July 16, 2024

This doesn't seem to be an issue with the amqp lib. Hopefully this can help someone else tho. 👍

from amqp.

ConnorRigby avatar ConnorRigby commented on July 16, 2024

Actually, upon further inspection, it doesn't seem to have to do with my token, but one of the dns labels?

iex(farmbot@farmbot-52db)25> args
[
  "LONG BINARY",
  {4,
   {["brisk-bear", "rmq", "cloudamqp", "com", "", "home"], 12, nil,
    {["rmq", "cloudamqp", "com", "", "home"], 23,
     {["cloudamqp", "com", "", "home"], 27, nil,
      {["com", "", "home"], 37, nil, nil}}, nil}}},
  41,
  ["", "home"]
]
iex(farmbot@farmbot-52db)26> [bin, comp0, pos, labels] = args
[
  "LONG BINARY",
  {4,
   {["brisk-bear", "rmq", "cloudamqp", "com", "", "home"], 12, nil,
    {["rmq", "cloudamqp", "com", "", "home"], 23,
     {["cloudamqp", "com", "", "home"], 27, nil,
      {["com", "", "home"], 37, nil, nil}}, nil}}},
  41,
  ["", "home"]
]

the pattern match for labels requires each item in the list to be greater than or equal to 1 bytes. "" is obviously only zero bytes so it doesn't match that pattern.

from amqp.

Related Issues (20)

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.