jackkum / node-pdu

Creates and parses a SMS PDU strings
MIT License
16 stars 11 forks source link

Splitting long messages results in missing characters #32

Open blackchineykh opened 2 months ago

blackchineykh commented 2 months ago

Hi, I have a situation where there seems to be missing characters in the resulting SMS messages received on the device. I wrote the below code to demonstrate what the results are:

const number = "19991234567";
const message = "Hi Friend, we found 73 new results for your Search criteria. View these new matches at https://mywebsiteonlineresults.com/profile/search-results.html?id=12345&passw=rilkb806s1h"

let submit = pdu.Submit()
submit.setAddress(number)
submit.setData(message)

let parts = submit.getParts()

console.log(`Original long message: `, message)

let result = "";
for (let i = 0; i < parts.length; i++) {
    console.log(`Encoded message part ${i} is: `, parts[i].toString())

    const decodedMessage = pdu.parse(parts[i].toString());
    console.log(`Decoded message part ${i} is: `, decodedMessage.getData().getText())
    result += decodedMessage.getData().getText();
}

console.log(`Resulting long message: `, result)

The resulting output does not match the original message. See the logged outputs below:

Original long message:  Hi Friend, we found 73 new results for your Search criteria. View these new matches at https://mywebsiteonlineresults.com/profile/search-results.html?id=12345&passw=rilkb806s1h
Encoded message part 0 is:  0041000B919199214365F700008C06080433B40201C834C8284F97DD6416E85E0699DF753719749B81DCE53B485E9ED7D9F439C8FC9683F2EFBA1C342D87E56334682C4FD3CBF274D805B2A6CB77101D5D9E9741EEF21DD40ED3C7E8F21C14A683D0743A7CAE7BBDDAF97B593C4FD3CB6F373BED2ECBCBF33A9B3E778DDFED175CFE36A7D9E5D7BC1C06
Decoded message part 0 is:  Hi Friend, we found 73 new results for your Search criteria. View these new matches at https://mywebsiteonlineresults.com/profile/se
Encoded message part 1 is:  0041000B919199214365F700003206080433B40202F231BA252FCFEB6CFADC85A6B7D9BF34B91793CD6835133C3C9FDF7BF2347B2DC6C16CF3181A
Decoded message part 1 is:  rch-results.html?id=12345&passw=rilkb806s1
Resulting long message:  Hi Friend, we found 73 new results for your Search criteria. View these new matches at https://mywebsiteonlineresults.com/profile/serch-results.html?id=12345&passw=rilkb806s1

You can see here serch-results.html that in the resulting message to the device that some characters are removed.

I also tried with the latest version using this code:

const number = "19991234567";
const message = "Hi Friend, we found 73 new results for your Search criteria. View these new matches at https://mywebsiteonlineresults.com/profile/search-results.html?id=12345&passw=rilkb806s1h"

let submit = new Submit(number, message);

console.log(`Original long message: `, message)
console.log(`Encoded message: `, submit.toString())

Here is the output:

Original long message:  Hi Friend, we found 73 new results for your Search criteria. View these new matches at https://mywebsiteonlineresults.com/profile/search-results.html?id=12345&passw=rilkb806s1h
Encoded message:  0041000B819199214365F700008C06080465430201C834C8284F97DD6416E85E0699DF753719749B81DCE53B485E9ED7D9F439C8FC9683F2EFBA1C342D87E56334682C4FD3CBF274D805B2A6CB77101D5D9E9741EEF21DD40ED3C7E8F21C14A683D0743A7CAE7BBDDAF97B593C4FD3CB6F373BED2ECBCBF33A9B3E778DDFED175CFE36A7D9E5D7BC1C06
0041000B819199214365F700003206080465430202F231BA252FCFEB6CFADC85A6B7D9BF34B91793CD6835133C3C9FDF7BF2347B2DC6C16CF3181A
KillerJulian commented 2 months ago

First of all, thank you very much for the well-described issue with code examples.

Your problem seems to be similar to this one, am I right? https://github.com/jackkum/node-pdu/issues/21#issuecomment-1786716694

blackchineykh commented 1 month ago

First of all, thank you very much for the well-described issue with code examples.

Your problem seems to be similar to this one, am I right? #21 (comment)

Yes it is similar