mikesafonov / spring-boot-starter-smpp Goto Github PK
View Code? Open in Web Editor NEWSpring boot starter to send SMS via SMPP
License: MIT License
Spring boot starter to send SMS via SMPP
License: MIT License
Hi Mike,
Hope you are doing well. I have been using your project from last 2 months in my production system. It fulfilled many of my business requirements. A great work. Really appreciated. My question is can you please add new feature to send a flash message.
Regards,
Haseeb Majeed
Hi @MikeSafonov
Current when trying to receive an inbound mo I get the following exception. Sometimes an smsc doesn't return a message with an id therefore it fails here
com.cloudhopper.smpp.util.DeliveryReceiptException: Unable to find [id] field or empty value in delivery receipt message
at com.cloudhopper.smpp.util.DeliveryReceipt.parseShortMessage(DeliveryReceipt.java:510) ~[ch-smpp-5.1.0-113.jar!/:5.1.0-113]
at com.cloudhopper.smpp.util.DeliveryReceipt.parseShortMessage(DeliveryReceipt.java:365) ~[ch-smpp-5.1.0-113.jar!/:5.1.0-113]
at com.cloudhopper.smpp.util.DeliveryReceipt.parseShortMessage(DeliveryReceipt.java:349) ~[ch-smpp-5.1.0-113.jar!/:5.1.0-113]
at com.github.mikesafonov.smpp.core.reciever.ResponseSmppSessionHandler.toReport(ResponseSmppSessionHandler.java:65) ~[spring-boot-starter-smpp-1.4.0.jar!/:na]
Could you kindly change it to this.
private DeliveryReport toReport(DeliverSm deliverSm) throws DeliveryReceiptException {
byte[] shortMessage = deliverSm.getShortMessage();
String sms = new String(shortMessage);
DeliveryReceipt deliveryReceipt = DeliveryReceipt.parseShortMessage(sms, DateTimeZone.UTC, false);
return DeliveryReport.of(deliveryReceipt, clientId);
}
Edit:
Finally found the issue is related to an MO message. When it is parsed the body doesn't contain delivery receipt but instead contains an actual message.
Was able to add the following to ResponseSmppSessionHandler
public class ResponseSmppSessionHandler extends DefaultSmppSessionHandler {
private final String clientId;
private final List<DeliveryReportConsumer> deliveryReportConsumers;
private final List<ReceivedMessageConsumer> receivedMessageConsumers;
public ResponseSmppSessionHandler(String clientId, List<DeliveryReportConsumer> deliveryReportConsumers, List<ReceivedMessageConsumer> receivedMessageConsumers) {
this.clientId = requireNonNull(clientId);
this.deliveryReportConsumers = requireNonNull(deliveryReportConsumers);
this.receivedMessageConsumers = requireNonNull(receivedMessageConsumers);
}
@Override
public PduResponse firePduRequestReceived(PduRequest pduRequest) {
log.debug(pduRequest.toString());
if (isDelivery(pduRequest)) {
processReport(pduRequest);
}
return pduRequest.createResponse();
}
private boolean isDelivery(PduRequest pduRequest) {
return pduRequest.isRequest() && pduRequest.getClass() == DeliverSm.class;
}
private void processReport(PduRequest pduRequest) {
DeliverSm dlr = (DeliverSm) pduRequest;
try {
if(dlr.getEsmClass() == 0x04){
DeliveryReport report = toReport(dlr);
for (DeliveryReportConsumer deliveryReportConsumer : deliveryReportConsumers) {
deliveryReportConsumer.accept(report);
}
}
else{
ReceivedMessage receivedMessage = toReceivedMessage(dlr);
for (ReceivedMessageConsumer consumer: receivedMessageConsumers){
consumer.accept(receivedMessage);
}
}
} catch (DeliveryReceiptException e) {
log.error(e.getMessage(), e);
}
}
private ReceivedMessage toReceivedMessage(DeliverSm deliverSm){
ReceivedMessage receivedMessage = new ReceivedMessage();
receivedMessage.setText(new String(deliverSm.getShortMessage()));
receivedMessage.setSource(deliverSm.getSourceAddress().getAddress());
receivedMessage.setMsisdn(deliverSm.getDestAddress().getAddress());
receivedMessage.setMessageId(Integer.toString(deliverSm.getSequenceNumber()));
return receivedMessage;
}
private DeliveryReport toReport(DeliverSm deliverSm) throws DeliveryReceiptException {
byte[] shortMessage = deliverSm.getShortMessage();
String sms = new String(shortMessage);
DeliveryReceipt deliveryReceipt = DeliveryReceipt.parseShortMessage(sms, DateTimeZone.UTC, false);
return DeliveryReport.of(deliveryReceipt, clientId);
}
}
I found that there are a lot of failed message in bind request with reason “ESME has maxed out its allowed sessions”. Currently, we set the maximum sessions as 10 in each site. But it seems your application will bind more than 20 sessions to submit SMS. For the submissions, you can use the same sessions to submit 200 messages/second (your production accounts are using this logic) instead to bind X sessions to submit 200 messages/second.
how can i setting for : maximum sessions as 10 in each site.
Would like to contribute to this library. Send me your email Id. Sorry for adding this message as an issue.
Hi,
firstly I'd like to thank you for your great library :)
I've got a question if it's possible to set validity period (smsc expiration time) for the message?
Greetings,
cholo
Hi!
Does current implementation of this starter support SubmitMulti?
I see the last (real) commit is from over a year ago. Is this still a relevant/wanted project?
If so I can contribute, I have Java and SMPP knowledge.
If the user send message to shortcode, like order something, then how to get this message by host,port,systemId,password etc
Hello,
is there a way to always try to bind with TRANSCEIVER, instead of TRANSMITTER and RECEIVER?
Hi. Thank you for creating this library. Just wondering what's the license for this project. It seems its MIT. However the dependencies are AGPL like org.restcomm.smpp
.
https://mvnrepository.com/artifact/org.restcomm.smpp/ch-commons-util/7.0.6
Is it possible to move to something like com.cloudhopper
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.