Skip to main content

Sending/Receiving SMS to SMPPSim

17 replies [Last post]
cryslin
Offline
Joined: 2007-11-13

Hi,

I am using SMPP RA to send and receive message from SBB to SMPPSim .
I have defined onDeliver_sm in SBB to receive message sent by SMPPSim and just print it.

I haven't changed anything in smppsim.props file.
But changed the smppra.properties file with system id and password as defined in smppsim.props as follows,

host = localhost
port = 2775
systemID = smppclient
systemType = ESME
password = password
addressTON = 0
addressNPI = 1
addressRange = 0020
enquareLinkTimeout = 300000

then started
1.mobicents
2.smppsim
3.deployed SMPP RA with the properties file

It gives error as "cannot bind to smsc"

but when started in the order
1.mobicents
2.deployed SMPP RA with the properties file
3.smppsim
and on sending message from SMPPSim MO Injection Form (http://localhost:88/inject_mo.htm) with default source address and destination address as 0020 there is no response from SBB.

Could anybody worked on this would give me a suggestion

Thanks

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
selva_eie2003
Offline
Joined: 2008-04-03

im also doing same task wat u have done..

modify the code..

here they r using 0020 specific destination address but i want to more destination nmbers then the reply from the G-talk can be go to that mobile numbers..

so help in this to do

thanks in advance
by
selva

andmus82
Offline
Joined: 2009-06-01

Have anyone modified the SMPP RA so that it' s possible to send sms in plain text?
Andrea

xuraj
Offline
Joined: 2009-08-07

Hi Guys,

I am able to bind simulator using SMPP RA but when I inject SMS with smppsim, I see that sim can not send to the server which my sbb is working.

Here is the sim logs:
WARNING 18 InboundQueue: no active receiver object to de
liver message. Application must issue BIND_RECEIVER with approriate address_range. Message has been moved to the pending queue

WARNING 18 Attempted outbind failed. Check IP address and port are correct for outbind. Exception of type java.net.ConnectException

So I set the correct ip address (mobicent server) and set 2776 for the port. Do I need to make another confıguration on the simulator or sbb to make it work? Btw sim is working on my computer.

Thanks in advance.

andmus82
Offline
Joined: 2009-06-01

Hi,
how i can modify resource-adaptor-jar.xml ? i cannot find such file.
Thanks,
Andrea

alexandrem
Offline
Joined: 2005-10-19

Inside the DU jar:

smpp-ra-DU-1.2.6.GA.jar\smpp-ra-1.2.6.GA.jar\META-INF\resource-adaptor-jar.xml

Alexandre Mendonca
JBoss R&D

andmus82
Offline
Joined: 2009-06-01

Where I can find "resource-adaptor-jar.xml" file?
Thanks,
Andrea

jfrankie
Offline
Joined: 2006-10-16

I had the chance to work alot on SMPP protocol to send and receve text and binary messages.
I used for my test a smpp sever simulator that you can find at Logica SMPP Open Source (
http://opensmpp.logica.com/).
It works fine and i didn't have any problem when i moved from the simulator to a real SMPP server.
I hope this can help you.

Francesco

cryslin
Offline
Joined: 2007-11-13

yet to be answered

andmus82
Offline
Joined: 2009-06-01

Hi, i' m using jslee 1.2.3.GA and smpp-ra-DU-1.2.3.GA. I' m usin the following code to send a sms to a sms simulator:

public void SendSms() {
Dialog dialog = smppProvider.getDialog("4477665544", "0020");
ShortMessage sms = dialog.createMessage();
sms.setOriginator("0020");
sms.setRecipient("4477665544");
sms.setText("Hello from SBB");

ClientTransaction tx = dialog.createSubmitSmTransaction();
try {
ActivityContextInterface ac = smppAcif.getActivityContextInterface(tx);
ac.attach(sbbContext.getSbbLocalObject());
} catch (FactoryException ex) {
ex.printStackTrace();
} catch (NullPointerException ex) {
ex.printStackTrace();
} catch (UnrecognizedActivityException ex) {
ex.printStackTrace();
}

try {
tx.send(sms);
} catch (IOException ex) {
ex.printStackTrace();
}
}

mySbb.sendSms() throws a java.lang.NullPointerException. The sbb sends an empty sms. Any ideas?
Thanks,
Andrea

Anonymous

Are you looking for Jobs in Java, Interact with recruiters and trainers @ eprojecthelp.com

frosters
Offline
Joined: 2007-10-30

Please look at your resource-adaptor-jar.xml to see an actual smpp parameters.
I think that smppra does not use smppra.properties - it uses resource-adaptor-jar.xml to read parameters.

Also, please check your smppsim. Does it listen localhost:2775. Check it with command like this:
telnet localhost 2775

Hope this helps.
Forester

cryslin
Offline
Joined: 2007-11-13

Thanks a lot Fosters!!!

After modifying the resource-adaptor-jar.xml with system-id and password the application successfully bound to SMSC and able to receive messages sent by the Simulator.

Now I am sending SMS to the simulator from SBB,

public void [b]onDeliver_sm[/b](net.java.slee.resource.smpp.RequestEvent event,
ActivityContextInterface aci) {
ShortMessage smsMsg = event.getMessage();
String text = smsMsg.getText();
origin = smsMsg.getOriginator();
System.out.println("Message Received is " + text);
if ((origin.equals("4477665544")))
{
SendSms();
}
}

public void [b]SendSms()[/b] {
Dialog dialog = smppProvider.getDialog("4477665544", "0020");
ShortMessage sms = dialog.createMessage();
sms.setText("Hello from SBB");

ClientTransaction tx = dialog.createSubmitSmTransaction();
try {
ActivityContextInterface ac = smppAcif.getActivityContextInterface(tx);
ac.attach(sbbContext.getSbbLocalObject());
} catch (FactoryException ex) {
ex.printStackTrace();
} catch (NullPointerException ex) {
ex.printStackTrace();
} catch (UnrecognizedActivityException ex) {
ex.printStackTrace();
}

try {
[b]tx.send(sms);[/b]
System.out.println("Sent message to " + origin);
} catch (IOException ex) {
ex.printStackTrace();
}
}

public void [b]onSubmit_sm_resp[/b](net.java.slee.resource.smpp.ResponseEvent event, ActivityContextInterface aci)
{

System.out.println("SMS message delivered: " + aci.getActivity());
}

Its given that that if loopback set to true, simulator send the short msg back to application.Shortmessage field in SMPPSim console is empty and gives the following error msg,

17:14:25,770 INFO [SmppResourceAdaptor] Source: 1:1:4477665544
17:14:25,773 INFO [SmppResourceAdaptor] Destination: 1:1:0020
17:14:25,773 INFO [SmppResourceAdaptor] ESM class : 0
17:14:25,790 INFO [SmppResourceAdaptor] Fire event: net.java.slee.resource.smpp.DELIVER_SM
17:14:25,808 INFO [STDOUT] Called setSbbContext PtinAudioConf!!!
17:14:25,816 INFO [STDOUT] Called setSbbContext PtinAudioConf!!!
17:14:25,824 INFO [STDOUT] Message Received is Hello World!!!
17:14:25,834 INFO [STDOUT] Sending message id 1
17:14:25,851 INFO [Connection] Notifying observers of packet received
17:14:25,851 INFO [STDOUT] Search tx: 1
17:14:25,851 INFO [STDOUT] Checking SmppDialogImpl id = 4477665544#0020
17:14:25,853 INFO [SmppResourceAdaptor] [b]Fire event: net.java.slee.resource.smpp.SUBMIT_SM_RESP[/b]
17:14:25,857 INFO [Connection] Notifying observers of packet received
17:14:25,857 INFO [SmppResourceAdaptor] Source: 1:1:0020
17:14:25,857 INFO [SmppResourceAdaptor] Destination: 1:1:0020
17:14:25,857 INFO [SmppResourceAdaptor] ESM class : 0
17:14:25,859 ERROR [SmppResourceAdaptor] [b]Caught an ActivityIsEndingException:[/b]
17:14:25,859 ERROR [STDERR] javax.slee.resource.ActivityIsEndingException: activity is ending/ended!
17:14:25,859 ERROR [STDERR] at org.mobicents.slee.resource.SleeEndpointImpl.getActivityContext(Unknown Source)
17:14:25,859 ERROR [STDERR] at org.mobicents.slee.resource.SleeEndpointImpl.fireEvent(Unknown Source)
17:14:25,859 ERROR [STDERR] at org.mobicents.slee.resource.smpp.ra.SmppResourceAdaptor.fireEvent(Unknown Source)
17:14:25,859 ERROR [STDERR] at org.mobicents.slee.resource.smpp.ra.SmppResourceAdaptor.packetReceived(Unknown Source)
17:14:25,859 ERROR [STDERR] at ie.omk.smpp.event.SimpleEventDispatcher.notifyObservers(Unknown Source)
17:14:25,859 ERROR [STDERR] at ie.omk.smpp.Connection.run(Unknown Source)
17:14:25,859 ERROR [STDERR] at java.lang.Thread.run(Thread.java:619)
17:14:25,861 INFO [STDOUT] Sent message to 4477665544
17:15:25,789 WARN [SmppResourceAdaptor] Could not end activity: null
17:15:25,862 WARN [SmppResourceAdaptor] Could not end activity: null

Is this the correct way of sending SMS. If not how to fire the Submit_sm event on activity context.

Thanks

frosters
Offline
Joined: 2007-10-30

Hello cryslin,

The first, you should send DELIVER_SM_RESP smpp packet after you have got DELIVER_SM from server. This can be done by invoke respond method on transaction.

Your code should be like this:

public void onDeliver_sm(net.java.slee.resource.smpp.RequestEvent event,
ActivityContextInterface aci) {
ShortMessage smsMsg = event.getMessage();
String text = smsMsg.getText();
origin = smsMsg.getOriginator();
System.out.println("Message Received is " + text);
try {
event.getTransaction().respond(Transaction.STATUS_OK);
} catch (Exception e) {
trace(Level.WARNING, "Exception during onDeliverSmEvent: ", e);
logger.error("Failed. Caused by", e);
}
...

Also in your SendSms method I think you need to set originating and destination addresses:
sms.setOriginator(smsMessage.getOriginator());
sms.setRecipient(smsMessage.getRecipient());

And about your sbb attachment:
ActivityContextInterface ac = smppAcif.getActivityContextInterface(tx);
ac.attach(sbbContext.getSbbLocalObject());

I am not sure that you really need this. It will be good if another JAIN SLEE guru can clarify us how to attach this sbb to dialog's Activity Context.

Can you please to show your sbb-jar.xml?
What the events do you have as initial? There are 2 types present:

net.java.slee.resource.smpp.DELIVER_SM
net.java.slee.resource.smpp.MESSAGE

And MESSAGE event fired automatically when you invoke
event.getTransaction().respond(Transaction.STATUS_OK);
My question is that on which AC it will be fired?

Message was edited by: frosters

cryslin
Offline
Joined: 2007-11-13

Hi,

[b]1)[/b] I tried giving "event.getTransaction().respond(Transaction.STATUS_OK)" in DELIVER_SM. "SMPP RA" fires the event [b]net.java.slee.resource.smpp.MESSAGE[/b].
But onMessage is never getting called.
[b]sbb-jar.xml : [/b]

[b]Deliver_sm[/b]

net.java.slee.resource.smpp.DELIVER_SM
net.java
3.4



[b]Message[/b]

net.java.slee.resource.smpp.MESSAGE
net.java
3.4


[b]Submit_sm_resp[/b]

net.java.slee.resource.smpp.SUBMIT_SM_RESP
net.java
3.4

[b]2) [/b] I am using the SMPPSim console to check if message is sent to simulator. Even on setting originator and recepient of short_msg as

Dialog dialog = smppProvider.getDialog("4477665544", "0020");
ShortMessage sms = dialog.createMessage();
sms.setOriginator("0020");
sms.setRecipient("4477665544");
sms.setText("Hello!!");
....

the source address and destination address are showed as that of simulator,

example :
cmd_len=64,cmd_id=4,cmd_status=0,seq_no=7,service_type=,source_addr_ton=1
source_addr_npi=1,[b]source_addr=4477665544[/b],dest_addr_ton=1,dest_addr_npi=1
[b]dest_addr=4477665544[/b],esm_class=0,protocol_ID=0,priority_flag=0
schedule_delivery_time=,validity_period=,registered_delivery_flag=0
replace_if_present_flag=0,data_coding=1,sm_default_msg_id=0,sm_length=0
short_message=,[b]tag=1060,len=7,value=0x48656C6C6F2121[/b]

[b]3) [/b] Also the short_message field is empty and value is shown as hexadecimal. Is there way of sending it as ascii to the recepient?

[b]4)[/b] After sending the SMS the SMPP server sends the Submit_sm_resp packet and onSubmit_sm_resp event handler is executed.

try {
tx.send(sms);
[b]//System.out.println("Sent message to " + origin);[/b]
} catch (IOException ex) {
ex.printStackTrace();
}
But if there is a statement after tx.send(sms) the [b]onSubmit_sm_resp[/b] is not getting called. I think, this statement sends the Submit_sm packet to server and server also generates Submit_sm_resp, but coming back to this calling method prevents the onSubmit_sm_resp from being executed.

[b]5) [/b] Sometimes all the events do not come in sequence when seen in the mobicents console and gives the error
[b][SmppResourceAdaptor] Unknown activity tx =2[/b]
[b][SmppResourceAdaptor] Could not end activity: null[/b]

Do anyone know how to handle these issues,

Expecting ur reply.

frosters
Offline
Joined: 2007-10-30

Hello cryslin!

Let's answer in order your questions are:

1. I think that onMessage not invoked at SBB because root SBB not subscribed to receive it. IMHO it should be done by code (in your onDeliverSM method).
It is need to look at examples to understand how to do it.

2. Yes, there is a bug in SMPPRA :) AFAIR I found it before, - look for RA sources to fix it, or checkout last smppra version from CVS. I hope it is already fixed.

3. You are right. By default it sends as PAYLOAD DATA (not plain text). To send it as text you need to modify ra sources.

4. Events executions are asynchronus. So, I don't know why it depends on currently running code... Please let me know if you will found an explanation for this case.

5. It is also bug in SMPPRA. I was open a thread in forum with subject 'SMPP bug' - try to search forum, you will find an explanation. In short words, there are incorrect transaction_id comparation method used ( '==' instead of 'equals' for String id).

That's all :)

Good luck!

cryslin
Offline
Joined: 2007-11-13

Hi,
Thank you for all your replies.

One more question,

I have downloaded the RA code from https://mobicents.dev.java.net/source/browse/mobicents/ra/smppra/.
I would like to modify and compile the source code and create the deployment jar files.The existing build.xml file in this folder doesn't seems to work.

Do I need to create a build.xml of my own to compile the source code or any other procedure is there.

Thanks

frosters
Offline
Joined: 2007-10-30

Hello cryslin.

Probably, you need to review current build.xml to fix some path variables, or write your custom build.xml.
But the first way is more clear, I guess.