SMS routing based on destination number string match

SMS routing based on destination number string match SearchSearch

SMS & MMS Technical Forum » NowSMS Support - SMS Issues (Product Support Only) » Archive through November 14, 2013 » SMS routing based on destination number string match « Previous || Next »
Author Message
Globe
New member
Username: Globeuser

Post Number: 1
Registered: 04-2013
Posted on Tuesday, April 09, 2013 - 02:45 pm:   

We have a requirement to route SMS to a destination numbers based on string match coming from our SMSC to NowSMS to route it back to our SMSC. I am hoping this is supported on NowSMS and you could assist us in getting this done.

If NowSMS cannot route the SMS back to the originating SMSC, as a last resort we would also like to consider routing to a different SMSC, but this is least favourable to us on our network.

I shall look forward to hear from you soon on this as this is high priority.
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 4372
Registered: 08-2008
Posted on Tuesday, April 09, 2013 - 04:15 pm:   

Hi,

If you could explain more about what you're trying to accomplish with some examples, I should be able to explain in more detail.

But, basically, yes, what you are describing is possible.

The exact setup depends somewhat on details, such as:

Who initiates the connection?

Are messages are routed back over the same connection or a different connection ?

What routing is to be done for non-matching messages?

What type of string match filtering do you need? (simple pattern match can be configured in settings, more complicated pattern matching can be implemented through HTTP callbacks)

Are there requirements to modify source or destination addresses? (There are some simple conversions that can be done in settings, more complicated translations are implemented through HTTP callbacks.)

So the short answer is that it is possible. The longer answer is that you might need to provide some HTTP scripts (PHP or other scripting language) that provides more detailed routing instruction. An explanation of how these callbacks work can be found here: http://www.nowsms.com/dynamic-sms-message-routing-with-http-callbacks

If you can provide some more detailed examples of what you're trying to accomplish, I can provide some more specific guidance.

--
Des
NowSMS Support
Globe
New member
Username: Globeuser

Post Number: 2
Registered: 04-2013
Posted on Wednesday, April 10, 2013 - 09:24 am:   

Who initiates the connection?
NowSMS intiates the connection to our SMSC


Are messages are routed back over the same connection or a different connection ?
Yes, routed back on the same connection

What routing is to be done for non-matching messages?
Non matching SMS should be forwarded on to our peer terminating party

Having said that, we have another NowSMS to simulate our terminating party.


What type of string match filtering do you need? (simple pattern match can be configured in settings, more complicated pattern matching can be implemented through HTTP callbacks)
Yes, its simple match on different ranges of MSISDNs.


Are there requirements to modify source or destination addresses? (There are some simple conversions that can be done in settings, more complicated translations are implemented through HTTP callbacks.)
There is no requirement to modify source or destination address, hence I hope we wont be needing any scripts for this.

Could you please provide us a step by step procedure to configure this please?
This is a high priority requirement.
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 4377
Registered: 08-2008
Posted on Wednesday, April 10, 2013 - 01:13 pm:   

Ok.

Things can get a little confusing depending on the direction of the connection ... not just for NowSMS, but also for the SMSCs to which you connect.

I'm assuming that you are connecting with the SMPP protocol.

SMPP imposes a client-server model which is at the core of where things get confusing. There is a lengthy discussion and illustration of these issues in the write-up at http://www.nowsms.com/sms-hubbing-considerations

However, I'll try to keep it simple.

If NowSMS initiates the connection, NowSMS is the client and the SMSC is the server.

If NowSMS receives a message from such an SMSC connection, in SMPP speak this is a deliver message ... I'll call it an inbound message from NowSMS perspective.

NowSMS expects to route inbound messages to the 2-way command processor, or to a local SMPP client account (defined under "SMS Users").

If you want to treat such messages as outbound messages and send them out via an SMSC connection, then you need to set an attribute on the connection through which the message was received to tell NowSMS that this is what you want to do.

This is done by editing SMSGW.INI and under the appropriate section header for the connection delivering the inbound messages (e.g., [SMPP - server:port]), add ReRouteReceived=Yes

Or in the brand new release of NowSMS (download at http://www.nowsms.com/download/nowsms20130401.zip), this setting can be configured via the advanced settings for an SMPP connection where it is labeled "Re-Route Received Messages for Outbound Delivery".

NowSMS then treats inbound messages from this connection like any other outbound message. If you can route messages using prefix routing, define the prefixes in the "Preferred Connection for" list for the SMSC connection.

Standard outbound routing considerations are explained here: http://www.nowsms.com/routing-sms-messages-to-a-specifc-smsc-route

And if prefix based routing is not sufficient, an explanation of how to use dynamic routing callbacks can be found here: http://www.nowsms.com/dynamic-sms-message-routing-with-http-callbacks

Overall, your setup is quite straight-forward, the only "trick" is the ReRouteReceived setting for flipping inbound messages back to outbound.

The only problem I'd expect is delivery receipt handling. Because the SMSC uses SMPP deliver_sm format to deliver the message to NowSMS (because NowSMS initiates the connection), the message ID tracking chain is broken. The handling of delivery receipts in this type of configuration is very complex and an attempt to explain it can be found at http://www.nowsms.com/sms-hubbing-considerations. (Short explanation, either both NowSMS and the SMSC must each initiate a connection so there are two connections, or both NowSMS and the SMSC must know this is a hub type of connection and be configured to use data_sm instead of submit_sm and deliver_sm.)

Let me know if you require further clarification.

--
Des
NowSMS Support
Globe
New member
Username: Globeuser

Post Number: 3
Registered: 04-2013
Posted on Wednesday, April 10, 2013 - 02:34 pm:   

Thanks Des,

I have tried what you provided.

Set the SMSGW.INI file with ReRouteReceived=Yes for our SMSC and added a string of MSISDN (eg : +14552*) under 'preferred SMS Connection for'.

Also, I disabled route SMS to Local user under receive SMS messages (tried enabling this too).

My MOSMS from SMC to NowSMS is being forwarded to terminating NowSMS instead of rouing it back to SMSC.

I could see only DeliverSM on the tcpdump. I would expect a submitSM from NowSMS back to SMSC.

Could you please advise?
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 4380
Registered: 08-2008
Posted on Wednesday, April 10, 2013 - 02:47 pm:   


quote:

My MOSMS from SMC to NowSMS is being forwarded to terminating NowSMS instead of rouing it back to SMSC.




I'm not sure I understand what you mean by terminating NowSMS.

Is this another NowSMS server? Or do you mean the message is terminating at this NowSMS?

I am assuming that it means another NowSMS server ... in which case, what if you use the web interface of NowSMS to submit a message to that same number? Does it follow the same path?

If it follows the same path, something is not right with the "Preferred SMSC Connection for" list. Did you press Apply (or OK) from the SMSC list after adding that setting? It can be confusing, but SMSC configuration changes don't get saved until you OK or Apply from the SMSC list.

If the web submission follows a different path, then doublecheck the number as it appears in SMSIN and SMSOUT logs to make sure it is in the expected format. (Maybe + is missing?)

If you mean that the message is terminating at the first NowSMS, try ReRouteReceived=Any instead of Yes (initially when this setting was added, it was Any, not Yes ... not knowing what version you are running I should have said Any). Also double-check spelling of this setting and verify it is under the [SMPP - server:port] section header from which the message is being received ... and verify there is only one such section header.

--
Des
NowSMS Support
Globe
New member
Username: Globeuser

Post Number: 4
Registered: 04-2013
Posted on Wednesday, April 10, 2013 - 02:59 pm:   

Hi Des,

yes, I meant that was another NowSMS simulating our terminating partner.
Just clicking the OK button, doesn't apply changes. We have to click on Apply everytime and then OK.
Thanks for your support!

Anyway, this brings us to our next question.
What is the capacity of the strings we can match under "Preferred SMSC Connection for" ?
Can we know the limit please?
Globe
New member
Username: Globeuser

Post Number: 5
Registered: 04-2013
Posted on Wednesday, April 10, 2013 - 03:29 pm:   

Hi Des,

I have tested with the changes you advised and found the string match routing is working, all SMS matching the string is routed back to the SMSC.

Although, SMS to non matching MSISDNs too are being routed back to SMSC. I would expect them to be forwarded on to the NowSMS (terminating party).

I tried disabling reroute on SMSGW.INI and all messages are forwarded onward.

Could you please provide some insight into this scenario?.
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 4381
Registered: 08-2008
Posted on Wednesday, April 10, 2013 - 03:45 pm:   

Hi,

The Apply/OK issue is confusing. When I said Apply or OK, I was referring to those buttons on the SMSC list page, not when editing an SMSC entry. Bottom line ... look for Apply being enabled, if it is, changes are pending. If the Apply button is disabled, no changes are pending.

For the routing issue, is "Support any outbound message traffic" checked on the connection to your SMSC?

If checked, it basically means the connection can be used as a default route. First NowSMS evaluates all "Preferred SMSC Connection For" lists, then if no match is found, any routes with this setting enabled can be used.

You want that setting checked for your SMSC so that only matching entries are routed there.

There is no defined limit on the number of entries in the preferred list. Additional memory is allocated to accomodate the entries as needed. However, there becomes a practical limit of manageability in the configuration program...a point at which it becomes too awkward to manage a lot of entries in that small dialog window (or an extreme point where there are too many entries for a Windows dialog box). If you have more complex requirements where it becomes too awkward or you need to evaluate against an external database to determine routing, you would write a script and use the HTTP callback interface.

--
Des
NowSMS Support
Globe
New member
Username: Globeuser

Post Number: 6
Registered: 04-2013
Posted on Wednesday, April 10, 2013 - 04:02 pm:   

Hi Des,

Yes, "Support any outbound message traffic" was checked.

from your statement, you say
if no match is found, any routes with this setting enabled can be used.

what setting are you referring to?

I have added one string only and an sms user under preferred smsc connection.

So, I assume if string doesnt match, it should route to the sms user which is connected to terminating Nowsms.

Also, I see receive sms check box and route sms to local user below that.
What does this do? if I add the sms user of terminating Nowsms?
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 4382
Registered: 08-2008
Posted on Wednesday, April 10, 2013 - 04:26 pm:   

This statement will hopefully clarify:

If "Support any outbound message traffic" is checked, it basically means the connection can be used as a default route. First NowSMS evaluates all "Preferred SMSC Connection For" lists for all defined SMSCs looking for a recipient address match. If no match is found, any routes with this "Support any outbound message traffic" enabled can be used.


quote:

I have added one string only and an sms user under preferred smsc connection.

So, I assume if string doesnt match, it should route to the sms user which is connected to terminating Nowsms.




No.

"Preferred SMSC Connection for" is basically a list of phone numbers or phone number patterns. User accounts should not be listed here.


quote:

Also, I see receive sms check box and route sms to local user below that.




"Receive SMS Messages" should be checked because you want to receive messages from this SMSC connection.

"Route SMS to local user" is an option for how to process SMS messages from this SMSC connection. You do NOT want to use this option because you want to route some of the messages back to your SMSC. (The ReRouteReceived setting probably takes precedence over this setting, causing it to be ignored if you did configure it. Basically this "Route SMS to local user" setting is mutually exclusive with ReRouteReceived.)


quote:

What does this do? if I add the sms user of terminating Nowsms?




Do not define an SMS User account. At least not on the NowSMS connected to your SMSC.

On the terminating NowSMS, define an "SMS User" account, and enable the SMPP server. (See http://www.nowsms.com/using-nowsms-as-an-smpp-server-for-another-application)

On the NowSMS connected to your SMSC, define an SMSC connection pointing to the terminating NowSMS. "Support any outbound message traffic" should be enabled for this connection, making it a default route.

--
Des
NowSMS Support
Globe
New member
Username: Globeuser

Post Number: 7
Registered: 04-2013
Posted on Wednesday, April 10, 2013 - 05:09 pm:   

So, if ReRouteReceived is enabled and no string match added under Preferred SMS connection for, all SMS will rerouted back to SMSC.. correct ?

Also, from your last comment.. we will have 2 SMSC configured on the NOwSMS connecting the SMSC.
Can we have both SMSC connections active at the same time?

One to the SMSC
Two to the terminating NowSMS.
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 4383
Registered: 08-2008
Posted on Wednesday, April 10, 2013 - 05:28 pm:   


quote:

So, if ReRouteReceived is enabled and no string match added under Preferred SMS connection for, all SMS will rerouted back to SMSC.. correct ?




Not quite.

The SMSC connection is both sending and receiving messages.

You have to separate these two activities in your thought process.

ReRouteReceived applies to messages that NowSMS receives from that SMSC connection. It says that we are changing the direction of the message to send it back out. It does not specify the outbound route to be used to send the message out.

To determine the route to be used to send a message out (regardless of where it was received from), NowSMS evaluates all "Preferred SMSC Connection For" lists for all defined SMSCs looking for a recipient address match. If no match is found, any routes with "Support any outbound message traffic" enabled can be used.


quote:

Also, from your last comment.. we will have 2 SMSC configured on the NOwSMS connecting the SMSC.
Can we have both SMSC connections active at the same time?

One to the SMSC
Two to the terminating NowSMS.




That is fine. If you have other SMSC connections to define, you can add more.


--
Des
NowSMS Support
Globe
New member
Username: Globeuser

Post Number: 8
Registered: 04-2013
Posted on Wednesday, April 10, 2013 - 06:06 pm:   

Hello Des,

Thanks for your help, but Im afraid this might not work for us when we go live, as our terminating partner is an ESME and cannot be a server or SMSC.

Could you please advise?
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 4384
Registered: 08-2008
Posted on Wednesday, April 10, 2013 - 07:03 pm:   

Routing to an ESME in this scenario is possible. However, it does require the use of an HTTP callback.

Here's an example...

Let's say the route name for your SMSC is named BackToSMSC in NowSMS.

And that your partner has a user account on NowSMS named PartnerESME that they use to connect to your system.

The following PHP script will route numbers that start with +14552 back to your SMSC, and other messages to the ESME.

It is easily extensible for other prefixes or additional logic.

<?php
header ("Content-Type: text/plain");

// Set default response to generic text OK
$response = "OK";

if (isset($_REQUEST['Type'])) {
if ($_REQUEST['Type'] == "SMSSend") {
// SMS routing callback, set response for default route to partner ESME
$response = "SMSCRoute=localuser:PartnerESME";
if (isset($_REQUEST['To'])) {
$to = $_REQUEST['To'];
if (!strncmp ($to, "+14552", 6)) {
$response = "SMSCRoute=BackToSMSC";
}
}
}
}

echo $response;

?>

As the formatting is messed up above, I'll also attach it as a text file.

text/plainrouteme.php
routeme-php.txt (0.5 k)


You save this as a PHP file on a web server. Let's say it is called routeme.php.

Edit SMSGW.INI and under the [SMSGW] header add:

SMSAccountingURL=http://server/routeme.php

This script now takes over outbound routing logic instead of using the "preferred connection for" list in NowSMS. (You still need the ReRouteReceived setting.)

If you don't have easy access to a web server that you can place a PHP script on, it is possible to install PHP so that NowSMS can run PHP scripts directly: http://www.nowsms.com/now-sms-native-php-scripts

(If you install PHP for NowSMS to use directly, it's a good idea to reboot after installing PHP so that it's environment is properly enabled for services.)

--
Des
NowSMS Support
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 4385
Registered: 08-2008
Posted on Wednesday, April 10, 2013 - 07:40 pm:   

P.S. - When you define the PartnerESME account in NowSMS, be sure to enable the "Accept Messages" setting as this enables messages to be queued to that account.
Globe
New member
Username: Globeuser

Post Number: 9
Registered: 04-2013
Posted on Thursday, April 11, 2013 - 09:13 am:   

Hello Des,

I am trying to install PHP following instructions from your link on my machine and now trying to install pear, PEAR Mail Package and PEAR Net_SMTP Package.

When I try the following commands,

go-pear
pear install Mail
pear install Net_SMTP

I get not recognized as as an internal or external command,
operable program or batch file.

Could you please advise?
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 4386
Registered: 08-2008
Posted on Thursday, April 11, 2013 - 10:04 am:   

Hi,

Hmm .... go-pear.bat is a batch file

If you install a version of PHP through an installer version (5.3.24), it is present.

But I did not see it present in a ZIP download of PHP, and the 5.4.x version does not have an installer version.

That said, NowSMS does not require the pear modules to be installed (we just have some examples that use it). But the installer does set some environmental variables that we use to locate the PHP install.

So I would recommend using 5.3.24 installer version of PHP.

I just tried a fresh install and it is working fine (odd pop-up syntax error installing one of the pear modules, but it did install).

After the PHP and pear install, when you try to enable the PHP integration, NowSMS will complain that it cannot locate PHP, but a reboot will ensure that environmental variables set by the PHP installer are properly initialised.

--
Des
NowSMS Support
Globe
New member
Username: Globeuser

Post Number: 10
Registered: 04-2013
Posted on Thursday, April 11, 2013 - 12:52 pm:   

Hi,

I have followed your procedure and still all SMS are sent back to the SMSC. Doesn't look like the string match is working yet.

could you clarify a few things here?

1. What should the php script be named for NowSMS to identify, placed under /c/programfiles/nowsms/php/?
2. I have only updated the SMSC connection name and the ESME user name in your script. Am I missing anything else?
3. I have checked Support outbound messages trafic and left preferred SMSC connection blank on SMSC.
4. Checked Accept received messages for this user on SMS user for ESME and left recipient address to route to this user as blank.
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 4387
Registered: 08-2008
Posted on Thursday, April 11, 2013 - 01:13 pm:   

Hello again,

We're getting there. (As a side note, I have asked our engineering team to implement a way to address your scenario without having to implement a routing callback. But that will take some time ... and once you get past the initial setup issues ... routing callbacks are more flexible and easier to modify.)

The name can be whatever you want. You tell NowSMS in the SMSAccountingURL setting. (See note about this in earlier message, right below the example script. But since you are installing PHP locally I will clarify further.)

Let's say that it is called routeme.php

Edit SMSGW.INI and under the [SMSGW] header add:

SMSAccountingURL=http://nowsmslocal/php/routeme.php

As a sanity check, open a browser window on that machine and open http://127.0.0.1:8800/php/routeme.php ... you should see an OK response indicating the PHP script is running correctly.

If you do not see the OK response, restart the NowSMS service and try again. Most settings are loaded dynamically when you change them, but when you first enable PHP support, it does require a service restart to initialise the PHP engine.

--
Des
NowSMS Support
Globe
New member
Username: Globeuser

Post Number: 11
Registered: 04-2013
Posted on Thursday, April 11, 2013 - 01:33 pm:   

Hi,

yeah, I thought that SMSGFW.INI update was only if php script is on a different webserver.

Anyway, Im afraid this doesnt work either,verified the config on SMSGW.INI file and tried restarting NOwSMS many times. I still do not see OK response on the browser....

Also, I saw on one of your urls about configuring 2-way SMS command with the php script path but i guess thats not relevant to this scenario.

Thanks
Pavan
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 4388
Registered: 08-2008
Posted on Thursday, April 11, 2013 - 01:47 pm:   

Hi Pavan,

Ok ... the fact that you are not seeing an OK response in the browser suggests the local PHP support is not loading.

Let's enable the SMSDEBUG.LOG, and then I'm going to have you repeat the test and send me some files to look at.

Edit SMSGW.INI and under the [SMSGW] header add Debug=Yes

Restart the NowSMS service. (So that we have a clean debug log.)

Open the NowSMS web interface from a web browser on the same machine (http://127.0.0.1:8800 unless the default settings have changed).

Verify that routeme.php exists in a directory named PHP directly under where SMSGW.INI is located. (Some versions of NowSMS use ProgramData\NowSMS instead of Program Files\NowSMS). The 2-way configuration page will tell you the directory location.

Assuming the web interface works properly and the PHP directory with routeme.php has been verified, request http://127.0.0.1:8800/php/routeme.php from the browser.

If you still don't see OK, collect SMSDEBUG.LOG and SMSGW.INI and e-mail them to nowsms@nowsms.com. Put Attention: Des in the subject line and post a quick reply here so that I can check for those files.

--
Des
NowSMS Support
Globe
New member
Username: Globeuser

Post Number: 12
Registered: 04-2013
Posted on Thursday, April 11, 2013 - 01:58 pm:   

Hi Des,

This still didnt work, I have mailed you the debug log and ini file.
Globe
New member
Username: Globeuser

Post Number: 13
Registered: 04-2013
Posted on Thursday, April 11, 2013 - 03:17 pm:   

Hi Des,

Got the sanity test working, but still non matching string not being forwarded. They are all routed back to SMSC.

I have now cleared the duplicate INI files and updated the latest NowSMS configuration.

Could you please advise why the non matching MSISDNs are forwarded to ESME.
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 4389
Registered: 08-2008
Posted on Thursday, April 11, 2013 - 03:23 pm:   

Hi Pavan,

I'd need to see an SMSDEBUG.LOG to verify that the accounting callback is being called and is returning the expected responses.

(Make sure it is configured: SMSAccountingURL=http://nowsmslocal/php/routeme.php)

The SMSDEBUG.LOG should show this callback being called as each message is processed, and it should also show the response from the callback, such as SMSCRoute=BackToSMSC

--
Des
NowSMS Support
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 4390
Registered: 08-2008
Posted on Thursday, April 11, 2013 - 06:13 pm:   

Hi Pavan,

I just did a fresh install on a new system to simulate your configuration.

Everything worked as expected, however I did experience one unexpected issue.

When I was submitting test messages from the web interface, the callbacks were not querying the route. (It did work for messages received from an SMSC connection that were processed via ReRouteReceived.)

There is an issue that if authentication is NOT required for the web interface (meaning you are not prompted for a login), then this callback does not occur. Check the setting "Require authentication for web interface" and it will work as expected.

--
Des
NowSMS Support
Globe
New member
Username: Globeuser

Post Number: 14
Registered: 04-2013
Posted on Friday, April 12, 2013 - 11:41 am:   

Hi Des,

I have tried the above and verified all configurations on NowSMS but still SMS is not being routed back to the SMSC. Both matching and non matching strings are being forwarded to the ESME. I have mailed you the debuglogs, could you please review and let me know about any changes needed?
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 4393
Registered: 08-2008
Posted on Friday, April 12, 2013 - 11:44 am:   

Hi Pavan,

As I mentioned in my e-mail...

The message coming in from the ESME is addressed to 141552xxxxx, not +141552xxxxx. Therefore it does not match the prefix routing in the PHP file.

There are different ways to handle this … either edit the PHP file to test for that prefix without the +, or apply prefix conversions to fix it and add the + automatically. Prefix conversions are described here: http://www.nowsms.com/international-prefix-conversion-for-sms

The short solution is to edit SMSGW.INI and under the [SMSGW] header add:

GlobalSenderPrefixConvert=141552:+141552


I also notice that your earlier messages indicated that the prefix you were trying to handle was +14552, yet the prefix here is +141552, so this particular number wouldn't match even with the + added.

So you need to add the GlobalSenderPrefixConvert setting, and fix the PHP file like this:

if (!strncmp ($to, "+141552", 7)) {
$response = "SMSCRoute=qa-smsc-rte";
}

If you need to add other prefixes to the routing file, just add more if conditions. If you are not familiar with PHP, the strncmp function is just comparing the first n characters of the string for a match. (See http://php.net/manual/en/function.strncmp.php)

I do notice one other potential issue. You seem to be applying a sender address conversion to messages received from the ESME so that the sender address is changed to zynetixtx. Maybe you mean to do that. If you do not mean to, this is happening because you have a "Forced Sender Address" associated with the account in NowSMS … that setting changes the sender address.

--
Des
NowSMS Support
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 4395
Registered: 08-2008
Posted on Friday, April 12, 2013 - 12:08 pm:   

Follow-up ... ignore my last paragraph. There is no "Forced Sender Address" potential issue.

Also, if you want to ensure that no messages from the ESME are routed back to the ESME, change the PHP logic to be like this:

// default route to ESME
$response = "SMSCRoute=localuser:zynetixtx";
// If from ESME, default route to SMSC
if (isset($_REQUEST['From'])) {
   $from = $_REQUEST['From'];
   if (!strcmp ($from, "zynetixtx")) {
      $response = "SMSCRoute=qa-smsc-rte";
   }
}
if (isset($_REQUEST['To'])) {
   $to = $_REQUEST['To'];
   if (!strncmp ($to, "+14552", 6)) {
      $response = "SMSCRoute=qa-smsc-rte";
   }
}

Formatting is a little funny ... but you get the idea ... there is a test to see if the message is from the ESME account and if it is, the default route becomes the SMSC.

--
Des
NowSMS Support
Globe
New member
Username: Globeuser

Post Number: 15
Registered: 04-2013
Posted on Tuesday, April 16, 2013 - 01:33 pm:   

Hello Des,

What's the capacity of the SMSDEBUG,log?
Once this goes live, we will have loads of logs and would like to know if there is log rotation which could be configured? or how this will be handled?
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 4403
Registered: 08-2008
Posted on Tuesday, April 16, 2013 - 02:38 pm:   

Hi Pavan,

By default it rolls over to a new log at any of the following conditions:

Date changes
Service restarted
Size exceeds 512MB

When this happens, LOG becomes BAK. Previous BAK deleted.

We generally recommend turning it off unless troubleshooting. It's no harm if you want to leave it over and monitor for a bit. (I'd suggest monitoring the SMSOUT logs to make sure destinations look good ... and then look at debug only if questions/issues.)

--
Des
NowSMS Support
Globe
New member
Username: Globeuser

Post Number: 16
Registered: 04-2013
Posted on Tuesday, April 16, 2013 - 02:43 pm:   

Thanks Des,

Another question..

Now that you know our requirement and what I have configured here, I had checked 'process received message' under 2-way tab.
tried unchecking this and all looked to be working the same way.

Can you explain if that makes any difference or its implications, just to avoid any surprises when it goes live.
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 4404
Registered: 08-2008
Posted on Tuesday, April 16, 2013 - 03:34 pm:   

I would leave "Process received messages" checked.

But leave the 2-way command list blank.

I don't expect it to have any effect on your installation.

I just know that there have been past issues where UNchecking this setting caused some messages getting routed to a local user account to get stuck in the queue until the setting was enabled.

If memory serves me correctly, it had something to do with HTTP submissions to a local user account. Similar to what you are doing with your routing callback having the messages routed to an ESME, but different enough that I don't believe this would effect you.

There's no downside to having it enabled. So I'd probably err on the side of caution and enable it.

All it does is scan the SMS-IN directory for message files. You shouldn't have any, so it won't be doing any work.

--
Des
NowSMS Support
Globe
New member
Username: Globeuser

Post Number: 17
Registered: 04-2013
Posted on Monday, June 03, 2013 - 11:39 am:   

HI Des,

We are now in the process of setting up the same requirement on a different server and unfortunatley after following the same procedure, the SMS is not routed / forwarded on to ESME as expected.

I could see response ok when I tried to initiate php script on http as you advised earlier to verify.
Could you please advise if there is anything else to get this working?
Your earliest reply would be much appreciated.
Globe
New member
Username: Globeuser

Post Number: 18
Registered: 04-2013
Posted on Monday, June 03, 2013 - 12:40 pm:   

Hi Des,

Please find the smsdebug logs, could you please advise?


12:52:10:144 [18] InitPHPWorker: PHP FastCGI Support will attempt to use 127.0.0.1:3513
12:52:10:582 [18] InitPHPWorker: PHP FastCGI Support initialised on 127.0.0.1:3513
12:52:10:613 [18] ProcessPHPRequest: Got FCGI_END_REQUEST
12:52:10:613 [18] ProcessPHPRequest: HTTP/1.1 200 OK
Connection: Keep-Alive
Content-Length: 16
X-Powered-By: PHP/5.3.25
Content-Type: text/plain


12:52:10:613 [18] ProcessPHPRequest: .Response is OK
12:52:21:160 [18] ProcessRead: End of socket
12:52:21:160 [18] WaitForSocketClose: WinSock reported ioctlsocket complete
12:52:21:160 [18] ThreadProcessConnection: Request processing complete
12:57:06:769 [0] UseRouteCache: Yes
12:59:05:879 [16] SMPPReceiveMessageCallback: inbound message: sender=+16517605259, recip=+21324568912, pid=0, dcs=0, msgFlags=0, udh=, msg=
12:59:05:894 [16] ReRouteReceived: C:\PROGRA~1\NowSMS\Q\51A77996.req
12:59:05:894 [16] MessageRoutesAdd: 51A77996.req
12:59:05:894 [16] MessageRoutesAdd: SMPP - 192.168.151.164:2775
12:59:06:894 [16] ThreadProcessModem: Processing 51A77996.req...
12:59:42:066 [16] SMPPReceiveMessageCallback: inbound message: sender=+16517605259, recip=+21324568912, pid=0, dcs=0, msgFlags=0, udh=, msg=
12:59:42:066 [16] ReRouteReceived: C:\PROGRA~1\NowSMS\Q\51A77997.req
12:59:42:066 [16] MessageRoutesAdd: 51A77997.req
12:59:42:066 [16] MessageRoutesAdd: SMPP - 192.168.151.164:2775
12:59:43:066 [16] ThreadProcessModem: Processing 51A77997.req...
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 4514
Registered: 08-2008
Posted on Monday, June 03, 2013 - 12:48 pm:   

Hi,

The script appears to be returning the following literal text:

.Response is OK

In other words, NowSMS is not generating that text, the PHP script is.

The script needs to return a response that includes routing information, such as:

SMSCRoute=qa-smsc-rte

NowSMS is looking for the text "SMSCRoute=" in the response, followed by a valid route name (or localuser:account if routing to an ESME).

--
Des
NowSMS Support
Globe
New member
Username: Globeuser

Post Number: 19
Registered: 04-2013
Posted on Monday, June 03, 2013 - 12:52 pm:   

Thanks Des,

Could you then advise what can I do to update this ?

I have provided SMS name under sms user (accept received messages for this user)

Anything to change on the script?
Globe
New member
Username: Globeuser

Post Number: 20
Registered: 04-2013
Posted on Monday, June 03, 2013 - 01:12 pm:   

I have verified all the configs are the same as the already working system, but this new system is facing the problem. I dont know what could have changed and how to fix this. Please advise the steps to fix this.
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 4515
Registered: 08-2008
Posted on Monday, June 03, 2013 - 01:14 pm:   

I don't have enough information.

I do have a script that you sent me from April 15. And it does suggest that if the script returns "Response is OK", then this means that none of the if conditional statements were a match.

I'd suggest adding more echo debug statements to the script to determine why your expected if condition is not being met.


--
Des
NowSMS Support
Globe
New member
Username: Globeuser

Post Number: 21
Registered: 04-2013
Posted on Monday, June 03, 2013 - 01:22 pm:   

Hi Des,
I do have echo statements already adn dont see them on debug logs. Please find my script below and advise....
header ("Content-Type: text/plain");
// Set default response to generic text OK
$response = "OK";
if (isset($_REQUEST['Type'])) {
if ($_REQUEST['Type'] == "SMSSend") {
// SMS routing callback, set response for default route to Syniverse
// $response = "SMSCRoute=localuser:zynetixrx";
if (isset($_REQUEST['To']) && isset($_REQUEST['From'])) {
$to = $_REQUEST['To'];
$from = $_REQUEST['From'];
echo "Destination address - $to ";
echo "Originating address - $from ";
if ($from == "zynetixtx") {
$response = "SMSCRoute=lpl-smsc-rte";
}
else {
if ((!strncmp ($to, "+12253083", 9)) || (!strncmp ($to, "+15183", 6)) || (!strncmp ($to, "+141552", 6))
|| (!strncmp ($to, "19292237", 8))
|| (!strncmp ($to, "+13344403", 8))) {
echo " Response for GM MSISDN match ";
$response = "SMSCRoute=lpl-smsc-rte";
}
else {
echo "Response for no match of GM MSISDN";
$response = "SMSCRoute=localuser:zynetixrx";
}
}
}
}
}
echo "Response is $response ";
?>
Globe
New member
Username: Globeuser

Post Number: 22
Registered: 04-2013
Posted on Monday, June 03, 2013 - 01:41 pm:   

This is the same script which is working fine on a different machine setup, not sure if its some config issue on the NOwSMS as even thats the same.
Please advise a solution.
Globe
New member
Username: Globeuser

Post Number: 23
Registered: 04-2013
Posted on Monday, June 03, 2013 - 03:45 pm:   

Hi Des,

I have tried to re install and start configuring from scratch. Unfortunately, I cant even get response ok for the php script now.
ANy ideaS?
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 4516
Registered: 08-2008
Posted on Monday, June 03, 2013 - 03:45 pm:   

The SMSDEBUG.LOG excerpt above does not show the actual accounting callback request, only the response.

For all I know, that might be an SMSOut callback. In which case the PHP script response would be expected.

There appears to be no callback occurring for the inbound message which appears to be getting rerouted back to the same connection from which it was received? From this limited amount of information, I don't know what is happening or what should happen.

You say this is a different machine from the one that is working. Are they both running the same version of NowSMS?

Overall, I need a lot more information.

I'd suggest you e-mail a more complete SMSDEBUG.LOG and SMSGW.INI ... and go ahead and also include the PHP file as it is hard to read with missing indenting in this forum. Also, please explain what did not happen as expected referencing one or more messages referenced in the SMSDEBUG.LOG. I need to know what was expected to happen that did not happen.

You can e-mail those files to nowsms@nowsms.com. Please put Attention: Des in the subject line.

--
Des
NowSMS Support
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 4517
Registered: 08-2008
Posted on Monday, June 03, 2013 - 04:24 pm:   

The current problem is that the routeme.php file appears to be missing (perhaps deleted when you uninstalled/reinstalled?). Or maybe the PHP install cannot be located.


Make sure PHP support is loaded in NowSMS and that the PHP file is located in the referenced directory.
Globe
New member
Username: Globeuser

Post Number: 24
Registered: 04-2013
Posted on Monday, June 03, 2013 - 05:32 pm:   

Hi Des,

The routeme script is placed under NowSMS/php and local php processing is enabled. still no luck..

I guess there is some config on NowSMS to initiate the php script. Any more ideas?
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 4520
Registered: 08-2008
Posted on Monday, June 03, 2013 - 05:58 pm:   

Hi Pavan,

I double checked the error that you are seeing.

It says:

ERROR: File not found
C:\PROGRA~1\NowSMS\PHP\routeme.php

I assume PROGRA~1 is the short name directory for Program Files.

What directory is SMSGW.INI and SMSDEBUG.LOG located in? The PHP folder should be in that same directory and it should contain routeme.php.

(There are some differences in different versions of NowSMS with different versions of Windows. Sometimes ProgramData\NowSMS is used for data files. Other times Program Files\NowSMS or Program Files (x86)\NowSMS is used. PROGRA~1 is usually the short name for Program Files, so I believe NowSMS is looking for Program Files\NowSMS\PHP\routeme.php. The 2-way page of the configuration should report the directory using its long name.)

NowSMS was finding this file before you re-installed from scratch, so I'm guessing it was deleted if you uninstalled, and if it does not exist.

--
Des
NowSMS Support
Globe
New member
Username: Globeuser

Post Number: 25
Registered: 04-2013
Posted on Monday, June 03, 2013 - 06:06 pm:   

Hi Des,

SMSGW.INI and SMSDEBUG.LOG are located in C:\Program Files\NowSMS from what I can see on the machine.

Although the files themselves dont have .INI and .LOG extns respectively.

I am not sur3e why NowSMS is looking under C:\PROGRA~1\NowSMS\PHP\routeme.php

What would be the solution to get out of this?
Would re installing NowSMS again help ?
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 4521
Registered: 08-2008
Posted on Monday, June 03, 2013 - 06:24 pm:   

Hi Pavan,

As I stated above, PROGRA~1 is usually the short name for Program Files, so I believe NowSMS is looking for Program Files\NowSMS\PHP\routeme.php.

I don't think that the mixed reference to short and long names for the directory is a problem.


quote:

Although the files themselves dont have .INI and .LOG extns respectively.




This may be the clue we are looking for.

Windows is hiding file extensions, which may mean that although you see a file named routeme.php in Windows Explorer, that is not its actual name.

Open a command prompt window so that you can see things as they really exist.

Change directories to NowSMS:

cd "\Program Files\NowSMS"

Do a directory listing of the PHP subfolder:

dir php


Make sure routeme.php is displayed in this list, and that it doesn't have an extra file extension. (For example, if it is routeme.php.txt, that is a problem.)

You can turn off Windows Explorer hiding file extensions by following the steps detailed by Microsoft here: http://support.microsoft.com/kb/865219

If none of this seems to apply to your situation, from the command prompt window, I want to see a list of all files under your NowSMS install. From the C:\Program Files\NowSMS prompt, type:

dir /s > dir.txt

This will create a file named dir.txt that lists all of the files under the NowSMS install directory, and that will allow me to confirm whether or not the file in question exists.

--
Des
NowSMS Support
Globe
New member
Username: Globeuser

Post Number: 26
Registered: 04-2013
Posted on Monday, June 03, 2013 - 07:25 pm:   

Hi Des,

That worked although have a routing issue, just mailed you the script and the SMSdebug logs. COuld you look into it ?
Des - NowSMS Support
Board Administrator
Username: Desosms

Post Number: 4522
Registered: 08-2008
Posted on Monday, June 03, 2013 - 08:02 pm:   

Hi Pavan,

Referring back to your script above, the +1929 number is not being routed correctly because the + character is missing from the test condition in the PHP script. The + character is present for all other test conditions, but not this one.

!strncmp ($to, "19292237", 8)

should be

!strncmp ($to, "+19292237", 9)

--
Des
NowSMS Support

Login Login / Register Logout Logout Search Last 30 Days Topics Topics