<div dir="ltr"><div>Hello All,</div><div><br></div><div>I&#39;m new to Opensips (and especially all the B2B stuff), so please forgive my ignorance. It&#39;s my first post to the list, so if it&#39;s not the right place to ask for help, then please forgive me.</div>
<div><br></div><div>I want to try the new call center module, but I have problems. I&#39;m using Opensips 1.11.1 (from <a href="http://opensips.org/pub/opensips/1.11.1/src/opensips-1.11.1-0f26cc5_src.tar.gz">http://opensips.org/pub/opensips/1.11.1/src/opensips-1.11.1-0f26cc5_src.tar.gz</a>).  </div>
<div>I think I&#39;ve missed something.</div><div><br></div><div>Here is what I expect from the test:</div><div>1001@dark.sip calls 321 (the customer care number) and when the Agent (1000@dark.sip) is logged in, 1000 should receive the call, and 1001 should hear the </div>
<div>music on hold played from a remote Asterisk box (<a href="mailto:sip%3A789@192.168.57.3">sip:789@192.168.57.3</a>) until 1000 accepts the call.</div><div><br></div><div>Here is UL output:</div><div>bash-4.2# opensipsctl ul show</div>
<div>Domain:: location table=512 records=2</div><div>        AOR:: 1000@dark.sip</div><div>                Contact:: sip:1000@192.168.57.2:5060;ob Q=</div><div>                        Expires:: 6</div><div>                        Callid:: d8238fca92d546a4a02dacd49945ce09</div>
<div>                        Cseq:: 28989</div><div>                        User-agent:: MicroSIP/3.5.2</div><div>                        Received:: sip:<a href="http://192.168.57.2:5060">192.168.57.2:5060</a></div><div>                        State:: CS_SYNC</div>
<div>                        Flags:: 0</div><div>                        Cflags:: NAT</div><div>                        Socket:: udp:<a href="http://192.168.57.1:5060">192.168.57.1:5060</a></div><div>                        Methods:: 8063</div>
<div>        AOR:: 1001@dark.sip</div><div>                Contact:: sip:1001@192.168.57.1:5062;line=440bf1c1659e8f5 Q=</div><div>                        Expires:: 3419</div><div>                        Callid:: 1327377519</div>
<div>                        Cseq:: 12</div><div>                        User-agent:: Linphone/3.6.1 (eXosip2/3.6.0)</div><div>                        Received:: sip:<a href="http://192.168.57.1:5062">192.168.57.1:5062</a></div>
<div>                        State:: CS_SYNC</div><div>                        Flags:: 0</div><div>                        Cflags:: NAT</div><div>                        Socket:: udp:<a href="http://192.168.57.1:5060">192.168.57.1:5060</a></div>
<div>                        Methods:: 4294967295</div><div><br></div><div><br></div><div><br></div><div>When 1001 dial 321, it&#39;s connected to the music on hold on the remote asterisk box (192.168.57.3), but the Agent (1000@dark.sip) doesn&#39;t ring</div>
<div>When I log off the agent using &quot;opensipsctl fifo cc_agent_login 1000 0&quot;, then 1001 cannot call 321 (&quot;Cannot handle call&quot;) and that&#39;s normal I think.</div><div>When I log the Agent in using &quot;opensipsctl fifo cc_agent_login 1000 1&quot;, then 1001 can call 321 and stay in queue while connected to the music on hold, </div>
<div>but still the call is not delivered to the Agent </div><div><br></div><div>Here is the code:</div><div>.....</div><div>loadmodule &quot;b2b_entities.so&quot;</div><div>modparam(&quot;b2b_entities&quot;, &quot;db_mode&quot;, 1)</div>
<div>modparam(&quot;b2b_entities&quot;, &quot;db_url&quot;, &quot;mysql://opensips:opensipsrw@localhost/opensips_1_11&quot;)</div><div><br></div><div>loadmodule &quot;b2b_logic.so&quot;</div><div>modparam(&quot;b2b_logic&quot;, &quot;db_mode&quot;, 1)</div>
<div>modparam(&quot;b2b_logic&quot;, &quot;db_url&quot;, &quot;mysql://opensips:opensipsrw@localhost/opensips_1_11&quot;)</div><div>modparam(&quot;b2b_logic&quot;, &quot;script_scenario&quot;, &quot;/etc/opensips/scenario_callcenter.xml&quot;)</div>
<div><br></div><div>loadmodule &quot;call_center.so&quot;</div><div>modparam(&quot;call_center&quot;, &quot;db_url&quot;, &quot;mysql://opensips:opensipsrw@localhost/opensips_1_11&quot;)</div><div>modparam(&quot;call_center&quot;, &quot;acc_db_url&quot;, &quot;mysql://opensips:opensipsrw@localhost/opensips_1_11&quot;)</div>
<div>modparam(&quot;call_center&quot;, &quot;b2b_scenario&quot;, &quot;call center&quot;)</div><div>.....</div><div><br></div><div>route{</div><div>......</div><div><br></div><div><span class="" style="white-space:pre">        </span>$var(flowid)=&quot;support&quot;;</div>
<div><span class="" style="white-space:pre">        </span>if($rU==&quot;321&quot;) {</div><div><span class="" style="white-space:pre">                </span>if (is_method(&quot;INVITE&quot;) and !has_totag()) {</div><div><span class="" style="white-space:pre">                        </span>if (!cc_handle_call(&quot;$var(flowid)&quot;)) {</div>
<div><span class="" style="white-space:pre">                                </span>send_reply(&quot;403&quot;,&quot;Cannot handle call&quot;);</div><div><span class="" style="white-space:pre">                                </span>exit;</div><div><span class="" style="white-space:pre">                        </span>}</div>
<div><span class="" style="white-space:pre">                </span>exit;</div><div><span class="" style="white-space:pre">                </span>}</div><div><span class="" style="white-space:pre">        </span>}</div><div><br></div><div>.....</div><div><br>
</div><div><br></div><div><br></div><div><br></div><div>And below are the database contents:</div><div><br></div><div>MariaDB [opensips_1_11]&gt; select * from cc_agents;</div><div>+----+---------+----------------------------+----------+----------+---------------+</div>
<div>| id | agentid | location                   | logstate | skills   | last_call_end |</div><div>+----+---------+----------------------------+----------+----------+---------------+</div><div>|  1 | 1000    | <a href="http://sip:1000@192.168.57.2:5060">sip:1000@192.168.57.2:5060</a> |        1 | custcare |             0 |</div>
<div>+----+---------+----------------------------+----------+----------+---------------+</div><div>1 row in set (0.00 sec)</div><div><br></div><div>MariaDB [opensips_1_11]&gt; select * from cc_flows;</div><div>+----+---------+----------+----------+------------+-----------------+----------------------+</div>
<div>| id | flowid  | priority | skill    | prependcid | message_welcome | message_queue        |</div><div>+----+---------+----------+----------+------------+-----------------+----------------------+</div><div>|  2 | support |      256 | custcare |            | NULL            | <a href="mailto:sip%3A789@192.168.57.3">sip:789@192.168.57.3</a> |</div>
<div>+----+---------+----------+----------+------------+-----------------+----------------------+</div><div>1 row in set (0.00 sec)</div><div><br></div><div>MariaDB [opensips_1_11]&gt; select * from cc_calls;</div><div>+----+-------+----------+--------+------------+-----+------------+-----------+-----------+-----------+---------+---------+-------+</div>
<div>| id | state | ig_cback | no_rej | setup_time | eta | last_start | recv_time | caller_dn | caller_un | b2buaid | flow    | agent |</div><div>+----+-------+----------+--------+------------+-----+------------+-----------+-----------+-----------+---------+---------+-------+</div>
<div>| 37 |     3 |        0 |      0 |         -1 |   0 |         99 |        99 | 1001      | 1001      | 943.0   | support | 1000  |</div><div>+----+-------+----------+--------+------------+-----+------------+-----------+-----------+-----------+---------+---------+-------+</div>
<div>1 row in set (0.00 sec)</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div>Every time 1001 calls 321, I get the following log</div><div><br>
</div><div>May 14 09:33:12 darkstar /sbin/opensips[7494]: CRITICAL:db_mysql:wrapper_single_mysql_real_query: driver error (1062): Duplicate entry &#39;943.0&#39; for key &#39;PRIMARY&#39; </div><div>May 14 09:33:12 darkstar /sbin/opensips[7494]: ERROR:core:db_do_insert: error while submitting query </div>
<div>May 14 09:33:12 darkstar /sbin/opensips[7494]: ERROR:call_center:cc_db_insert_call: inserting new record in database </div><div>May 14 09:33:12 darkstar /sbin/opensips[7494]: ERROR:call_center:w_handle_call: Failed to insert call record in db </div>
<div><br></div><div><br></div><div><br></div><div><br></div><div>I checked my MySQL log, and I see something like the following </div><div><br></div><div><br></div><div>Query     insert into b2b_entities (type,tag0,tag1,callid,ruri,from_uri,from_dname,to_uri,to_dname,route0,route1,sockinfo_srv,param,state,cseq0,cseq1,lm,lrc,lic,contact0,contact1 ) values (0,&#39;265302590&#39;,&#39;B2B.15.62&#39;,&#39;1805953653&#39;,&#39;sip:321@dark.sip&#39;,&#39;sip:1001@dark.sip&#39;,&#39;&#39;,&#39;sip:321@dark.sip&#39;,&#39;&#39;,&#39;&#39;,&#39;&#39;,&#39;udp:<a href="http://192.168.57.1:5060">192.168.57.1:5060</a>&#39;,&#39;943.0&#39;,1,21,1,0,0,21,&#39;<a href="http://sip:1001@192.168.57.1:5062">sip:1001@192.168.57.1:5062</a>&#39;,&#39;sip:<a href="http://192.168.57.1:5060">192.168.57.1:5060</a>&#39;)</div>
<div>Query     insert into b2b_logic (si_key,scenario,sparam0,sparam1,sparam2,sparam3,sparam4,sdp,sstate,next_sstate,lifetime,e1_type,e1_sid,e1_to,e1_from,e1_key,e2_type,e2_sid,e2_to,e2_from,e2_key ) values (&#39;943.0&#39;,&#39;call center&#39;,&#39;<a href="mailto:sip%3A789@192.168.57.3">sip:789@192.168.57.3</a>&#39;,&#39;&#39;,&#39;&#39;,&#39;&#39;,&#39;&#39;,&#39;&#39;,1,1,1400057835,0,&#39;server1&#39;,&#39;sip:321@dark.sip&#39;,&#39;sip:1001@dark.sip&#39;,&#39;B2B.15.62&#39;,1,&#39;client1&#39;,&#39;<a href="mailto:sip%3A789@192.168.57.3">sip:789@192.168.57.3</a>&#39;,&#39;sip:1001@dark.sip&#39;,&#39;B2B.252.8053748&#39;)</div>
<div>Query     insert into cc_calls (state,ig_cback,no_rej,setup_time,eta,last_start,recv_time,caller_dn,caller_un,b2buaid,flow,agent ) values (2,0,0,-1,0,1623,1623,&#39;1001&#39;,&#39;1001&#39;,&#39;943.0&#39;,&#39;support&#39;,&#39;&#39;)</div>
<div>Query     insert into b2b_entities (type,tag0,tag1,callid,ruri,from_uri,from_dname,to_uri,to_dname,route0,route1,sockinfo_srv,param,state,cseq0,cseq1,lm,lrc,lic,contact0,contact1,leg_tag,leg_cseq,leg_contact,leg_route ) values (1,&#39;e86fcb40bafe3c72250681c6aca3fa92-c0ef&#39;,&#39;as79f2b584&#39;,&#39;B2B.252.8053748&#39;,&#39;&#39;,&#39;sip:1001@dark.sip&#39;,&#39;&#39;,&#39;<a href="mailto:sip%3A789@192.168.57.3">sip:789@192.168.57.3</a>&#39;,&#39;&#39;,&#39;&#39;,&#39;&#39;,&#39;udp:<a href="http://192.168.57.1:5060">192.168.57.1:5060</a>&#39;,&#39;943.0&#39;,4,22,1,1,0,22,&#39;sip:<a href="http://192.168.57.1:5060">192.168.57.1:5060</a>&#39;,&#39;<a href="http://sip:789@192.168.57.3:5060">sip:789@192.168.57.3:5060</a>&#39;,&#39;as79f2b584&#39;,22,&#39;<a href="http://sip:789@192.168.57.3:5060">sip:789@192.168.57.3:5060</a>&#39;,&#39;&#39;)</div>
<div>Query     update b2b_logic set sstate=1,next_sstate=1,lifetime=1400100975,e1_type=0,e1_sid=&#39;server1&#39;,e1_to=&#39;sip:321@dark.sip&#39;,e1_from=&#39;sip:1001@dark.sip&#39;,e1_key=&#39;B2B.15.62&#39;,e2_type=1,e2_sid=&#39;client1&#39;,e2_to=&#39;<a href="mailto:sip%3A789@192.168.57.3">sip:789@192.168.57.3</a>&#39;,e2_from=&#39;sip:1001@dark.sip&#39;,e2_key=&#39;B2B.252.8053748&#39; where si_key=&#39;943.0&#39;</div>
<div>Query     update b2b_entities set state=5,cseq0=22,cseq1=1,lm=4,lrc=0,lic=22,contact0=&#39;sip:<a href="http://192.168.57.1:5060">192.168.57.1:5060</a>&#39;,contact1=&#39;<a href="http://sip:789@192.168.57.3:5060">sip:789@192.168.57.3:5060</a>&#39;,leg_tag=&#39;as79f2b584&#39;,leg_cseq=22,leg_contact=&#39;<a href="http://sip:789@192.168.57.3:5060">sip:789@192.168.57.3:5060</a>&#39;,leg_route=&#39;&#39; where type=1 AND tag0=&#39;e86fcb40bafe3c72250681c6aca3fa92-c0ef&#39; AND tag1=&#39;as79f2b584&#39; AND callid=&#39;B2B.252.8053748&#39;</div>
<div>Query     update b2b_logic set sstate=1,next_sstate=1,lifetime=1400100975,e1_type=0,e1_sid=&#39;server1&#39;,e1_to=&#39;sip:321@dark.sip&#39;,e1_from=&#39;sip:1001@dark.sip&#39;,e1_key=&#39;B2B.15.62&#39;,e2_type=1,e2_sid=&#39;client1&#39;,e2_to=&#39;<a href="mailto:sip%3A789@192.168.57.3">sip:789@192.168.57.3</a>&#39;,e2_from=&#39;sip:1001@dark.sip&#39;,e2_key=&#39;B2B.252.8053748&#39; where si_key=&#39;943.0&#39;</div>
<div>Query     update b2b_entities set state=5,cseq0=21,cseq1=1,lm=0,lrc=200,lic=21,contact0=&#39;<a href="http://sip:1001@192.168.57.1:5062">sip:1001@192.168.57.1:5062</a>&#39;,contact1=&#39;sip:<a href="http://192.168.57.1:5060">192.168.57.1:5060</a>&#39; where type=0 AND tag0=&#39;265302590&#39; AND tag1=&#39;B2B.15.62&#39; AND callid=&#39;1805953653&#39;</div>
<div>Query     delete from b2b_entities where type=1 AND tag0=&#39;e86fcb40bafe3c72250681c6aca3fa92-c0ef&#39; AND tag1=&#39;as79f2b584&#39; AND callid=&#39;B2B.252.8053748&#39;</div><div>Query     update b2b_logic set sstate=-2,next_sstate=1,lifetime=1400057814,e1_type=0,e1_sid=&#39;server1&#39;,e1_to=&#39;sip:321@dark.sip&#39;,e1_from=&#39;sip:1001@dark.sip&#39;,e1_key=&#39;B2B.15.62&#39;,e2_type=1,e2_sid=&#39;client1&#39;,e2_to=&#39;<a href="mailto:sip%3A789@192.168.57.3">sip:789@192.168.57.3</a>&#39;,e2_from=&#39;sip:1001@dark.sip&#39;,e2_key=&#39;B2B.252.8053748&#39; where si_key=&#39;943.0&#39;</div>
<div>Query     delete from b2b_entities where type=0 AND tag0=&#39;265302590&#39; AND tag1=&#39;B2B.15.62&#39; AND callid=&#39;1805953653&#39;</div><div>Query     delete from b2b_entities where type=0 AND tag0=&#39;265302590&#39; AND tag1=&#39;B2B.15.62&#39; AND callid=&#39;1805953653&#39;</div>
<div>Query     delete from b2b_logic where si_key=&#39;943.0&#39;</div><div>Query     delete from b2b_entities where param=&#39;943.0&#39;</div><div><br></div><div><br></div><div>Query     insert into b2b_entities (type,tag0,tag1,callid,ruri,from_uri,from_dname,to_uri,to_dname,route0,route1,sockinfo_srv,param,state,cseq0,cseq1,lm,lrc,lic,contact0,contact1 ) values (0,&#39;1426943035&#39;,&#39;B2B.406.2&#39;,&#39;271697631&#39;,&#39;sip:321@dark.sip&#39;,&#39;sip:1001@dark.sip&#39;,&#39;&#39;,&#39;sip:321@dark.sip&#39;,&#39;&#39;,&#39;&#39;,&#39;&#39;,&#39;udp:<a href="http://192.168.57.1:5060">192.168.57.1:5060</a>&#39;,&#39;943.0&#39;,1,21,1,0,0,21,&#39;<a href="http://sip:1001@192.168.57.1:5062">sip:1001@192.168.57.1:5062</a>&#39;,&#39;sip:<a href="http://192.168.57.1:5060">192.168.57.1:5060</a>&#39;)</div>
<div>Query     insert into b2b_logic (si_key,scenario,sparam0,sparam1,sparam2,sparam3,sparam4,sdp,sstate,next_sstate,lifetime,e1_type,e1_sid,e1_to,e1_from,e1_key,e2_type,e2_sid,e2_to,e2_from,e2_key ) values (&#39;943.0&#39;,&#39;call center&#39;,&#39;<a href="mailto:sip%3A789@192.168.57.3">sip:789@192.168.57.3</a>&#39;,&#39;&#39;,&#39;&#39;,&#39;&#39;,&#39;&#39;,&#39;&#39;,1,1,1400057866,0,&#39;server1&#39;,&#39;sip:321@dark.sip&#39;,&#39;sip:1001@dark.sip&#39;,&#39;B2B.406.2&#39;,1,&#39;client1&#39;,&#39;<a href="mailto:sip%3A789@192.168.57.3">sip:789@192.168.57.3</a>&#39;,&#39;sip:1001@dark.sip&#39;,&#39;B2B.252.3775340&#39;)</div>
<div>Query     insert into cc_calls (state,ig_cback,no_rej,setup_time,eta,last_start,recv_time,caller_dn,caller_un,b2buaid,flow,agent ) values (2,0,0,-1,0,1655,1655,&#39;1001&#39;,&#39;1001&#39;,&#39;943.0&#39;,&#39;support&#39;,&#39;&#39;)</div>
<div>Query     insert into b2b_entities (type,tag0,tag1,callid,ruri,from_uri,from_dname,to_uri,to_dname,route0,route1,sockinfo_srv,param,state,cseq0,cseq1,lm,lrc,lic,contact0,contact1,leg_tag,leg_cseq,leg_contact,leg_route ) values (1,&#39;e86fcb40bafe3c72250681c6aca3fa92-c0ef&#39;,&#39;as7277702c&#39;,&#39;B2B.252.3775340&#39;,&#39;&#39;,&#39;sip:1001@dark.sip&#39;,&#39;&#39;,&#39;<a href="mailto:sip%3A789@192.168.57.3">sip:789@192.168.57.3</a>&#39;,&#39;&#39;,&#39;&#39;,&#39;&#39;,&#39;udp:<a href="http://192.168.57.1:5060">192.168.57.1:5060</a>&#39;,&#39;943.0&#39;,4,22,1,1,0,22,&#39;sip:<a href="http://192.168.57.1:5060">192.168.57.1:5060</a>&#39;,&#39;<a href="http://sip:789@192.168.57.3:5060">sip:789@192.168.57.3:5060</a>&#39;,&#39;as7277702c&#39;,22,&#39;<a href="http://sip:789@192.168.57.3:5060">sip:789@192.168.57.3:5060</a>&#39;,&#39;&#39;)</div>
<div>Query     update b2b_logic set sstate=1,next_sstate=1,lifetime=1400101006,e1_type=0,e1_sid=&#39;server1&#39;,e1_to=&#39;sip:321@dark.sip&#39;,e1_from=&#39;sip:1001@dark.sip&#39;,e1_key=&#39;B2B.406.2&#39;,e2_type=1,e2_sid=&#39;client1&#39;,e2_to=&#39;<a href="mailto:sip%3A789@192.168.57.3">sip:789@192.168.57.3</a>&#39;,e2_from=&#39;sip:1001@dark.sip&#39;,e2_key=&#39;B2B.252.3775340&#39; where si_key=&#39;943.0&#39;</div>
<div>Query     update b2b_entities set state=5,cseq0=22,cseq1=1,lm=4,lrc=0,lic=22,contact0=&#39;sip:<a href="http://192.168.57.1:5060">192.168.57.1:5060</a>&#39;,contact1=&#39;<a href="http://sip:789@192.168.57.3:5060">sip:789@192.168.57.3:5060</a>&#39;,leg_tag=&#39;as7277702c&#39;,leg_cseq=22,leg_contact=&#39;<a href="http://sip:789@192.168.57.3:5060">sip:789@192.168.57.3:5060</a>&#39;,leg_route=&#39;&#39; where type=1 AND tag0=&#39;e86fcb40bafe3c72250681c6aca3fa92-c0ef&#39; AND tag1=&#39;as7277702c&#39; AND callid=&#39;B2B.252.3775340&#39;</div>
<div>Query     update b2b_logic set sstate=1,next_sstate=1,lifetime=1400101006,e1_type=0,e1_sid=&#39;server1&#39;,e1_to=&#39;sip:321@dark.sip&#39;,e1_from=&#39;sip:1001@dark.sip&#39;,e1_key=&#39;B2B.406.2&#39;,e2_type=1,e2_sid=&#39;client1&#39;,e2_to=&#39;<a href="mailto:sip%3A789@192.168.57.3">sip:789@192.168.57.3</a>&#39;,e2_from=&#39;sip:1001@dark.sip&#39;,e2_key=&#39;B2B.252.3775340&#39; where si_key=&#39;943.0&#39;</div>
<div>Query     update b2b_entities set state=5,cseq0=21,cseq1=1,lm=0,lrc=200,lic=21,contact0=&#39;<a href="http://sip:1001@192.168.57.1:5062">sip:1001@192.168.57.1:5062</a>&#39;,contact1=&#39;sip:<a href="http://192.168.57.1:5060">192.168.57.1:5060</a>&#39; where type=0 AND tag0=&#39;1426943035&#39; AND tag1=&#39;B2B.406.2&#39; AND callid=&#39;271697631&#39;</div>
<div>Query     delete from b2b_entities where type=1 AND tag0=&#39;e86fcb40bafe3c72250681c6aca3fa92-c0ef&#39; AND tag1=&#39;as7277702c&#39; AND callid=&#39;B2B.252.3775340&#39;</div><div>Query     update b2b_logic set sstate=-2,next_sstate=1,lifetime=1400057840,e1_type=0,e1_sid=&#39;server1&#39;,e1_to=&#39;sip:321@dark.sip&#39;,e1_from=&#39;sip:1001@dark.sip&#39;,e1_key=&#39;B2B.406.2&#39;,e2_type=1,e2_sid=&#39;client1&#39;,e2_to=&#39;<a href="mailto:sip%3A789@192.168.57.3">sip:789@192.168.57.3</a>&#39;,e2_from=&#39;sip:1001@dark.sip&#39;,e2_key=&#39;B2B.252.3775340&#39; where si_key=&#39;943.0&#39;</div>
<div>Query     delete from b2b_entities where type=0 AND tag0=&#39;1426943035&#39; AND tag1=&#39;B2B.406.2&#39; AND callid=&#39;271697631&#39;</div><div>Query     delete from b2b_entities where type=0 AND tag0=&#39;1426943035&#39; AND tag1=&#39;B2B.406.2&#39; AND callid=&#39;271697631&#39;</div>
<div>Query     delete from b2b_logic where si_key=&#39;943.0&#39;</div><div>Query     delete from b2b_entities where param=&#39;943.0&#39;</div><div><br></div><div><br></div><div><br></div><div>Your help is really appreciated. And sorry for my poor english</div>
<div><br></div><div>Best Regards,</div><div><br></div><div>Garmin</div></div>