Skip to content
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

toBuffer throws an exception for PDUs that cannot have bodies #9

Closed
xaka opened this issue Jul 16, 2014 · 1 comment
Closed

toBuffer throws an exception for PDUs that cannot have bodies #9

xaka opened this issue Jul 16, 2014 · 1 comment

Comments

@xaka
Copy link
Contributor

xaka commented Jul 16, 2014

Hi there,

As per SMPP specification the submit_sm_resp command cannot have body if the status is not a zero. It's not respected by library and so you end up with:

../node_modules/smpp/lib/defs.js:70
                        value.copy(buffer, offset);
                              ^
TypeError: Cannot call method 'copy' of undefined
    at Object.types.cstring.write (../node_modules/smpp/lib/defs.js:70:10)
    at PDU.toBuffer (../node_modules/smpp/lib/pdu.js:136:20)
    at Session.send (../node_modules/smpp/lib/smpp.js:73:24)
    at Session.onPdu (../main.js:152:23)
    at Session.emit (events.js:95:17)
    at Session._extractPDUs (../node_modules/smpp/lib/smpp.js:52:8)
    at Socket.<anonymous> (../node_modules/smpp/lib/smpp.js:29:8)
    at Socket.emit (events.js:95:17)
    at Socket.<anonymous> (_stream_readable.js:748:14)
    at Socket.emit (events.js:92:17)

I'm not sure yet what would be the best solution, but as a workaround i had to add a check to toBuffer method and skip encoding.

We probably should add some kind of flag to commands that not allow the body when status is not a zero and add support for it to toBuffer method.

farhadi added a commit that referenced this issue Jul 19, 2014
As per SMPP specification, "When a response PDU carries a non-NULL command_status field,
it is indicating some form of error or rejection of the original request PDU. In such circumstances,
a PDU body should not be included in the PDU and the command_length of the PDU should therefore
be set to 16."
@farhadi farhadi closed this as completed Jul 19, 2014
@farhadi
Copy link
Owner

farhadi commented Jul 19, 2014

Thanks for the report.
I just fixed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants