<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Hello,</p>
    <p>do you have tls module loaded in kamailio.cfg? If yes, can you
      try without it, just to see if there is a conflict between our
      module and the boto3 client in use of libssl, because libssl
      creates global contexts per application, not per library/object.</p>
    <p>Cheers,<br>
      Daniel<br>
    </p>
    <div class="moz-cite-prefix">On 10.04.19 01:26, Michael Loughrey
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAHNSxcbCgNXk6HXdFrf5AbkRFLPj1Cce=2NZQ-RBppf6Zgf7nQ@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div dir="ltr">
          <div dir="ltr">
            <div dir="ltr">
              <div dir="ltr">Hi All,
                <div><br>
                </div>
                <div>looking for some advice regarding the proper way to
                  initialise an AWS API boto3 client object for send SNS
                  messages within a KEMI Python 2.7 routing script. </div>
                <div><br>
                </div>
                <div>
                  <div>I'm sure process forking has a major impact on
                    how this works - from kamailio.cfg</div>
                  <div><br>
                  </div>
                  <div>
                    <div>     fork=yes</div>
                    <div>     children=4</div>
                  </div>
                  <div><br>
                  </div>
                  <div>-  but would greatly appreciate some guidance.<br>
                  </div>
                  <br
                    class="m_-6381022331019216535gmail-Apple-interchange-newline">
                </div>
                <div>I have tried various methods to allocate an client
                  object self.sns_client = boto3.client('sns',
                  region_name=MY_AWS_REGION)</div>
                <div><br>
                </div>
                <div>  1. within   __init__(), only once from module
                  initialisation</div>
                <div>  2. on demand within a function call by any client
                  code e.g. called from ksr_route_request(), each
                  creating it's own client object</div>
                <div><br>
                </div>
                <div> and so far all have resulted in intermittent
                  crashes within botocore/client.py ultimately crashing
                  thus :</div>
                <div><br>
                </div>
                <div><br>
                </div>
                <div>
                  <div>Core was generated by `/usr/local/sbin/kamailio
                    -P /usr/local/kamailio/run/kamailio.pid -f
                    /usr/local/'.</div>
                  <div>Program terminated with signal SIGSEGV,
                    Segmentation fault.</div>
                  <div>#0  0x00007f8f9734f754 in ?? () from
                    /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1</div>
                  <div>(gdb) bt</div>
                  <div>#0  0x00007f8f9734f754 in ?? () from
                    /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1</div>
                  <div>#1  0x00007f8f9734f82e in X509_VERIFY_PARAM_free
                    () from /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1</div>
                  <div>#2  0x00007f8f97642f5c in SSL_free () from
                    /usr/lib/x86_64-linux-gnu/libssl.so.1.1</div>
                  <div>#3  0x00007f8f86b09c64 in
                    PySSL_dealloc.lto_priv.5 () at ./Modules/_ssl.c:1598</div>
                  <div>#4  0x00007f8f99cbb007 in insertdict_by_entry
                    (mp=0x7f8f841f1e88, key='_sslobj',
                    hash=<optimized out>, ep=<optimized
                    out>, value=<optimized out>) at
                    ../Objects/dictobject.c:519</div>
                  <div>#5  0x00007f8f99cbe2cf in insertdict (value=None,
                    hash=1051385741686792393, key='_sslobj',
                    mp=0x7f8f841f1e88) at ../Objects/dictobject.c:556</div>
                  <div>#6  dict_set_item_by_hash_or_entry (value=None,
                    ep=0x0, hash=1051385741686792393, key='_sslobj', </div>
                  <div>    op={'server_hostname': u'<a
                      href="http://sns.us-east-1.amazonaws.com"
                      target="_blank" moz-do-not-send="true">sns.us-east-1.amazonaws.com</a>',
                    '_connected': True, '_context': <SSLContext at
                    remote 0x7f8f84232398>, 'server_side': False,
                    '_makefile_refs': 0, '_closed': False, '_sslobj':
                    None, 'do_handshake_on_connect': True,
                    'suppress_ragged_eofs': True}) at
                    ../Objects/dictobject.c:795</div>
                  <div>#7  PyDict_SetItem (op=<optimized out>,
                    key=<optimized out>, value=<optimized
                    out>) at ../Objects/dictobject.c:848</div>
                  <div>#8  0x00007f8f99becec1 in
                    _PyObject_GenericSetAttrWithDict (obj=<optimized
                    out>, name='_sslobj', value=None, </div>
                  <div>    dict={'server_hostname': u'<a
                      href="http://sns.us-east-1.amazonaws.com"
                      target="_blank" moz-do-not-send="true">sns.us-east-1.amazonaws.com</a>',
                    '_connected': True, '_context': <SSLContext at
                    remote 0x7f8f84232398>, 'server_side': False,
                    '_makefile_refs': 0, '_closed': False, '_sslobj':
                    None, 'do_handshake_on_connect': True,
                    'suppress_ragged_eofs': True}) at
                    ../Objects/object.c:1529</div>
                  <div>#9  0x00007f8f99bed437 in PyObject_SetAttr (</div>
                  <div>    v=<SSLSocket(server_hostname=u'<a
                      href="http://sns.us-east-1.amazonaws.com"
                      target="_blank" moz-do-not-send="true">sns.us-east-1.amazonaws.com</a>',
                    _connected=True, _context=<SSLContext at remote
                    0x7f8f84232398>, server_side=False,
                    _makefile_refs=0, _closed=False, _sslobj=None,
                    do_handshake_on_connect=True,
                    suppress_ragged_eofs=True) at remote
                    0x7f8f841f62a8>, name=<optimized out>,
                    value=None) at ../Objects/object.c:1247</div>
                </div>
                <div><br>
                </div>
                <div>Here's my setup<br>
                </div>
                <div>
                  <div>
                    <div><br>
                    </div>
                    <div>host : Debian9/stretch</div>
                    <div><br>
                    </div>
                    <div>
                      <div>python --version</div>
                      <div>Python 2.7.13</div>
                      <div><br>
                      </div>
                      <div>kamailio -v</div>
                      <div>version: kamailio 5.2.2 (x86_64/linux)
                        67f967-dirty</div>
                      <div>flags: STATS: Off, USE_TCP, USE_TLS,
                        USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS,
                        DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM,
                        SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC,
                        TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX,
                        FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE,
                        USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLACKLIST,
                        HAVE_RESOLV_RES, MEM_JOIN_FREE</div>
                      <div>ADAPTIVE_WAIT_LOOPS=1024,
                        MAX_RECV_BUFFER_SIZE 262144 MAX_URI_SIZE 1024,
                        BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB</div>
                      <div>poll method support: poll, epoll_lt,
                        epoll_et, sigio_rt, select.</div>
                      <div>id: 67f967 -dirty</div>
                      <div>compiled on 23:44:31 Apr  8 2019 with gcc
                        6.3.0</div>
                    </div>
                  </div>
                </div>
                <div><br>
                </div>
                <div><br>
                </div>
                <div>Cheers</div>
                <div>Mike</div>
                <div><br>
                </div>
                <div><br>
                </div>
                <div><br>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
Kamailio (SER) - Users Mailing List
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.kamailio.org">sr-users@lists.kamailio.org</a>
<a class="moz-txt-link-freetext" href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users">https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla -- <a class="moz-txt-link-abbreviated" href="http://www.asipto.com">www.asipto.com</a>
<a class="moz-txt-link-abbreviated" href="http://www.twitter.com/miconda">www.twitter.com/miconda</a> -- <a class="moz-txt-link-abbreviated" href="http://www.linkedin.com/in/miconda">www.linkedin.com/in/miconda</a>
Kamailio World Conference - May 6-8, 2019 -- <a class="moz-txt-link-abbreviated" href="http://www.kamailioworld.com">www.kamailioworld.com</a></pre>
  </body>
</html>