Giter Club home page Giter Club logo

opensmpp's Introduction

OpenSmpp

Java library implementing the SMPP protocol, and allowing development of External Short Message Entities (ESMEs) and more

It is based on the OpenSmpp library from http://sourceforge.net/projects/smstools/

OpenSMPP is based on the original Logica SMPP libraries. It contains several bug fixes, and has been generally refactored.

Modules

  • core - the core library
  • charset - character sets useful in SMPP
  • client - a simple SMPP client
  • sim - a simple SMSC simulator

Versions

Versions of this project are managed according to the Semantic Versioning specification.

Build Status

Build Status

License

Copyright (c) 2005, OpenSmpp Project All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  • Neither the name of the OpenSmpp Project nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

This software was originally issued under the Logica Open Source License Version 1.0, but was subsequently put in the public domain under the current BSD licence, which was deemed closest to the spirit of the original licence.

opensmpp's People

Contributors

aaray avatar dependabot[bot] avatar megadix avatar paolobsms avatar paoloc0 avatar ptomli avatar thiamteck avatar vasyaod avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opensmpp's Issues

Problem when using the deliver method to send a short messege

Hello, I use opensmpp and try the submit method (Submit_SM) and it work fine. But later i discover that i must use the deliver method (Deliver_SM) in order to use the listener side of the ESME and receive the message from the SMSC.
Here is my code the bind work fine but the response from the deliver method is always null.
Please if anyone can help me or at least give me a little example whith the deliver method
PS: I use the synchronous mode.

import org.smpp.pdu.BindRequest
import org.smpp.pdu.BindResponse
import org.smpp.pdu.BindTransciever
import org.smpp.pdu.BindTransmitter
import org.smpp.pdu.BindReceiver
import org.smpp.TCPIPConnection
import org.smpp.Session
import org.smpp.test.SMPPTest.SMPPTestPDUEventListener
import org.smpp.pdu.AddressRange
import org.smpp.Data
import org.smpp.pdu.UnbindResp
import org.smpp.pdu.DeliverSM
import org.smpp.pdu.DataSM
import org.smpp.pdu.DeliverSMResp
import org.smpp.pdu.DataSMResp
import org.smpp.pdu.PDU
import org.smpp.pdu.Request
import org.smpp.pdu.Response
import org.smpp.ServerPDUEvent
import org.smpp.pdu.Address
import org.smpp.pdu.EnquireLink
import org.smpp.pdu.EnquireLinkResp

Session session = null;
def bound = false
boolean asynchronous = false;
String bindOption = "tr";
String systemType = "";
String serviceType = "";
Address sourceAddress = new Address()
Address destAddress = new Address()
byte replaceIfPresentFlag = 0;
String shortMessage = ""; // the message to send
String scheduleDeliveryTime = "";
String validityPeriod = "" // default estimated validity default period
byte esmClass = 0;
byte protocolId = 0;
byte priorityFlag = 0;
byte registeredDelivery = 0;
byte dataCoding = 0;
byte smDefaultMsgId = 0;
String messageId = "";
long receiveTimeout = Data.RECEIVE_BLOCKING;
AddressRange addressRange = new AddressRange();
SMPPTestPDUEventListener pduListener = null;

    println "begin binding operation..."
	try {

		// test if communication is already established
		if (bound) {
			System.out.println("Already bound, unbind first.");
			return;
		}

		BindRequest request = null;
		BindResponse response = null;
		// type of the session
		String syncMode = (asynchronous ? "a" : "s");

		// input values
		

		if (bindOption.compareToIgnoreCase("t") == 0) {
			request = new BindTransmitter();
		} else if (bindOption.compareToIgnoreCase("r") == 0) {
			request = new BindReceiver();
		} else if (bindOption.compareToIgnoreCase("tr") == 0) {
			request = new BindTransciever();
		}

		ipAddress = "xxx.xxx.xx.xx";
		port = yyyy;

        println "syncMode == "+syncMode
		TCPIPConnection connection = new TCPIPConnection(ipAddress, port);
		connection.setReceiveTimeout(20 * 1000);
		session = new Session(connection);

		systemId = "nnnnnn"
		password = "nnnnnn"

		// set values
		request.setSystemId(systemId);
		request.setPassword(password);
		request.setSystemType(systemType);
		request.setInterfaceVersion((byte) 0x34);
		request.setAddressRange(addressRange);

		// send the request
		System.out.println("Bind request " + request.debugString());
		if (asynchronous) {
			pduListener = new SMPPTestPDUEventListener(session);
			response = session.bind(request, pduListener);
		} else {
			response = session.bind(request);
		}
		System.out.println("Bind response " + response.debugString());
		println "response.getCommandStatus() === "+response.getCommandStatus()
		if (response.getCommandStatus() == Data.ESME_ROK) {
			bound = true;
            println "SMSC is bound succesfuuly with the ESME"
        }
					
	} catch (Exception e) {
		//event.write(e, "");
		//debug.write("Bind operation failed. " + e);
		System.out.println("Bind operation failed. " + e);
	} finally {
		//session.unbind()
        //connection.close()
	}

	println "enquire data ... "
    try {
        final EnquireLink request = new EnquireLink();
        System.out.println("Enquire Link request " + request.debugString());
        final EnquireLinkResp response = session.enquireLink(request);
        System.out.println("Enquire Link response " + response.debugString());
    } catch (Throwable e) {
        e.printStackTrace();
    }


try {
	DeliverSM request = new DeliverSM();
	DeliverSMResp response;
	  
            // input values
        	serviceType = ""
        	sourceAddress.setNpi((byte)1)
	sourceAddress.setTon((byte)1)
	sourceAddress.setAddress("4123601", Data.SM_ADDR_LEN)
        	destAddress.setNpi((byte)1)
	destAddress.setTon((byte)1)
	destAddress.setAddress("0022233411686", Data.SM_ADDR_LEN)
        	esmClass = 0
            registeredDelivery = 0;
            dataCoding = 0;
	
           // set values
	request.setServiceType(serviceType);
            request.setSequenceNumber(1)
	request.setSourceAddr(sourceAddress);
	request.setDestAddr(destAddress);
	request.setEsmClass(esmClass);
	request.setRegisteredDelivery(registeredDelivery);
	request.setDataCoding(dataCoding);
            request.setProtocolId(protocolId)
            request.setPriorityFlag(priorityFlag);
            request.setShortMessage("Hello world",Data.ENC_ASCII);

	// send the request
	System.out.println("Data request " + request.debugString());
	if (asynchronous) {
		session.data(request);
	} else {
		response = session.deliver(request); // here the problem , the response is always null
		System.out.println("Data response " + response.debugString());
		messageId = response.getMessageId();
	}

} catch (Exception e) {
		System.out.println("Data operation failed. " + e);
   	}
finally {
       session.unbind()
}

sending short message

I have build an application to sending short messages using smpp 3.4 and that work fine, but in some phones model like nokia 220 i got this message:

Can not display this message

in my phone.
this is my function source code :

public String sendMsg(JsonObject paramsIN) {
    String smsMessage = paramsIN.getString("body");
    String smsDestination = paramsIN.getString("to");
    String smsSource = paramsIN.getString("from");
    String smscNAME = paramsIN.getString("smsc");

    SubmitSM request = new SubmitSM();
    SubmitSMResp response;
    Session session;
    try {
        request.setSourceAddr(smsSource);
        request.setDestAddr(smsDestination);
        request.setShortMessage(smsMessage, "UTF-8");
        request.setRegisteredDelivery((byte) 3);
        request.setDataCoding((byte) 4); // 4
        request.assignSequenceNumber(true);
        response = ((Session) sd.get(smscNAME)).submit(request);
        logger.info("Submit response " + response.debugString());
        String messageId = response.getMessageId();       

        BigInteger bigInt = new BigInteger(messageId, 16);  

        return bigInt+"";
    } catch (WrongLengthOfStringException e) {
        logger.error(e);
        return null;
    } catch (PDUException e) {
        logger.error(e);
        return null;
    } catch (TimeoutException e) {
        logger.error(e);
        return null;
    } catch (WrongSessionStateException e) {
        logger.error(e);
        return null;
    } catch (IOException e) {
        logger.error(e);
        return null;
    }
}

problem with packeges

Hello
i have a problem with your library.
in some moment I stop receiving packets Enquirelink SumbitSm-resp and others in my PDU Lintener class, when i restarting app i am getting well all packages
What i do wrong?

Indian Local Language Encoding Issue

Hello,
We have been using opensmpp library for some of our applications for quite some time. We are facing a unique issue, when sending sms in unicode, sms when sent using Hindi or Telugu languages its delivering fine, but when sending using Gujarathi or Tamil the messages are garbled at the end handset.
We tried to analyse the issue and found that, when the message data is being converted to byes using .getBytes("ASCII") the specific language content is getting garbled with either ? or something else. We assume this is a encoding/charset issue, any help in this regard would be appreciated ?
Also has anyone faced or fixed issues in the lib in this regard ?
Do let us know if you need more information to be able to help us with a possible solution.
Thanks

delay in sending Session.respond

Hi All,

I've faced with the problem when sending response for DeliverSM.

There is random delay (up to the several second) between invocation Session.respond() and real sending it's' packet through the network interface.

I checked by it using network packet sniffer.

I've reviewed sources but not found any parts of code which could be a potencial reason for such strange delays.. (

Is anybody knows about any reason (and solution) for this situation ?

Thank you in advance,
Roman

Not able to run Simulator main class

Command mentioned in the javadoc of the Simulator class is

java -cp smpp.jar:smscsim.jar org.smpp.smscsim.Simulator

is not working and i also tried

java -cp D:\logica-smpp-sim-master\smscsim.jar;.;D:\logica-smpp-sim-master\smpp.jar org.smpp.smscsim.Simulator

The above command is also not working .

Kindly help me to start the simulator

SMPP v5.0

The website for opensmpp says it only supports v3.4. Is this still true, or does opensmpp now support v5.0? Thanks

Issue in sending mesage more than 255 characters

I'm using opensmpp for sending sms. But I'm not able to send sms more than 255 characters. Messages are not getting sent for more than 255 characters. can you please suggest how to use optional parameters with TLV to send the same.

How to make a long Connection

Does this open source project support long connections? How to transform without support? Anybody know?
Thank you very much!

while using opensmpp got error java.io.IOException: Not connected

we are using opensmpp as part of upgrade from Logica smpp to opensmpp and its working fine for sometime but suddenly getting the ERROR: Not connected Exception: java.io.IOException: Not connected in application logs.
After restart the application again it working fine and after sometime again same error throwing..

Can anyone help on it please ?

execute from command line

how can i execute from command line?

java -classpath ./ SMPPSender
Error: No found or load the main class SMPPSender

java.net.ConnectException: Connection time out: connect when calling bind?

I tried the simulator on 2 servers: one is mine (Debian Sid), the other is my office's (Ubuntu).
On my server, the simulator runs fine. No problem so far. But on my office's, I faces an issue when choosing bind:

1
Asynchronous/Synchronnous Session? (a/s) [s]
Transmitter/Receiver/Transciever (t/r/tr) [t]
IP address of SMSC [142.88.100.56]
Port number [2557] 2557
Your system ID [pavel]
Your password [dfsew]
Bind request (bindreq: (pdu: 0 2 0 [1]) pavel dfsew 52 (addrrang: 1 1 ) )
Bind operation failed. java.net.ConnectException: Connection timed out: connect

What do possibly cause this connection timed out issue? Both simulators use the same config. Mine runs JDK 8, my office's runs JDK 9.

Overflow not detected by GSM7Charset.Gsm7BitEncoder and GSM7Charset.Gsm7BitDecoder

When a character buffer with only basic GSM characters and a byte buffer of insufficient size is provided as argument to Gsm7BitEncoder.encode(), the return value is CoderResult.UNDERFLOW but it should be CoderResult.OVERFLOW. Vice versa, GSM7BitDecoder.decode() returns CoderResult.UNDERFLOW even though a character buffer of insufficient size is provided as argument.

Failed to execute

Failed to execute goal on project opensmpp-sim: Could not resolve dependencies for project org.opensmpp:opensmpp-sim:jar:3.0.2-SNAPSHOT: Could not find artifact org.opensmpp:opensmpp-core:jar:3.0.2-SNAPSHOT -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

TCP Zero Window on high throughput - Async mode TRX Bind with Delivery

We are sending high throughput SUBMIT_SM using OpenSMPP. But TCP ZeroWindow is received most of the times. Deliver_SM and SUBMIT_SM_RESP is getting missed. Please suggest how to resolve this.

TPS: 1000 msg/s for SUBMIT_SM and similar is on PDUListerener(DeliverSM/SUBMIT_SM_RESP)

Issue in the ByteBuffer class, in particular, methods appendCString and removeCString are using a different charset encoding.

The method appendCString adds a string as ASCII, in the time the method removeCString reads one as GSM7BIT, although it should use ASCII.

A next trouble follows from this issue: If we try to connect some EMSE using OpenSmpp to some SMSC using OpenSmpp and we use special symbols in login/password like '[]-' then login/password will be different in BindRequest and BindResponse entities.

Bind operation failed

Sorry guys but I have this issue...
Bind request (bindreq: (pdu: 0 2 0 [1]) pavel dfsew 52 (addrrang: 1 1 ) )
Bind operation failed. java.net.ConnectException: Connection refused: connect

I can't send any sms. Maybe I forget some configuration. Is there some doc to understand how to implement/set all parameters?
Thanks

I want to know the phone number of the text I sent in the handleEvent method. What should I do?

======================================================================
================================ code ==================================

