Skip to content

smpplib.exceptions.UnknownCommandError: Unknown SMPP command code "0x2001" #190

@AnnaLupanova

Description

@AnnaLupanova

Hi. I use python 3.6 and I get this error when sending a delivery report from SMSC.

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/smpplib-2.2.1-py3.6.egg/smpplib/client.py", line 401, in listen
  File "/usr/local/lib/python3.6/site-packages/smpplib-2.2.1-py3.6.egg/smpplib/client.py", line 355, in read_once
  File "/usr/local/lib/python3.6/site-packages/smpplib-2.2.1-py3.6.egg/smpplib/client.py", line 268, in read_pdu
  File "/usr/local/lib/python3.6/site-packages/smpplib-2.2.1-py3.6.egg/smpplib/smpp.py", line 41, in parse_pdu
  File "/usr/local/lib/python3.6/site-packages/smpplib-2.2.1-py3.6.egg/smpplib/pdu.py", line 127, in parse
  File "/usr/local/lib/python3.6/site-packages/smpplib-2.2.1-py3.6.egg/smpplib/command.py", line 315, in parse_params
  File "/usr/local/lib/python3.6/site-packages/smpplib-2.2.1-py3.6.egg/smpplib/command.py", line 333, in parse_optional_params
  File "/usr/local/lib/python3.6/site-packages/smpplib-2.2.1-py3.6.egg/smpplib/command.py", line 71, in get_optional_name
smpplib.exceptions.UnknownCommandError: Unknown SMPP command code "0x2001"

I also have to respond to this message with the deliver_sm_resp status. But how can I do it? Here is my code

def received_handler(pdu):
    lambda pdu: sys.stdout.write('--'.format(pdu.short_message))
    pdu_body = pdu.short_message
    pdu_phone = pdu.source_addr
    sms_1 = 'sms %s' % (pdu_body)
    logger.info(sms_1)
    phone_1 = 'phone %s' % (pdu_phone)
    logger.info(phone_1)

try:
    client = smpplib.client.Client(host,port)
    client.set_message_sent_handler(
        lambda pdu: sys.stdout.write('sent {} {}\n'.format(pdu.sequence, pdu.message_id)))
    client.set_message_received_handler(received_handler)
    client.connect()
    client.bind_transceiver(system_id=sys_id, password=pwd)

    client.listen()
except UnknownCommandError as e:
    logger.error('UnknownCommandError DELIVER SMS')
    deliver = smpplib.smpp.make_pdu('deliver_sm_resp', client=client)
    client.send_pdu(deliver)
    logger.info("SEND deliver_sm_resp")
except Exception as e:
    client.listen()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions