twitter-archive / cloudhopper-smpp

Efficient, scalable, and flexible Java implementation of the Short Messaging Peer to Peer Protocol (SMPP)
Other
381 stars 357 forks source link

Unable to send long message which is greater than 255 chars using cloudhopper #72

Closed New009 closed 9 years ago

New009 commented 9 years ago

Hi All,

When we are trying to push a longer message which is more than 255 characters length, i am getting the below error message from cloud hopper. But in our case, the SMSC element is handling the split of longer messages. We are requested not to split at our end.

com.cloudhopper.smpp.type.SmppInvalidArgumentException: A short message in a PDU can only be a max of 255 bytes [actual=535]; use optional parameter message_payload as an alternative

How can we make the cloud hopper API by pass this validation and push the message directly to SMSC element so that SMSC takes care of split logic.

Thanks

krasa commented 9 years ago

Have you looked into the code?


    public void setShortMessage(byte[] value) throws SmppInvalidArgumentException {
        if (value != null && value.length > 255) {
            throw new SmppInvalidArgumentException("A short message in a PDU can only be a max of 255 bytes [actual=" + value.length + "]; use optional parameter message_payload as an alternative");
        }
        this.shortMessage = value;
    }

Either use your own patched version, or try to use reflection and not the setter.

imade commented 9 years ago

A more correct way would be to use the message_payload TLV which allows you to send up to 64k octets. It's part of the optional parameters. If your SMSC is spec compliant it should handle message_payload nicely. Check the SMPP spec for more info.

Madhukiran81 commented 9 years ago

can any one share, how to set the optional parameters (TLV) to use message_Payload to send the message more than 255 characters. and one more is if use use message_payload do we need to set the sm_length as 0.?? if yes how can we set it to 0 because in submit_sm it is set to private like this. // setSmLength() is private as it's set to length of the message private void setSmLength(short value) { smLength = value; }

lafod commented 8 years ago

if (textBytes != null && textBytes.length > 255) { submitMsg.addOptionalParameter(new Tlv(SmppConstants.TAG_MESSAGE_PAYLOAD, textBytes, "message_payload")); }else{ submitMsg.setShortMessage(textBytes); }