Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Answered by eigenein
AnnaLupanova asked this question in Q&A
Discussion options

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()
You must be logged in to vote

Hi @AnnaLupanova 👋

  1. client.listen() should take care of sending deliver_sm_resp, see
    elif pdu.command == 'deliver_sm':
    self._message_received(pdu)
  2. As for the UnknownCommandError – we're unfortunately unable to handle vendor-specific command codes at the moment. Here's the tracking issue: #105

Replies: 1 comment

Comment options

Hi @AnnaLupanova 👋

  1. client.listen() should take care of sending deliver_sm_resp, see
    elif pdu.command == 'deliver_sm':
    self._message_received(pdu)
  2. As for the UnknownCommandError – we're unfortunately unable to handle vendor-specific command codes at the moment. Here's the tracking issue: Handle vendor-specific command codes #105
You must be logged in to vote
0 replies
Answer selected by eigenein
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
Converted from issue

This discussion was converted from issue #190 on February 16, 2022 20:44.

AltStyle によって変換されたページ (->オリジナル) /