[SIP Beyond VoIP] Sylk-server "db.connection is null" duringthe saving message

Anil KARADAG akaradag at NETAS.com.tr
Wed Oct 17 10:29:15 CEST 2012


I found it[1].


Thanks



[1] http://projects.ag-projects.com/projects/sylkserver/repository/revisions/387

-----Original Message-----
From: sipbeyondvoip-bounces at lists.ag-projects.com [mailto:sipbeyondvoip-bounces at lists.ag-projects.com] On Behalf Of Anil KARADAG
Sent: Wednesday, October 17, 2012 11:00 AM
To: Saúl Ibarra Corretgé
Cc: sipbeyondvoip at lists.ag-projects.com
Subject: Re: [SIP Beyond VoIP] Sylk-server "db.connection is null" duringthe saving message

Hi Saúl,


Thanks for reply, please sent me the bug info;

- issue number
- issue link


to see diff for verification.


-----Original Message-----
From: Saúl Ibarra Corretgé [mailto:saul at ag-projects.com] 
Sent: Wednesday, October 17, 2012 10:56 AM
To: Anil KARADAG
Cc: sipbeyondvoip at lists.ag-projects.com
Subject: Re: [SIP Beyond VoIP] Sylk-server "db.connection is null" during the saving message

Hi Anil,

Thanks for the report! I pushed a fix for this to our darcs repository, it will be part of the next release. Can you confirm it works as expected for you?


Regards,


On Oct 17, 2012, at 8:54 AM, Anil KARADAG wrote:

> Hi all,
>  
>  
>  
> I use sylk-server 2.1.0 on ubuntu 11.04. I realize that sylk-server does not write chat message to the pre-defined database.
> I added some debug logs to applications->conference->room.py and applications->conference->database.py
>  
>  
> applications->conference->database.py
>  
> def initialize():
>     print "Function conference.database.initialize";
>     print "ConferenceConfig.db_uri:%s" %(ConferenceConfig.db_uri)
>     db = Database(ConferenceConfig.db_uri)
>     if db.connection is not Null:
>         print db.connection.__dict__
>     MessageHistory._connection = db.connection
>     db.create_table(MessageHistory)
>  
>  
> def _save_message(sip_from, room_uri, cpim_body, cpim_content_type, cpim_sender, cpim_recipient, cpim_timestamp):
>     print "Function _save_message"
>     for x in xrange(0, 3):
>         try:
>             return MessageHistory(date              = datetime.datetime.utcnow(),
>                                 room_uri          = room_uri,
>                                 sip_from          = sip_from,
>                                 cpim_body         = cpim_body,
>                                 cpim_content_type = cpim_content_type,
>                                 cpim_sender       = cpim_sender,
>                                 cpim_recipient    = cpim_recipient,
>                                 cpim_timestamp    = cpim_timestamp)
>         except Exception, e:
>             time.sleep(0.2)
>     print "Could not save DB records: %s" %(e)
>     log.error('Could not save DB records: %s' % e)
>     return
>  
> def async_save_message(sip_from, room_uri, cpim_body, cpim_content_type, cpim_sender, cpim_recipient, cpim_timestamp):
>     print "Function async_save_message";
>     if db.connection is not Null:
>         print "Function async_save_message: db.connection is not null";
>         return deferToThread(_save_message, sip_from, room_uri, cpim_body, cpim_content_type, cpim_sender, cpim_recipient, cpim_timestamp)
>     else:
>         print "db.connection is null"
>  
>  
> applications->conference->room.py
>  
> def _message_dispatcher(self):
>         """Read from self.incoming_message_queue and dispatch the messages to other participants"""
>        while True:
>             session, message_type, data = self.incoming_message_queue.wait()
>             print "Chat Message type: %s" %(message_type)
>             if message_type == 'message':
>                 message = data.message
>                 print "message.sender.uri=%s, session.remote_identity.uri=%s" %(message.sender.uri, session.remote_identity.uri)
>  
>             ...
>  
>  
>  
> According to below logs, the variable "db" is set within conference.database.initialize function but the instance is overwritten because db.connection is null within async_save_message.
> So no messages is written to database.
>  
>  
> root at trhtlangley35:/usr/lib/python2.7/dist-packages/sylk/applications/conference# /usr/bin/sylk-server --no-fork
> Starting SylkServer 2.1.0, config=/etc/sylkserver/config.ini
> using set_wakeup_fd
> ...
> Loaded applications: conference, xmppgateway, irc-conference
> Function conference.database.initialize
> ConferenceConfig.db_uri:sqlite:///var/lib/sylkserver/conference.sqlite
> {'debugThreading': False, 'module': <module 'sqlite3' from '/usr/lib/python2.7/sqlite3/__init__.pyc'>, 'debugOutput': False, 'style': None, 'debugWriter': <sqlobject.dbconnection.ConsoleWriter instance at 0x2f6a3f8>, '_connectionCount': 1, 'cache': <sqlobject.cache.CacheSet object at 0x2f96990>, 'filename': '/var/lib/sylkserver/conference.sqlite', 'autoCommit': True, '_connOptions': {'isolation_level': None, 'detect_types': 1}, '_threadPool': {}, 'registry': None, '_threadOrigination': {}, 'SQLObject': <sqlobject.dbconnection.ConnWrapper object at 0x2f96a10>, 'name': None, 'using_sqlite2': True, '_pool': [], 'MessageHistory': <sqlobject.dbconnection.ConnWrapper object at 0x2f96a50>, 'doCache': True, '_memory': False, 'debug': False, 'use_table_info': False, '_binaryType': <type 'buffer'>, '_connectionNumbers': {}, '_poolLock': <thread.lock object at 0x213aeb0>}
> [conference] Bonjour publication started for service 'sipfocus'
> [conference] Bonjour publication started for service 'sipuri'
> twisted.web.server.Site starting on 58525
> Starting factory <twisted.web.server.Site instance at 0x2f99680>
> [conference] ScreenSharing listener started on 47.168.85.98:58525
> <class 'sylk.applications.xmppgateway.xmpp.XMPPS2SServerFactory'> starting on 5269
> Starting factory <sylk.applications.xmppgateway.xmpp.XMPPS2SServerFactory object at 0x2f6b810>
> [xmpp] XMPP listener started on 47.168.85.98:5269
> [conference] New incoming session from sip:odolu2 at nl12taf.com
> eventlib.twistedutil.protocol.SpawnFactory starting on 60606
> Starting factory <eventlib.twistedutil.protocol.SpawnFactory instance at 0x2a53bd8>
> (TCP Port 60606 Closed)
> Stopping factory <eventlib.twistedutil.protocol.SpawnFactory instance at 0x2a53bd8>
> [conference] test test <sip:test at abc.com> started conference meetme at abc.com with chat
> Function async_save_message
> db.connection is null
> Chat Message type: message
> message.sender.uri=sip:test at abc.com, session.remote_identity.uri=sip:test at abc.com
> Function async_save_message
> db.connection is null
>  
>  
>  
>  
> I tried the write operation on the python console, there is no problem.
>  
>  
> root at trhtlangley35:~# python
> Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53)
> [GCC 4.5.2] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import sylk
> >>> from sylk.applications.conference.database import *
> using set_wakeup_fd
> >>> from sylk.applications.conference.configuration import ConferenceConfig
> >>> from sylk.database import Database
> >>> db = Database(ConferenceConfig.db_uri)
> >>> import datetime
> >>> sylk.applications.conference.database._save_message("odolu2 at nl12taf.com", "test", "test", "text", "odolu2 at nl12taf.com", "odolu1 at nl12taf.com", datetime.datetime.today())
> error: [conference] Could not save DB records: No connection has been defined for this thread or process
> >>> 
> >>> sylk.applications.conference.database.MessageHistory._connection = db.connection
> >>> sylk.applications.conference.database._save_message("odolu2 at nl12taf.com", "test", "test", "text", "odolu2 at nl12taf.com", "odolu1 at nl12taf.com", datetime.datetime.today())
> <MessageHistory 2 date='datetime.datetime...)' room_uri=u'test' sip_from="u'odolu2 at nl12taf....'" cpim_body=u'test' cpim_content_type=u'text' cpim_sender="u'odolu2 at nl12taf....'" cpim_recipient="u'odolu1 at nl12taf....'" cpim_timestamp='datetime.datetime...)'>
>  
> _______________________________________________
> SIPBeyondVoIP mailing list
> SIPBeyondVoIP at lists.ag-projects.com
> http://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip

--
Saúl Ibarra Corretgé
AG Projects



_______________________________________________
SIPBeyondVoIP mailing list
SIPBeyondVoIP at lists.ag-projects.com
http://lists.ag-projects.com/mailman/listinfo/sipbeyondvoip


More information about the SIPBeyondVoIP mailing list