jasmin icon indicating copy to clipboard operation
jasmin copied to clipboard

Confused about MO vs MT and receiving messages.

Open AndreaAltamirano opened this issue 7 years ago • 21 comments

Hello! First of all, Jasmin is awesome in the couple of tests I've run so far, so many thanks to everyone involved. I'm not sure if I'll get an answer here because this is more of a support/conceptual question than an issue. Apologies in advance.

I'm pretty confused when it comes to receiving messages. Our situation is as follows: we have our own numbers but we're not a mobile service provider. We would like to send messages to our clients (through the actual mobile providers) and be abale to receive answers (Like standardized YES or NO answers or prompts) and act on them through an API. This would be covered by the MO messages you refer to in your architecture:

screen shot 2017-05-02 at 5 59 31 pm

But to interconnect with the actual providers they require an SMPP connection where they are the client, while also getting DLRs and everything. This is obviously covered by the "SMPP Server" part of your architecture.

screen shot 2017-05-02 at 6 11 56 pm

The connection works with the one provider we've tried so far, but every message through that channel gets identified as an MT message...and we have nowhere to forward it because our numbers aren't actual devices. (We get this error: "2017-04-28 19:17:01 ERROR 1 SMPPC [cid:virgin] is not bound: Requeuing ..."

So, to sum it up, is there any way to force messages to be identified as MO (How would they ever be MO and not MT?) to be able to trigger the scripts associated with Receiving SMS-MO as described in your documentation, while at the same time delivering DLRs to the SMPP client. Or if thats impossible, a way to save SMS-MT in a database and respond with DLRs while not actually delivering them to the destination number.

I hope that wasn't too confusing. Thanks in advance for any kind reply.

AndreaAltamirano avatar May 02 '17 21:05 AndreaAltamirano

Hi Andrea,

From a design perspective the "provider" is considered as the uplink (or upstream) and it's always a smpp server, Jasmin will connect to the provider.

I understand you have a reversed situation where the "provider" is connecting to Jasmin, in this case the provider is a smpp client (receives MO and send MT).

farirat avatar May 04 '17 03:05 farirat

Hi Farirat, thank you so much for responding.

My use case is that I need to send MT messages and receive MO ones that I store in a database and respond accordingly.

BUT, the phone companies require me to give them an account and they want to receive DLRs for every message that a mobile belonging to them sends back. So they only give me MTs...so my question is if I can somehow treat those MTs as if they were MOs so I can process them with an HTTP api or intercept them. And the other question is how MOs would ever originate, like, I don't really understand under what circumstances they happen.

Thanks.

AndreaAltamirano avatar May 04 '17 17:05 AndreaAltamirano

@AndreaAltamirano do you have a clear call flow to explain your use case ?

farirat avatar May 06 '17 09:05 farirat

Hello Farirat,

The phone companies required me to give them a user (system_id and password). Thats the only way they want to send messages my way (MT). What I need is to somehow route those as if they were MO only (because the endpoint is not a device, as we don't actually own any). So for example, yesterday one company connected and tried to send this message:

tail -20 default-smpps_01.log:

2017-05-26 09:18:35 ERROR 1 No route matched from user provider for SubmitSmPDU: PDU [command: submit_sm, sequence_number: 31, command_status: ESME_ROK service_type: '' source_addr_ton: EnumValue(<jasmin.vendor.enum.Enum object at 0x7fe692a9fd10>, 6, 'INTERNATIONAL') source_addr_npi: EnumValue(<jasmin.vendor.enum.Enum object at 0x7fe692aa7250>, 9, 'ISDN') source_addr: 'their number' dest_addr_ton: EnumValue(<jasmin.vendor.enum.Enum object at 0x7fe692a9fd10>, 4, 'NATIONAL') dest_addr_npi: EnumValue(<jasmin.vendor.enum.Enum object at 0x7fe692aa7250>, 9, 'ISDN') destination_addr: 'one of our numbers' esm_class: EsmClass[mode: DEFAULT, type: DEFAULT, gsmFeatures: set([])] protocol_id: 0 priority_flag: EnumValue(<jasmin.vendor.enum.Enum object at 0x7fe692aa7450>, 0, 'LEVEL_0') schedule_delivery_time: None validity_period: None registered_delivery: RegisteredDelivery[receipt: SMSC_DELIVERY_RECEIPT_REQUESTED, smeOriginatedAcks: set([]), intermediateNotification: False] replace_if_present_flag: EnumValue(<jasmin.vendor.enum.Enum object at 0x7fe692aa7710>, 0, 'DO_NOT_REPLACE') data_coding: DataCoding[scheme: DEFAULT, schemeData: SMSC_DEFAULT_ALPHABET] sm_default_msg_id: 0 short_message: 'A' ]

This obviously threw a route not found error since none of my MT routes match the destination number. Can I somehow divert it/intercept it to make it behave like an MO (sorry my knowledge of the inner workings of jasmin is very limited).

AndreaAltamirano avatar May 26 '17 12:05 AndreaAltamirano

You can make MT2MO conversion through an external http call, but i dont understand where do you want to route the MO to ?

farirat avatar May 27 '17 21:05 farirat

Hello!

I want to save them to my database and send DLRs as if they were regular MOs. I have my morouter set up and everything:

screen shot 2017-05-27 at 6 09 52 pm
def receive_sms():
    db.message.insert(body=request.post_vars)
    db.commit()
    return "ACK/Jasmin"

Could you explain to me how I do the conversion from MT to MO with an external call like I'm 5 years old? Would this involve the interceptor? (I can already intercept the MT messages coming to my numbers through a regex filter) Thank you so much!

AndreaAltamirano avatar May 27 '17 22:05 AndreaAltamirano

Saldly I haven't been able to figure it out so far. I can barely run the interceptors script. Any and all help would be greatly appreciated. Thanks.

AndreaAltamirano avatar May 31 '17 02:05 AndreaAltamirano

Hi Andrea,

Surely an interceptor script is not the way forward, you simply need to setup a MT endpoint.

operator SMS -> MT -> JASMIN -> MT receiver (your http script)

You need to setup Jasmin to MTRoute the messages onward to something else (your application) to receive them

A simple app, would be a HTTP receiver - that would write to file.

HTH

On 31 May 2017 at 03:24, AndreaAltamirano [email protected] wrote:

Saldly I haven't been able to figure it out so far. I can barely run the interceptors script. Any and all help would be greatly appreciated. Thanks.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jookies/jasmin/issues/568#issuecomment-305063778, or mute the thread https://github.com/notifications/unsubscribe-auth/AAM85I1Eg7fcuPGLNjKh8ggE0cRbtkBcks5r_M9FgaJpZM4NOuAi .

jmoverley avatar May 31 '17 06:05 jmoverley

Mmm how would this endpoint look?

As I understood it jasmin only provides the possibility to set up endpoints for MO messages. For MT it only allows other smpp servers as possibilities (smppc). Could you explain how this would work or look? Because the documentation only explains the short external calls needed to receive MOs (beautiful and easy). Ive looked into creating a full SMPP connector but that kind of defeats the purpose of using jasmin (and looks very complicated).

operator SMS -> MT -> JASMIN -> MT receiver (your http script) <--- how?

Farirats suggested way would be (as far as I can tell):

operator SMS -> MT -> JASMIN (interceptor) -> external call MT2MO (What would it have to do?) -> JASMIN (MORouter) -> http endpoint -> save to BD, ACK/Jasmin

Don't know what would be the better solution, Id be happy with either one of them, but I haven't been able to find anything in the docs. 🙇🏻‍♀️

If anyone ( @farirat ) could explain either scenario in detail considering that I'm new to this I'd be so grateful. 🙇🏻‍♀️🙇🏻‍♀️🙇🏻‍♀️

Thanks!

AndreaAltamirano avatar May 31 '17 11:05 AndreaAltamirano

Please, can anyone help a girl out? I'd be willing to pay for a quick chat, this can't be that difficult, I'm just not seeing it. =(

AndreaAltamirano avatar Jun 02 '17 14:06 AndreaAltamirano

gender regardless : Still not sure whats trying to be achieved here..

1: You have SMPP connection from a "phone company" -> is this an operator or a business that wishes to send text

2: they submitSM to you (this is application to mobile submission AO->MT)

What is the desired outcome after you receive this SM?

You wish to onward submt to an operator? or to an application?

jasmin is designed as a message router, it will receive messages via SMPP, and then via the routing table decide how to onward route them.

http://jasmin.readthedocs.io/en/latest/architecture/

Hopefully helping :)

On 2 June 2017 at 15:08, AndreaAltamirano [email protected] wrote:

Please, can anyone help a girl out? I'd be willing to pay for a quick chat, this can't be that difficult, I'm just not seeing it. =(

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jookies/jasmin/issues/568#issuecomment-305798909, or mute the thread https://github.com/notifications/unsubscribe-auth/AAM85IzNURkNP4KtFPuEjOEqD53NGCCXks5sABdmgaJpZM4NOuAi .

jmoverley avatar Jun 02 '17 14:06 jmoverley

Hello jmoverley, thanks for answering!

  1. Its an operator that sends MT messages our way
  2. Those MT (submit_sm) messages I need to save to a database and send a DLR (as if they were MO (deliver_sm). Farirat suggested that I can do MT2MO, you suggested that I can forward it to a http application somehow (dont know how, the mtrouter only allows forwarding to smppc)

So to answer your question: "You wish to onward submt to an operator? or to an application?" Its to an application somehow.

AndreaAltamirano avatar Jun 02 '17 14:06 AndreaAltamirano

You want jasmin to behave as a SMSC, and that is not possible (as far as I know).

asgarciap avatar Jun 02 '17 15:06 asgarciap

Mmm...cant be the only case where the answers to an MT send by us come through a different smpp connection in the form of another MT (its how they need it). And I mean, I already get the message as the log above shows, there must be something I can do. =(

AndreaAltamirano avatar Jun 02 '17 15:06 AndreaAltamirano

It is not that easy to generate a DLR, you have to check if the submit_sm actually requested the DLR, then generate and send a msgId in the submit_sm_resp, then create the deliver_sm with the proper deliver status and the msgId generated previously. There is a lot of logic in that process and jasmin is not intended to do that (again, as far as I know).

asgarciap avatar Jun 02 '17 15:06 asgarciap

Might even suggest you look at Kannel, which does act as an SMC :) J

On 2 June 2017 at 16:59, Mr. Lucius Fox [email protected] wrote:

It is not that easy to generate a DLR, you have to check if the submit_sm actually requested the DLR, then generate and send a msgId in the submit_sm_resp, then create the deliver_sm with the proper deliver status and the msgId generated previously. There is a lot of logic in that process and jasmin is not intended to do that (again, as far as I know).

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/jookies/jasmin/issues/568#issuecomment-305831386, or mute the thread https://github.com/notifications/unsubscribe-auth/AAM85CTNDuiY2259mzyG2hKkXUFlEDgdks5sADFagaJpZM4NOuAi .

jmoverley avatar Jun 05 '17 08:06 jmoverley

@AndreaAltamirano @farirat I have the same issue I am receiving the incoming SMS like MT (instead of MO) and I need to route it with mtroute.

@farirat Maybe I can solve it using a mt2mo conversión before route it but I don't know how to do it

chihau avatar Jul 07 '17 07:07 chihau

Hi all,

I managed to solve this by using an MT interceptor:

  • Locally generated messages (http://localhost:1401/send) get a tag applied to them
  • On the interceptor script incoming tagged messages are left as is
  • Incoming messages are then captured and inserted into a database/submitted to a REST service/whatever
  • A message_id is generated and assigned to the (undocumented) extra parameter (https://github.com/jookies/jasmin/blob/0.9.25/jasmin/interceptor/interceptor.py#L51 / https://github.com/jookies/jasmin/blob/0.9.25/jasmin/protocols/smpp/factory.py#L345-L346)
  • A value of 0 is set to smpp_status which, as stated in the documentation, skips the rest of the routing process (http://jasmin.readthedocs.io/en/latest/interception/index.html#intercepting-a-message). This, coupled with the previous step, allows a valid submit_sm_resp message to be sent back to the upstream provider
  • For the DLR, a deliver_sm PDU is created, by reversing the src/dst values from the original message and using the previously generated message_id (see https://github.com/jookies/jasmin/blob/0.9.25/jasmin/protocols/smpp/operations.py#L300-L311 for an example) and wrapped inside a RoutedDeliverSmContent, with the connector identified by the user property of the routable object
  • Finally the message is injected to the deliver_sm_thrower.smpps AMQP queue for delivery.

Hope it helps.

Best,

idevsoftware avatar Aug 21 '17 20:08 idevsoftware

Hi all,

I managed to solve this by using an MT interceptor:

  • Locally generated messages (http://localhost:1401/send) get a tag applied to them
  • On the interceptor script incoming tagged messages are left as is
  • Incoming messages are then captured and inserted into a database/submitted to a REST service/whatever
  • A message_id is generated and assigned to the (undocumented) extra parameter (https://github.com/jookies/jasmin/blob/0.9.25/jasmin/interceptor/interceptor.py#L51 / https://github.com/jookies/jasmin/blob/0.9.25/jasmin/protocols/smpp/factory.py#L345-L346)
  • A value of 0 is set to smpp_status which, as stated in the documentation, skips the rest of the routing process (http://jasmin.readthedocs.io/en/latest/interception/index.html#intercepting-a-message). This, coupled with the previous step, allows a valid submit_sm_resp message to be sent back to the upstream provider
  • For the DLR, a deliver_sm PDU is created, by reversing the src/dst values from the original message and using the previously generated message_id (see https://github.com/jookies/jasmin/blob/0.9.25/jasmin/protocols/smpp/operations.py#L300-L311 for an example) and wrapped inside a RoutedDeliverSmContent, with the connector identified by the user property of the routable object
  • Finally the message is injected to the deliver_sm_thrower.smpps AMQP queue for delivery.

Hope it helps.

Best,

@idevsoftware could you share your code example please? thanks!

2naive avatar Dec 24 '18 03:12 2naive

It’d be greatly helpful to get a sample code!

I currently receive the smpp and also use an interceptor to then retrieve the sms paramos and forward it’s straight to my http sms box. But receiving back the dLR I haven’t yet figured out.

davidcsi avatar Oct 13 '19 16:10 davidcsi

Hi all,

I managed to solve this by using an MT interceptor:

* Locally generated messages (`http://localhost:1401/send`) get a tag applied to them

* On the interceptor script incoming tagged messages are left _as is_

* Incoming messages are then captured and inserted into a database/submitted to a REST service/whatever

* A `message_id` is generated and assigned to the (undocumented) `extra` parameter (https://github.com/jookies/jasmin/blob/0.9.25/jasmin/interceptor/interceptor.py#L51 / https://github.com/jookies/jasmin/blob/0.9.25/jasmin/protocols/smpp/factory.py#L345-L346)

* A value of 0 is set to `smpp_status` which, as stated in the documentation, skips the rest of the routing process (http://jasmin.readthedocs.io/en/latest/interception/index.html#intercepting-a-message). This, coupled with the previous step, allows a valid `submit_sm_resp` message to be sent back to the upstream provider

* For the DLR, a `deliver_sm` PDU is created, by reversing the src/dst values from the original message and using the previously generated `message_id` (see https://github.com/jookies/jasmin/blob/0.9.25/jasmin/protocols/smpp/operations.py#L300-L311 for an example) and wrapped inside a `RoutedDeliverSmContent`, with the connector identified by the `user` property of the `routable` object

* Finally the message is injected to the `deliver_sm_thrower.smpps` AMQP queue for delivery.

Hope it helps.

Best,

jesus, i understand the process which is what we need to do. But doing it is another level?can you help us to do it?

primeKal avatar Jun 23 '21 13:06 primeKal

Stale issue detected, remove stale label or comment or this will be closed soon.

github-actions[bot] avatar Jun 24 '23 02:06 github-actions[bot]

This issue was closed because it has been stalled more than a year with no activity.

github-actions[bot] avatar Aug 09 '23 02:08 github-actions[bot]