Hello Daniel

Sorry for the late response. Yes,  when i change subs_db_mode to 3 i see lots of error messages as below.
5678*002 is the subscriber for 5678*012 and 5678*011. When all phones idle, everything is fine all lamps are green. 
But when i make a call i see error messages and nothing changes with the lamps.
Sorry for inconvenience but I had to mask public IP addresses in the logs. 
I am using Kamailio version 4.3.2 and Postgresql-server 9.4.3 as DB.
root@km1:~# uname -a
Linux km1 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt11-1+deb8u3 (2015-08-04) x86_64 GNU/Linux
 
Btw i tried to separate presence server from proxy but nothing changes and i saw the same errors as below.

Thanks

Huseyin 



1:45:45 km1 kamailio_presence[10037]: WARNING: db_postgres [km_dbase.c:277]: db_postgres_submit_query(): postgres result check failed with code 7 (PGRES_FATAL_ERROR)
Sep 28 11:45:45 km1 kamailio_presence[10037]: WARNING: db_postgres [km_dbase.c:281]: db_postgres_submit_query(): postgres query command failed, connection status 0, error [ERROR:  duplicate key value violates unique constraint "presentity_presentity_idx"#012DETAIL:  Key (username, domain, event, etag)=(5678*002, XXX.XXX.XX.XXX, dialog, *#-OFFLINE-#*) already exists.#012]
Sep 28 11:45:45 km1 kamailio_presence[10037]: ERROR: db_postgres [km_dbase.c:290]: db_postgres_submit_query(): 0x7f0dd4497060 PQsendQuery Error: ERROR:  duplicate key value violates unique constraint "presentity_presentity_idx"#012DETAIL:  Key (username, domain, event, etag)=(5678*002, XXX.XXX.XX.XXX, dialog, *#-OFFLINE-#*) already exists.#012 Query: update presentity set etag='*#-OFFLINE-#*',expires=1443433545,body='<?xml version="1.0"?>#012<dialog-info xmlns="urn:ietf:params:xml:ns:dialog-info" version="00000000000" state="full" entity="sip:5678*002@XXX.XXX.XX.XXX">#012  <dialog id="1074899713" call-id="1074899713" direction="recipient">#012    <state>terminated</state>#012    <remote>#012      <identity>sip:5678*011@XXX.XXX.XX.XXX</identity>#012      <target uri="sip:5678*011@XXX.XXX.XX.XXX:5060"/>#012    </remote>#012    <local>#012      <identity>sip:5678*002@XXX.XXX.XX.XXX:5060</identity>#012      <target uri="sip:5678*002@XXX.XXX.XX.XXX:5060"/>#012    </local>#012  </dialog>#012</dialog-info>#012' where username='5678*002' AND domain='XXX.XXX.XX.XXX' AND event='dialog' AND etag='a.1442821424.10032.187.0'
Sep 28 11:45:45 km1 kamailio_presence[10037]: ERROR: <core> [db_query.c:339]: db_do_update(): error while submitting query
Sep 28 11:45:45 km1 kamailio_presence[10037]: ERROR: db_postgres [km_dbase.c:580]: db_postgres_store_result(): invalid query, execution aborted
Sep 28 11:45:45 km1 kamailio_presence[10037]: ERROR: db_postgres [km_dbase.c:581]: db_postgres_store_result(): driver error: PGRES_FATAL_ERROR, ERROR:  duplicate key value violates unique constraint "presentity_presentity_idx"#012DETAIL:  Key (username, domain, event, etag)=(5678*002, XXX.XXX.XX.XXX, dialog, *#-OFFLINE-#*) already exists.
Sep 28 11:45:45 km1 kamailio_presence[10037]: WARNING: db_postgres [km_dbase.c:690]: db_postgres_update(): unexpected result returned
Sep 28 11:45:45 km1 kamailio_presence[10037]: ERROR: presence [presentity.c:1324]: mark_presentity_for_delete(): unsuccessful sql update operation
Sep 28 11:45:45 km1 kamailio_presence[10037]: ERROR: presence [publish.c:169]: msg_presentity_clean(): Marking presentity
Sep 28 11:45:47 km1 kamailio_presence[10036]: INFO: presence [subscribe.c:1601]: get_database_info(): No matching subscription dialog found in database
Sep 28 11:45:47 km1 kamailio_presence[10036]: INFO: presence [subscribe.c:949]: handle_subscribe(): getting stored info
Sep 28 11:45:55 km1 kamailio_presence[10035]: ERROR: presence [subscribe.c:1617]: get_database_info(): wrong sequence number received: 22 - stored: 22
Sep 28 11:45:55 km1 kamailio_presence[10035]: INFO: presence [subscribe.c:949]: handle_subscribe(): getting stored info
Sep 28 11:45:55 km1 kamailio_presence[10036]: INFO: presence [subscribe.c:1601]: get_database_info(): No matching subscription dialog found in database
Sep 28 11:45:55 km1 kamailio_presence[10036]: INFO: presence [subscribe.c:949]: handle_subscribe(): getting stored info
Sep 28 11:46:03 km1 kamailio_presence[10031]: ERROR: presence [subscribe.c:1617]: get_database_info(): wrong sequence number received: 22 - stored: 22
Sep 28 11:46:03 km1 kamailio_presence[10031]: INFO: presence [subscribe.c:949]: handle_subscribe(): getting stored info
Sep 28 11:46:03 km1 kamailio_presence[10033]: INFO: presence [subscribe.c:1601]: get_database_info(): No matching subscription dialog found in database
Sep 28 11:46:03 km1 kamailio_presence[10033]: INFO: presence [subscribe.c:949]: handle_subscribe(): getting stored info
Sep 28 11:46:11 km1 kamailio_presence[10034]: ERROR: presence [subscribe.c:1617]: get_database_info(): wrong sequence number received: 22 - stored: 22
Sep 28 11:46:11 km1 kamailio_presence[10034]: INFO: presence [subscribe.c:949]: handle_subscribe(): getting stored info
Sep 28 11:46:11 km1 kamailio_presence[10035]: INFO: presence [subscribe.c:1601]: get_database_info(): No matching subscription dialog found in database
Sep 28 11:46:11 km1 kamailio_presence[10035]: INFO: presence [subscribe.c:949]: handle_subscribe(): getting stored info
Sep 28 11:46:25 km1 kamailio_presence[10037]: WARNING: db_postgres [km_dbase.c:277]: db_postgres_submit_query(): postgres result check failed with code 7 (PGRES_FATAL_ERROR)
Sep 28 11:46:25 km1 kamailio_presence[10037]: WARNING: db_postgres [km_dbase.c:281]: db_postgres_submit_query(): postgres query command failed, connection status 0, error [ERROR:  duplicate key value violates unique constraint "presentity_presentity_idx"#012DETAIL:  Key (username, domain, event, etag)=(5678*012, XXX.XXX.XX.XXX, dialog, *#-OFFLINE-#*) already exists.#012]
Sep 28 11:46:25 km1 kamailio_presence[10037]: ERROR: db_postgres [km_dbase.c:290]: db_postgres_submit_query(): 0x7f0dd4497060 PQsendQuery Error: ERROR:  duplicate key value violates unique constraint "presentity_presentity_idx"#012DETAIL:  Key (username, domain, event, etag)=(5678*012, XXX.XXX.XX.XXX, dialog, *#-OFFLINE-#*) already exists.#012 Query: update presentity set etag='*#-OFFLINE-#*',expires=1443433585,body='<?xml version="1.0"?>#012<dialog-info xmlns="urn:ietf:params:xml:ns:dialog-info" version="00000000000" state="full" entity="sip:5678*012@XXX.XXX.XX.XXX">#012  <dialog id="CLaNCoBMpzbMBIZ6wPvEFw.." call-id="CLaNCoBMpzbMBIZ6wPvEFw.." direction="recipient">#012    <state>terminated</state>#012    <remote>#012      <identity>sip:5678*002@XXX.XXX.XX.XXX;transport=TCP</identity>#012      <target uri="sip:5678*002@192.168.1.20:63157;transport=tcp;alias=XXX.XXX.XX.XXX~49663~2"/>#012    </remote>#012    <local>#012      <identity>sip:5678*012@XXX.XXX.XX.XXX;transport=TCP</identity>#012      <target uri="sip:5678*012@XXX.XXX.XX.XXX;transport=TCP"/>#012    </local>#012  </dialog>#012</dialog-info>#012' where username='5678*012' AND domain='XXX.XXX.XX.XXX' AND event='dialog' AND etag='a.1442821424.10036.177.0'
Sep 28 11:46:25 km1 kamailio_presence[10037]: ERROR: <core> [db_query.c:339]: db_do_update(): error while submitting query
Sep 28 11:46:25 km1 kamailio_presence[10037]: ERROR: db_postgres [km_dbase.c:580]: db_postgres_store_result(): invalid query, execution aborted
Sep 28 11:46:25 km1 kamailio_presence[10037]: ERROR: db_postgres [km_dbase.c:581]: db_postgres_store_result(): driver error: PGRES_FATAL_ERROR, ERROR:  duplicate key value violates unique constraint "presentity_presentity_idx"#012DETAIL:  Key (username, domain, event, etag)=(5678*012, XXX.XXX.XX.XXX, dialog, *#-OFFLINE-#*) already exists.
Sep 28 11:46:25 km1 kamailio_presence[10037]: WARNING: db_postgres [km_dbase.c:690]: db_postgres_update(): unexpected result returned
Sep 28 11:46:25 km1 kamailio_presence[10037]: ERROR: presence [presentity.c:1324]: mark_presentity_for_delete(): unsuccessful sql update operation
Sep 28 11:46:25 km1 kamailio_presence[10037]: ERROR: presence [publish.c:169]: msg_presentity_clean(): Marking presentity
Sep 28 11:47:05 km1 kamailio_presence[10037]: WARNING: db_postgres [km_dbase.c:277]: db_postgres_submit_query(): postgres result check failed with code 7 (PGRES_FATAL_ERROR)
Sep 28 11:47:05 km1 kamailio_presence[10037]: WARNING: db_postgres [km_dbase.c:281]: db_postgres_submit_query(): postgres query command failed, connection status 0, error [ERROR:  duplicate key value violates unique constraint "presentity_presentity_idx"#012DETAIL:  Key (username, domain, event, etag)=(5678*012, XXX.XXX.XX.XXX, dialog, *#-OFFLINE-#*) already exists.#012]
Sep 28 11:47:05 km1 kamailio_presence[10037]: ERROR: db_postgres [km_dbase.c:290]: db_postgres_submit_query(): 0x7f0dd4497060 PQsendQuery Error: ERROR:  duplicate key value violates unique constraint "presentity_presentity_idx"#012DETAIL:  Key (username, domain, event, etag)=(5678*012, XXX.XXX.XX.XXX, dialog, *#-OFFLINE-#*) already exists.#012 Query: update presentity set etag='*#-OFFLINE-#*',expires=1443433625,body='<?xml version="1.0"?>#012<dialog-info xmlns="urn:ietf:params:xml:ns:dialog-info" version="00000000000" state="full" entity="sip:5678*012@XXX.XXX.XX.XXX">#012  <dialog id="CLaNCoBMpzbMBIZ6wPvEFw.." call-id="CLaNCoBMpzbMBIZ6wPvEFw.." direction="recipient">#012    <state>terminated</state>#012    <remote>#012      <identity>sip:5678*002@XXX.XXX.XX.XXX;transport=TCP</identity>#012      <target uri="sip:5678*002@192.168.1.20:63157;transport=tcp;alias=XXX.XXX.XX.XXX~49663~2"/>#012    </remote>#012    <local>#012      <identity>sip:5678*012@XXX.XXX.XX.XXX;transport=TCP</identity>#012      <target uri="sip:5678*012@XXX.XXX.XX.XXX;transport=TCP"/>#012    </local>#012  </dialog>#012</dialog-info>#012' where username='5678*012' AND domain='XXX.XXX.XX.XXX' AND event='dialog' AND etag='a.1442821424.10036.177.0'
Sep 28 11:47:05 km1 kamailio_presence[10037]: ERROR: <core> [db_query.c:339]: db_do_update(): error while submitting query
Sep 28 11:47:05 km1 kamailio_presence[10037]: ERROR: db_postgres [km_dbase.c:580]: db_postgres_store_result(): invalid query, execution aborted
Sep 28 11:47:05 km1 kamailio_presence[10037]: ERROR: db_postgres [km_dbase.c:581]: db_postgres_store_result(): driver error: PGRES_FATAL_ERROR, ERROR:  duplicate key value violates unique constraint "presentity_presentity_idx"#012DETAIL:  Key (username, domain, event, etag)=(5678*012, XXX.XXX.XX.XXX, dialog, *#-OFFLINE-#*) already exists.
Sep 28 11:47:05 km1 kamailio_presence[10037]: WARNING: db_postgres [km_dbase.c:690]: db_postgres_update(): unexpected result returned
Sep 28 11:47:05 km1 kamailio_presence[10037]: ERROR: presence [presentity.c:1324]: mark_presentity_for_delete(): unsuccessful sql update operation
Sep 28 11:47:05 km1 kamailio_presence[10037]: ERROR: presence [publish.c:169]: msg_presentity_clean(): Marking presentity


  

On Fri, Sep 11, 2015 at 1:16 PM, Daniel-Constantin Mierla <miconda@gmail.com> wrote:
Hello,

I will adjust the tutorial to make the note about PUBLISH looping back and need to authorize it by IP check.

Regarding "db_mode", are you referring to "subs_db_mode" parameter?

Cheers,
Daniel