private class SMPPTestPDUEventListener extends SmppObject implements ServerPDUEventListener {
public void handleEvent(ServerPDUEvent event) {
this.pdu = event.getPDU();

		if (pdu.isRequest()) {
			synchronized (requestEvents) {
				this.requestEvents.enqueue(event);
				this.requestEvents.notify();
			}
		} else if (this.pdu.isResponse()) {
			
			System.out.println("--------------------------------------------------\n=====> PDU Listener :: async response received " + this.pdu.debugString() + "\n--------------------------------------------------");
			
			System.out.println("--------------------------------------------------\n======> PDU response is True or False :: " + this.pdu.isOk() + "\n--------------------------------------------------");
			
			if(this.pdu.isOk() == false) {
				this.failSendCount++;
				this.phoneNumbers.add("1000000000");
			}
			
			this.count++;
			
			if(this.phoneNumCount == this.count) {
				// this.dbManager.addFailList("addFailPhoneNumberInfo", this.seq, phoneNumbers, this.objid);
				this.dbManager.setRowsState("setFirstLowSequenceState", this.seq, this.failSendCount, 3);
			}
		} else {
			System.out.println("PDU of unknown class (not request nor " + "response) received, discarding "
					+ this.pdu.debugString());
		}
	}

I brought a piece of my code.

if pdu.isOK() value is false ====> this.failSendCount++

And I will put the failed number in this.phoneNumbers.add("1000000000"); and store it in database

I would like to get a phone number for which texting failed.

In this.phoneNumbers.add ("1000000000") we will put the phone number that failed to transmit.

How can I get the number that failed to transfer?

Need to Receive MO SMS and set auto reply

Hello,

i am able to send SMS Successfully. but i am not receiving SMS

this is my code to receive PDU

try {
while (true) {
try {
System.out.println("SMSCSession going to receive a PDU");
pdu = session.receive(30000);
} catch (Exception e) {
System.out.println("SMSCSession caught exception receiving PDU " + e.getMessage());
}
if (pdu != null) {
timeoutCntr = 0;
if (pdu.isRequest()) {
System.out.println("SMSCSession got request " + pdu.debugString());

                } else if (pdu.isResponse()) {
                    System.out.println("SMSCSession got response " + pdu.debugString());

                } else {
                    System.out.println("SMSCSession not reqest nor response => not doing anything.");
                }
            }
        }

SMSC simulator

any docs on how to config and start the SMSC server ?!

Need proxy support

We need support for establishing an outbound connection through a proxy server.
Is there already a mechanism in place to do this that I might have overlooked? If now, I'd be happy to submit a PR

Connection Timeout Issue

Can anyone explain how does the below timeout works?

  • RECEIVER_TIMEOUT = 60000;
  • CONNECTION_RECEIVE_TIMEOUT = 10000;
  • COMMS_TIMEOUT = 2000;
  • QUEUE_TIMEOUT = 2000;
  • ACCEPT_TIMEOUT = 60000;
  • CONNECTION_TIMEOUT = 60000;

I try to make the connection expired in 6 seconds but the connection will hit more than 1 minutes for some of my transactions

Thread.yield causes high CPU load in ProcessingThread start/stop

Using the original Logica SMPP (precursor to OpenSMPP) code in an SMPP server implementation, it was observed that some threads would occasionally cause 100% CPU load for a 60 second period, when a particular SMPP client tried to connect, but failed because the bind request was deemed invalid.

This particular client seemed to not shut down the TCP session timeously, which caused a race condition that could occasionally lead to Thread.yield() being run in a tight loop in ProcessingThread, waiting for TCP socket shutdown.

During periods of high CPU load, thread dumps showed threads that persisted in this state for ~60 seconds:

   java.lang.Thread.State: RUNNABLE
        at java.lang.Thread.yield(Native Method)
        at com.logica.smpp.util.ProcessingThread.stop(ProcessingThread.java:165)
        at com.logica.smpp.Receiver.stop(Receiver.java:234)
        at <some code that tries to stop() a Receiver>

The same code still exists in OpenSMPP, and should be fixed (Thread.yield replaced with Thread.sleep) here too.

Internal issue tracker ref: TP-6228.

guide to install

I'm not familiar with java or maven, so please give me a light to start the instalation and configuration of this package.

thanks.

Window Size/TPS Throttle

Hello All,
Anyone using this library is aware how to set window size or Throttle TPS based on the Server we connect to, to ensure we send not more than the configured TPS.
Any insight is really appreciated.
Regards,
Kiran

Session closing and SMSCListener stopping

When stopping a Session or stopping an SMSCListener, an ongoing socket operation (reading, in the first case and accepting, in the second case) can delay the termination for one minute (since the socket timeout is fixed at 60s).

By closing the Connection object (connection) on Session.unbind() and (serverConn) on SMSCListener.stop(), the socket operation will unblock and they will terminate.

This will prevent the unnecessary wait on either end of the connection.

Having an issue with executing.

Hi,

correct me if I'm wrong,

but, once I've downloaded smpp files on my server and once i've configured the smppsender.cfg file, the last thing i've to do is execute smppsender.sh?

It does appear an error when I'm doing that:

Error: main class not found or loaded org.smpp.client.SMPPSender

What is wrong here?

Kind regards.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.