<div dir="ltr"><div><div>Hello,<br><br></div>Based on the erlang diameter library and the sample code, I want to start multiple diameter client processes in one erlang node(one client IP), and the client needs to define a diameter_app callback module for certain application, for example:<br>
<br>-define(SERVICE(Name), [{'Origin-Host', ?L(Name) ++ ".<a href="http://example.com">example.com</a>"},<br>                        {'Origin-Realm', "<a href="http://example.com">example.com</a>"},<br>
                        {'Vendor-Id', 193},<br>                        {'Product-Name', "Client"},<br>                        {'Auth-Application-Id', [?DIAMETER_APP_ID_COMMON, ?DIAMETER_APP_ID_CCRA]},<br>
                        {application, [{alias, ?APP_CCR_ALIAS},<br>                                       {dictionary, ?DIAMETER_DICT_CCRA},<br>                                       {module, client_cb_ccra}]}]).<br><br><br>
</div><div>First question: <br>how the diameter library handles this situation? Will all diameter client processes share one single diameter_app callback module "client_cb_ccra" or it will automatically attach different instance of the callback module (process) to the different client process by using spawn_monitor? So from the callback handle_answer in "client_cb_ccra" I can notify the proper client proce by just calling client:notify() something.<br>
<br></div><div>Second question: <br></div><div>Notice that diameter:call allows to set extra arguments, so I was wondering I could set some data like: <br>diameter:call(Name, ?APP_CCR_ALIAS, CCR, [{extra, [self()]}]). <br>
which sets the client process ID and I hope to deliver to the callback module "client_cb_ccra" and when the callback module knows which client process sends request and response accordingly, for example using the client process ID in the callback function handle_answer. <br>
</div><div>However, I don't want pack the extra arguments into the diameter packet since the diameter server doesn't know what they are and the extra ones are not part of standard diameter packet.<br><br></div><div>
Now I changed the pick_peer callback signatures to allow extra arguments, <br>pick_peer([Peer | _], _, _SvcName, _State, A)<br><br></div><div>But I got encoding error in the callback prepare_request<br><br>=ERROR REPORT==== 14-Apr-2013::11:40:41 ===<br>
Error in process <0.175.0> with exit value: {undef,[{client_cb_ccra,prepare_request,[{diameter_packet,{diameter_header,1,undefined,undefined,undefined,3958849953,3958849953,undefined,undefined,undefined,undefined},undefined,{diameter_rfc4006_cc_CCR,["who",";","142745567... <br>
<br>{error,encode}<br><br></div><div>In overall, I read the online documents, which have limited information on how to use the extra arguments in the library and  don't quite get how to utilize the extra arguments to do something tricky, <br>
<br></div><div>Are there any suggestions on how to deal with multiple client processes?<br><br>Thanks a lot!<br><br></div><div>Samuel<br></div><div> </div></div>