For the quickest reply, please use our new Customer Helpdesk and Feedback platform
 
   
 
Crash when receiving unexpected Packet
Posted: 19 November 2009 05:33 PM   [ Ignore ]
Junior Member
Avatar
RankRank
Total Posts:  38
Joined  2009-11-19

Not sure if it is my Erlang, or exmpp crashing here:

22> jn_component:start(“jn.localhost”,“secret”,“localhost”, 8888, “127.0.0.1”).
<0.333.0>
{received_packet,iq,“get”,
  {<<“user2”>>,<<“localhost”>>,<<“Thiago-Camargos-MacBook-Pro”>>},
  “aacaa”,undefined,
  {xmlel,‘jabber:component:accept’,[],iq,
      [{xmlattr,undefined,from,
        <<“user2@localhost/Thiago-Camargos-MacBook-Pro”>>},
      {xmlattr,undefined,to,<<“jn.localhost”>>},
      {xmlattr,‘http://www.w3.org/XML/1998/namespace’,“lang”,<<“en”>>},
      {xmlattr,undefined,type,<<“get”>>},
      {xmlattr,undefined,id,<<“aacaa”>>}],
      [{xmlcdata,<<”\n”>>},
      {xmlel,‘http://jabber.org/protocol/disco#info’,
        [{‘http://jabber.org/protocol/disco#info’,none}],
        ‘query’,[],[]},
      {xmlcdata,<<”\n”>>}]}}
23>
=ERROR REPORT==== 19-Nov-2009::17:29:56 ===
Error in process <0.333.0> with exit value: {function_clause,[{jn_component,process_iq,[<0.334.0>,{xmlel,‘jabber:component:accept’,[],iq,[{xmlattr,undefined,from,<<43 bytes>>},{xmlattr,undefined,to,<<12 bytes>>},{xmlattr,‘http://www.w3.org/XML/1998/namespace’,“lang”,<<2 bytes>>},{xmlattr,undefined…

—————————————————————————————————
The code portion is:

loop(XmppComJIDPubIP) ->
    
receive
        stop 
->
            
exmpp_component:stop(XmppCom);
        %% If 
we receive a messagewe reply with the same message
        Record 
#received_packet{packet_type=message, raw_packet=Packet} ->
            
io:format("~p~n"[Record]),
            
process_message(XmppComPacketJID),
            
loop(XmppComJIDPubIP);
        
Record #received_packet{packet_type=iq, type_attr=Type, raw_packet=IQ} ->
            
io:format("~p~n"[Record]),
            
process_iq(XmppComIQTypePubIP,exmpp_xml:get_ns_as_atom(exmpp_iq:get_payload(IQ))),
            
loop(XmppComJIDPubIP);
        
Record ->
            
io:format("~p~n"[Record]),
            
loop(XmppComJIDPubIP)
    
end.

%% 
Create Channel and return details
process_iq
(XmppCom"get"IQPubIP, ?NS_CHANNEL) ->
    case 
allocate_relay() of
        {A
B} ->
                
Result exmpp_iq:result(IQ,get_candidate_elem(PubIPAB)),
                
exmpp_component:send_packet(XmppComResult);
        
->
                
Error exmpp_iq:error(IQ),
                
exmpp_component:send_packet(XmppComError)
        
end;

process_iq(XmppCom"get"IQ_, ?NS_DISCO_INFO) ->
        
Identity exmpp_xml:element(?NS_DISCO_INFO'identity'[exmpp_xml:attribute("category", <<"proxy">>),
                                                      
exmpp_xml:attribute("type", <<"relay">>),
                                                      
exmpp_xml:attribute("name", <<"Jingle Nodes Relay">>)
                                                      
],
                                     
[]),
        
IQRegisterFeature1 exmpp_xml:element(?NS_DISCO_INFO'feature'[exmpp_xml:attribute('var', ?NS_JINGLE_NODES_s)],[]),
        
IQRegisterFeature2 exmpp_xml:element(?NS_DISCO_INFO'feature'[exmpp_xml:attribute('var', ?NS_CHANNEL_s)],[]),
        
Result exmpp_iq:result(IQexmpp_xml:element(?NS_DISCO_INFO'query'[][IdentityIQRegisterFeature1IQRegisterFeature2])),
        
exmpp_component:send_packet(XmppComResult);

process_iq(XmppCom"set"IQ__) ->
                    
Error exmpp_iq:error(IQ,'feature-not-implemented'),
                    
exmpp_component:send_packet(XmppComError). 
Profile
 
 
Posted: 19 November 2009 05:56 PM   [ Ignore ]   [ # 1 ]
Moderator
RankRank
Total Posts:  31
Joined  2009-06-04

Hi Thiago,

the problem is in the order of the parameters on the call to the process_iq/5 function.

The function expect, as second argument the IQ type   (“get” in your example), but you are calling
it as

process_iq(XmppComIQTypePubIP,exmpp_xml:get_ns_as_atom(exmpp_iq:get_payload(IQ))) 

the second argument don’t match.


The hint is:

{function_clause,[{jn_component,process_iq,[<0.334.0>,{xmlel,‘jabber:component:accept’,[],iq,[{xmlattr,undefined,from

here erlang is telling you that no function clause match the call you made,

the actual call is jn_component:process_iq, with parameters <0.334.0>, {xmlel,‘jabber:component:accept’..

Profile
 
 
Posted: 20 November 2009 04:31 PM   [ Ignore ]   [ # 2 ]
Newbie
Rank
Total Posts:  1
Joined  2009-11-20

How did you configure the table for that.

Profile
 
 
Posted: 23 November 2009 09:43 PM   [ Ignore ]   [ # 3 ]
Moderator
RankRank
Total Posts:  31
Joined  2009-06-04

what table?

Profile
 
 
Posted: 03 December 2009 09:11 PM   [ Ignore ]   [ # 4 ]
Junior Member
Avatar
RankRank
Total Posts:  38
Joined  2009-11-19

Problem Solved.

Profile