[rabbitmq-discuss] custom plugin debugging
Tim Watson
tim at rabbitmq.com
Fri Nov 9 01:26:15 GMT 2012
Hi
On 8 Nov 2012, at 23:22, Prabodh Upreti wrote:
> I got over the crash problem.
>
> Now where I try to connect via my java client I get
>
> =ERROR REPORT==== 8-Nov-2012::18:16:57 ===
> closing AMQP connection <0.246.0> (127.0.0.1:52094 -> 127.0.0.1:5672):
> {channel0_error,starting,
> {error,function_clause,'connection.start_ok',
> [{rabbitmq_cas_authen,q,
> [user_path,
> [{ticket,<<"ST-2-VYPDk5OF0y7SCDe9LGCO-cas01.example.org">>},
> {password,<<>>}]],
> []},
This error specifically means that the function 'q' in the rabbitmq_cas_authen module was called with the arguments given (i.e., q(user_path, [{ticket, _}, {password, <<>>}]) and there was no function clause matching those inputs, therefore the process executing that code crashed. This is probably because according to your subsequent post, you've defined q/2 as
q(PathName, token) ->
{ok, Path} = application:get_env(rabbitmq_cas_authen, PathName),
R = Path ++ "?ticket=" ++ token,
R.
So I think what you're probably getting confused about here is that in Erlang, variable names begin with a capital letter, so you'd want something more like `q(PathName, Token)` - the lowercase 'token' is an atom (i.e., like an interned string) and that's clearly not what's getting passed. I'd be remiss if I didn't strongly suggest spending some quality time with http://www.erlang.org/doc/reference_manual/users_guide.html at this point.
Now, you're trying to return `Path ++ "?ticket=" ++ Token` but the ++ operator is used to concatenate lists (which strings are represented as in Erlang) so even that's going to go wrong when you call it as `q(user_path, [{ticket, Username}|AuthProps])` because you've got a list of tuples there in that second parameter, not a string.
So..... What exactly are you trying to do here? It seems you want to append this *Token* to the URL you're doing a 'GET' on to authenticate, but where exactly is this Token data meant to be coming from? Is it in a header, or a cookie, or what? In Simon's code he appends the tuple {username, Username} to the AuthProps list, then takes all the {Key, Value} pairs in that list and formats them into a query string. But your 'token' seems to have appeared from nowhere!? At this point, even getting the syntax right isn't going to help! ;)
If you let us know where the token is meant to be coming from then I'm sure we can steer you in the right direction anyway.
Cheers,
Tim
More information about the rabbitmq-discuss
mailing list