Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled terminate function clause #93

Closed
ConnorRigby opened this issue Apr 24, 2018 · 8 comments
Closed

Unhandled terminate function clause #93

ConnorRigby opened this issue Apr 24, 2018 · 8 comments

Comments

@ConnorRigby
Copy link

ConnorRigby commented Apr 24, 2018

This may be inside the underlying amqp lib. If you think this is a lower level issue please feel free to close.

{{:function_clause, [{:amqp_gen_connection, :terminate, [{:function_clause, [{:inet_dns, :encode_labels, [<<0, 97, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 10, 98, 114, 105, 115, 107, 45, 98, 101, 97, 114, 3, 114, 109, 113, 9, 99, 108, 111, 117, 100, 97, 109, 113, 112, ...>>, {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<0.869.0>, {:amqp_params_network, "device_863", "eyJhbGciOiJREDACTEDXVCJ9.eyJhdWQiOiJib3QiLCJzdWIiOjg2NCwiaWF0IjoxNTI0NTc5NDM2LCJqdGkiOiJlYWVjYzE1MS04YWRiLTQwMWItYjc3YS0zZDkxMTkzMzNmOWUiLCJpc3MiOiIvL215LmZhcm1ib3QuaW86NDQzIiwiZXhwIjoxNTI4MDM1NDM2LCJtcXR0IjoiYnJpc2stYmVhci5ybXEuY2xvdWRhbXFwLmNvbSIsImJvdCI6ImRldmljZV84NjMiLCJ2aG9zdCI6InZiemN4c3FyIiwibXF0dF93cyI6IndzczovL2JyaXNrLWJlYXIucm1xLmNsb3VkYW1xcC5jb206NDQzL3dzL21xdHQiLCJvc191cGRhdGVfc2VydREDACTEDGkuZ2l0aHViLmNvbS9yZXBvcy9mYXJtYm90L2Zhcm1ib3Rfb3MvcmVsZWFzZXMvbGF0ZXN0IiwiaW50ZXJpbV9lbWFpbCI6InN0ZXBoZW5hZkBsZWVzY2hvb2xzLm5ldCIsImZ3X3VwZGF0ZV9zZXJ2ZXIiOiJERVBSRUNBVEVEIiwiYmV0YV9vc191cGRhdGVfc2VydmVyIjoiaHR0cHM6Ly9hcGkuZ2l0aHViLmDONTHACKMEvcy9GYXJtQm90L2Zhcm1ib3Rfb3MvcmVsZWFzZXMvMTA2MzU4NjgifQ.tHF5Q5ALVHoELfsafjGvQ2iBCKEoHlzEt5w4wL1Yj31TJipxfBJNgnfXcO_-8iS4jtevo4yfzujmNUlj8nHfnF-F-PuREDACTEDvKxi8N8np8Uu2Q2DXb02CA19wQ33T5K-onTNtTny8sTbZs5MtmupNd_l0LrcnWMwm3ujg-cbHR4bAYAOTPYvs9Jc7moSdd_tPyFd8lRh5xmI-ajgclNBVdq-JC_KQRN0QiHWA_VvnraaHQv0jt027j_8hnVN8DkqDrkQH0rA02Fy8PK3F_iODOle-6FrNZXOZuuvssxCgjkjp7jiBUCtmDBCemBAIro7ZVWXbc3lUQvSOnMg", "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<0.870.0>, :connect, :infinity]}}
@ConnorRigby
Copy link
Author

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

@ConnorRigby
Copy link
Author

  {{: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]}}

@bmrsny
Copy link

bmrsny commented Apr 26, 2018

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>}}

@ConnorRigby
Copy link
Author

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

@ono
Copy link
Collaborator

ono commented May 9, 2018

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.)

@ConnorRigby
Copy link
Author

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.

@ConnorRigby
Copy link
Author

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

@ConnorRigby
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants