-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: data_coding should not be applied to all fields that are C-Octet Strings #188
Comments
I think that data_coding field is property of short_message, not client |
Hi @Slavix72 client = naz.Client(
smsc_host="127.0.0.1",
smsc_port=2775,
system_id="smppclient1",
password="password",
codec_class=naz.nazcodec.SimpleNazCodec(encoding="ucs2"),
) I'm able to reproduce this. Smpp server logs; 2019.12.03 12:56:24 895 WARNING 19 Bind failed authentication check.
INFO 19 : BIND_TRANSCEIVER_RESP:
INFO 19 Hex dump (16) bytes:
INFO 19 00000010:80000009:0000000F:00000006:
INFO 19
INFO 19 cmd_len=16,cmd_id=-2147483639,cmd_status=15,seq_no=6,system_id=SMPPSim and {
"timestamp": "2019-12-03 15:56:20,891",
"event": "naz.Client.command_handlers",
"smpp_command": "bind_transceiver_resp",
"command_status": 15,
"state": "Invalid System ID",
"smsc_host": "127.0.0.1",
"system_id": "smppclient1",
} This is because of; Line 798 in c47f503
|
note to self: although nazcodec allows any python standard encoding[1]; Line 276 in c47f503
naz.Client._find_data_coding does not play nice; Lines 671 to 676 in c47f503
|
@Slavix72 I'll prepare a fix for this. |
Actually we cant use all python standard encodings, only the ones defined in SMPP spec;
|
…ields (#190) What: - BugFix, `data_coding` should not be applied to all fields that are of type C-octet string - Have the naz messsage protocol only use `utf8` for encoding/decoding Why: - fixes: #188 - A C-Octet string, is a series of ASCII characters terminated with the NULL character. see; section 3.1 of SMPP spec Thus we need to encode any field that is a C-Octet strings as ascii and also terminate them with NULL char(chr(0).encode()) eg, ` system_id.encode("ascii") + chr(0).encode()` Also they should be decoded as such; `message_id.decode('ascii')`
@Slavix72 this should now be fixed. Try version https://pypi.org/project/naz/0.7.5/ Also please read the changelog: https://github.com/komuw/naz/blob/master/CHANGELOG.md#version-v075 |
this client should now work okay; client = naz.Client(
...
codec=naz.codec.SimpleCodec(encoding="ucs2"),
) |
Python 3.8
Ubuntu 18.04
Naz 0.7.4
I want to send short message (or long short message = message payload) with message_encoding= 8.
I set client.codec_class.encoding eqaul 'ucs2' before client.submit_sm() call.
Naz creates smpp packet:
00 00 00 41 00 00 00 04 00 00 00 00 00 00 00 05 00 00 01 00 32 00 30 00 32 00 01 01 00 37 00 39 00 30 00 38 00 36 00 33 00 31 00 31 00 31 00 33 00 30 00 00 00 00 00 00 00 00 00 00 04 00 37 00 37
Naz encode text='77' to ucs2_codes = 0037 0037. But it encodes src_addr and dst_addr too.
SMSC can not receive such packet.
Packet with correct src_addr and dst_addr is
00 00 00 31 00 00 00 04 00 00 00 00 00 00 00 05 00 00 01 32 30 32 00 01 01 37 39 30 38 36 33 31 31 31 33 30 00 00 00 00 00 00 00 00 00 00 02 37 37
How to encode short_message only to ucs2_codes?
The text was updated successfully, but these errors were encountered: