{"action":"opened","issue":{"url":"https://api.github.com/repos/cgrates/cgrates/issues/226","labels_url":"https://api.github.com/repos/cgrates/cgrates/issues/226/labels{/name}","comments_url":"https://api.github.com/repos/cgrates/cgrates/issues/226/comments","events_url":"https://api.github.com/repos/cgrates/cgrates/issues/226/events","html_url":"https://github.com/cgrates/cgrates/issues/226","id":109548961,"number":226,"title":"Incorrect account match in UserService","user":{"login":"ezgektor","id":10644254,"avatar_url":"https://avatars.githubusercontent.com/u/10644254?v=3","gravatar_id":"","url":"https://api.github.com/users/ezgektor","html_url":"https://github.com/ezgektor","followers_url":"https://api.github.com/users/ezgektor/followers","following_url":"https://api.github.com/users/ezgektor/following{/other_user}","gists_url":"https://api.github.com/users/ezgektor/gists{/gist_id}","starred_url":"https://api.github.com/users/ezgektor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ezgektor/subscriptions","organizations_url":"https://api.github.com/users/ezgektor/orgs","repos_url":"https://api.github.com/users/ezgektor/repos","events_url":"https://api.github.com/users/ezgektor/events{/privacy}","received_events_url":"https://api.github.com/users/ezgektor/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-10-02T18:42:52Z","updated_at":"2015-10-02T18:42:52Z","closed_at":null,"body":"The problem is connected with UserService. We have a UserProfile with Cli 34688888888. We try to make a call to 34691111111. And CGRateS matches random UserProfile with incorrect Account, Subject and also Cli. Every time we try to make a call, it matches new profile from our db. And tries to bill that random pofile instead of correct one and generates incorrect CDRs.\r\n\r\nHere is the example of such CDR, but the call was made from Cli 34688888888, not the one we can see in CDR.\r\n\r\n| 262 | 05fee133eb4311f4da37708fdb0ad96a784c7491 | *voice | b44e8444-6880-11e5-9fda-6b0fa7455d8f | 172.16.43.103 | freeswitch_json | *prepaid | *out      | flexi.mobi | call     | 34688888889 | 34688888889 | 34691111111 | 2015-10-01 21:09:29 |  0.000000000 | 0000-00-00 00:00:00 |   0.000000000 |          | NORMAL_CLEARING          | 2015-10-01 21:09:29 | 0000-00-00 00:00:00 |\r\n\r\nI also provide ngrep data from 2080 port of FreeSwitch.\r\n\r\nPOST /freeswitch_json?uuid=b44e8444-6880-11e5-9fda-6b0fa7455d8f HTTP/1.1.\r\n\r\nUser-Agent: freeswitch-json/1.0.\r\nHost: 172.16.43.101:2080.\r\nAccept: */*.\r\nContent-Type: application/json.\r\nContent-Length: 6530.\r\nExpect: 100-continue.\r\n.\r\n\r\n##\r\nT 2015/10/01 21:09:29.547533 172.16.43.101:2080 -> 172.16.43.103:38343 [AP]\r\nHTTP/1.1 100 Continue.\r\n.\r\n\r\n##\r\nT 2015/10/01 21:09:29.547593 172.16.43.103:38343 -> 172.16.43.101:2080 [A]\r\n{\"core-uuid\":\"16a3e68e-687c-11e5-9f85-6b0fa7455d8f\",\"switchname\":\"bf-mvno-fs-1.es.xxxxxxxxx.es\",\"channel_data\":{\"state\":\"CS_REPORTING\",\"direction\":\"inbound\",\"state_number\":\"11\",\"flags\":\"0=1;37=1;39=1;73=1;111=1;115=1;117=1\",\"caps\":\"1=1;2=1;3=1;4=1;5=1;6=1\"},\"variables\":{\"direction\":\"inbound\",\"uuid\":\"b44e8444-6880-11e5-9fda-6b0fa7455d8f\",\"session_id\":\"8\",\"sip_from_user\":\"34688888888\",\"sip_from_uri\":\"34688888888@192.168.80.21\",\"sip_from_host\":\"192.168.80.21\",\"channel_name\":\"sofia/external/34688888888@192.168.80.21\",\"sip_call_id\":\"6e88-42b-91201521929-IMG01-0-192.168.80.21\",\"ep_codec_string\":\"PCMU@8000h@20i@64000b,G729@8000h@20i@8000b,PCMA@8000h@20i@64000b\",\"sip_local_network_addr\":\"172.16.43.103\",\"sip_network_ip\":\"172.16.43.102\",\"sip_network_port\":\"5060\",\"sip_received_ip\":\"172.16.43.102\",\"sip_received_port\":\"5060\",\"sip_via_protocol\":\"udp\",\"sip_from_user_stripped\":\"34688888888\",\"sip_from_tag\":\"95ffcd055e0f78f7d5d397020e89288df3cdd5f0\",\"sofia_profile_name\":\"external\",\"recovery_profile_name\":\"external\",\"sip_full_via\":\"SIP/2.0/UDP 172.16.43.102:5060;branch=z9hG4bK8dce.d7409351.0\",\"sip_from_display\":\"34688888888\",\"sip_full_from\":\"\\\"34688888888\\\" <sip:34688888888@192.168.80.21>;tag=95ffcd055e0f78f7d5d397020e89288df3cdd5f0\",\"sip_full_to\":\"<sip:34691111111@172.16.43.103:5060>\",\"sip_req_user\":\"34691111111\",\"sip_req_port\":\"5060\",\"sip_req_uri\":\"34691111111@172.16.43.103:5060\",\"sip_req_host\":\"172.16.43.103\",\"sip_to_user\":\"34691111111\",\"sip_to_port\":\"5060\",\"sip_to_uri\":\"34691111111@172.16.43.103:5060\",\"sip_to_host\":\"172.16.43.103\",\"sip_contact_params\":\"did=1ac.89afb4b1\",\"sip_contact_user\":\"34688888888\",\"sip_contact_uri\":\"34688888888@172.16.43.102\",\"sip_contact_host\":\"172.16.43.102\",\"sip_user_agent\":\"Dialogic-SIP/10.5.3.53602 IMG01 0\",\"sip_via_host\":\"172.16.43.102\",\"sip_via_port\":\"5060\",\"switch_r_sdp\":\"v=0\\r\\no=Dialogic_SDP 12299628 0 IN IP4 192.168.80.21\\r\\ns=Dialogic-SIP\\r\\nc=IN IP4 192.168.80.22\\r\\nt=0 0\\r\\nm=audio 8172 RTP/AVP 0 18 8 101\\r\\na=rtpmap:0 PCMU/8000\\r\\na=rtpmap:18 G729/8000\\r\\na=fmtp:18 annexb=yes\\r\\na=rtpmap:8 PCMA/8000\\r\\na=rtpmap:101 telephone-event/8000\\r\\na=fmtp:101 0-15\\r\\na=silenceSupp:off - - - -\\r\\n\",\"endpoint_disposition\":\"DELAYED NEGOTIATION\",\"cgr_reqtype\":\"*users\",\"cgr_tenant\":\"*users\",\"cgr_account\":\"*users\",\"cgr_subject\":\"*users\",\"cgr_destination\":\"34691111111\",\"Cli\":\"34688888888\",\"cgr_notify\":\"-INSUFFICIENT_FUNDS\",\"max_forwards\":\"68\",\"transfer_history\":\"1443733769:b45718d4-6880-11e5-9fe3-6b0fa7455d8f:bl_xfer:34691111111/default/XML\",\"transfer_source\":\"1443733769:b45718d4-6880-11e5-9fe3-6b0fa7455d8f:bl_xfer:34691111111/default/XML\",\"call_uuid\":\"b44e8444-6880-11e5-9fda-6b0fa7455d8f\",\"proto_specific_hangup_cause\":\"sip:403\",\"current_application\":\"hangup\",\"hangup_cause\":\"NORMAL_CLEARING\",\"hangup_cause_q850\":\"16\",\"digits_dialed\":\"none\",\"start_stamp\":\"2015-10-01 21:09:29\",\"profile_start_stamp\":\"2015-10-01 21:09:29\",\"end_stamp\":\"2015-10-0\r\n#\r\nT 2015/10/01 21:09:29.547605 172.16.43.103:38343 -> 172.16.43.101:2080 [A]\r\n1 21:09:29\",\"start_epoch\":\"1443733769\",\"start_uepoch\":\"1443733769467490\",\"profile_start_epoch\":\"1443733769\",\"profile_start_uepoch\":\"1443733769527480\",\"answer_epoch\":\"0\",\"answer_uepoch\":\"0\",\"bridge_epoch\":\"0\",\"bridge_uepoch\":\"0\",\"last_hold_epoch\":\"0\",\"last_hold_uepoch\":\"0\",\"hold_accum_seconds\":\"0\",\"hold_accum_usec\":\"0\",\"hold_accum_ms\":\"0\",\"resurrect_epoch\":\"0\",\"resurrect_uepoch\":\"0\",\"progress_epoch\":\"0\",\"progress_uepoch\":\"0\",\"progress_media_epoch\":\"0\",\"progress_media_uepoch\":\"0\",\"end_epoch\":\"1443733769\",\"end_uepoch\":\"1443733769527480\",\"last_app\":\"hangup\",\"caller_id\":\"\\\"34688888888\\\" <34688888888>\",\"duration\":\"0\",\"billsec\":\"0\",\"progresssec\":\"0\",\"answersec\":\"0\",\"waitsec\":\"0\",\"progress_mediasec\":\"0\",\"flow_billsec\":\"0\",\"mduration\":\"60\",\"billmsec\":\"0\",\"progressmsec\":\"0\",\"answermsec\":\"0\",\"waitmsec\":\"0\",\"progress_mediamsec\":\"0\",\"flow_billmsec\":\"0\",\"uduration\":\"59990\",\"billusec\":\"0\",\"progressusec\":\"0\",\"answerusec\":\"0\",\"waitusec\":\"0\",\"progress_mediausec\":\"0\",\"flow_billusec\":\"0\",\"sip_hangup_disposition\":\"send_refuse\"},\"app_log\":{\"applications\":[{\"app_name\":\"set\",\"app_data\":\"cgr_reqtype=*users\"},{\"app_name\":\"set\",\"app_data\":\"cgr_tenant=*users\"},{\"app_name\":\"set\",\"app_data\":\"cgr_account=*users\"},{\"app_name\":\"set\",\"app_data\":\"cgr_subject=*users\"},{\"app_name\":\"set\",\"app_data\":\"cgr_destination=34691111111\"},{\"app_name\":\"set\",\"app_data\":\"Cli=34688888888\"},{\"app_name\":\"park\",\"app_data\":\"\"},{\"app_name\":\"set\",\"app_data\":\"proto_specific_hangup_cause=sip:403\"},{\"app_name\":\"hangup\",\"app_data\":\"\"}]},\"callflow\":{\"dialplan\":\"XML\",\"profile_index\":\"2\",\"extension\":{\"name\":\"CGRateS_AuthForbidden\",\"number\":\"34691111111\",\"applications\":[{\"app_name\":\"set\",\"app_data\":\"proto_specific_hangup_cause=sip:403\"},{\"app_name\":\"hangup\",\"app_data\":\"\"}]},\"caller_profile\":{\"username\":\"34688888888\",\"dialplan\":\"XML\",\"caller_id_name\":\"34688888888\",\"ani\":\"34688888888\",\"aniii\":\"\",\"caller_id_number\":\"34688888888\",\"network_addr\":\"172.16.43.102\",\"rdnis\":\"34691111111\",\"destination_number\":\"34691111111\",\"uuid\":\"b44e8444-6880-11e5-9fda-6b0fa7455d8f\",\"source\":\"mod_sofia\",\"context\":\"default\",\"chan_name\":\"sofia/external/34688888888@192.168.80.21\"},\"times\":{\"created_time\":\"1443733769467490\",\"profile_created_time\":\"1443733769527480\",\"progress_time\":\"0\",\"progress_media_time\":\"0\",\"answered_time\":\"0\",\"bridged_time\":\"0\",\"last_hold_time\":\"0\",\"hold_accum_time\":\"0\",\"hangup_time\":\"1443733769527480\",\"resurrect_time\":\"0\",\"transfer_time\":\"0\"}},\"callflow\":{\"dialplan\":\"XML\",\"profile_index\":\"1\",\"extension\":{\"name\":\"cgr_auth\",\"number\":\"34691111111\",\"applications\":[{\"app_name\":\"set\",\"app_data\":\"cgr_reqtype=*users\"},{\"app_name\":\"set\",\"app_data\":\"cgr_tenant=*users\"},{\"app_name\":\"set\",\"app_data\":\"cgr_account=*users\"},{\"app_name\":\"set\",\"app_data\":\"cgr_subject=*users\"},{\"app_name\":\"set\",\"app_data\":\"cgr_destination=${sip_to_user}\"},{\"app_name\":\"set\",\"app_data\":\"Cli=${sip_from_user}\"},{\"app_name\":\"park\",\"app_data\":\"\"},{\"last_exe\r\n#\r\nT 2015/10/01 21:09:29.547611 172.16.43.103:38343 -> 172.16.43.101:2080 [AP]\r\ncuted\":\"true\",\"app_name\":\"hangup\",\"app_data\":\"\"}],\"current_app\":\"hangup\"},\"caller_profile\":{\"username\":\"34688888888\",\"dialplan\":\"XML\",\"caller_id_name\":\"34688888888\",\"ani\":\"34688888888\",\"aniii\":\"\",\"caller_id_number\":\"34688888888\",\"network_addr\":\"172.16.43.102\",\"rdnis\":\"\",\"destination_number\":\"34691111111\",\"uuid\":\"b44e8444-6880-11e5-9fda-6b0fa7455d8f\",\"source\":\"mod_sofia\",\"context\":\"default\",\"chan_name\":\"sofia/external/34688888888@192.168.80.21\"},\"times\":{\"created_time\":\"1443733769467490\",\"profile_created_time\":\"1443733769467490\",\"progress_time\":\"0\",\"progress_media_time\":\"0\",\"answered_time\":\"0\",\"bridged_time\":\"0\",\"last_hold_time\":\"0\",\"hold_accum_time\":\"0\",\"hangup_time\":\"0\",\"resurrect_time\":\"0\",\"transfer_time\":\"1443733769527480\"}}}\r\n##\r\nT 2015/10/01 21:09:29.616447 172.16.43.101:2080 -> 172.16.43.103:38343 [AP]\r\nHTTP/1.1 200 OK.\r\nDate: Thu, 01 Oct 2015 21:09:29 GMT.\r\nContent-Length: 0.\r\nContent-Type: text/plain; charset=utf-8."}}