通过 SMPP 接收 SMS

发布于 2024-10-10 15:55:04 字数 192 浏览 0 评论 0原文

我有一个项目需要通过特定的移动运营商发送和接收消息,该运营商仅提供 SMPP 接口。整个项目将是一个托管网站。我已经阅读了很多内容,但我还不太明白使用该协议实际上需要什么。

我的应用程序是否应该尝试保持与 smpp 的持续连接? 我可以简单地连接、发送消息然后断开连接吗?

接收消息是基于推送还是基于拉取?

感谢您的帮助。

I have a project coming up where I need to send and receive messages through a specific mobile operator, which only provides an SMPP interface. The whole project will be a hosted website. I have already read quite a lot, but I do not yet quite understand what is actually needed from my side to use the protocol.

Should my application try to maintain a constant connection to the smpp?
Can I simply connect, send a message and then disconnect?

Are receiving messages based on push or pull?

Thanks for the help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

月下凄凉 2024-10-17 15:55:04

SMPP 是一种点对点协议。这应该意味着 SMS 网关(您这边)和 SMSC(您的移动运营商)需要建立正确的绑定/连接。即使没有要发送/接收的 SMS 或 DLR,也会持续交换 smpp PDU (enquire_link/enquire-link_resp) 以确保建立绑定。
具体来说,如果您发送 enquire_link PDU 并且没有收到响应 (enquire_link_resp),则绑定已损坏。您的短信将不会送达(将在您的网关存储中保持排队状态),并且您不会收到 MO(传入短信)或 DLR(送达报告)。要重新建立连接,您应该重新启动连接。

所以,我的答案是您需要与 SMSC 保持持续连接。

SMPP is a peer-to-peer protocol. That should mean that SMS Gateway (your side) and SMSC (your mobile operator) need to have a proper bind/connection established. Even when there are no SMS or DLRs to send/receive, there is a continous exchange of smpp PDU (enquire_link/enquire-link_resp) that ensure that the bind is established.
In detail, if you send an enquire_link PDU and you get no response (enquire_link_resp) the bind is broken. Your sms won't be delivered (will remain enqueued in your gateway store), and you won't receive MOs (incoming sms) or DLRs (delivery report). To re-establish the connection you should re-initiate the connection.

So, my answer would be that you need a constant connection to SMSC.

如果没有 2024-10-17 15:55:04

您声明您想要接收消息,因此至少需要一个 bind_receiver 。因为您不知道消息何时传入,所以您必须始终保持连接,而不是在每次事件后断开连接。

关于你关于“推还是拉”的问题,这取决于你如何解决第一个问题。如果你能构建一个持续连接的解决方案,结果将是推送(运营商收到消息后会立即推送给你)。如果(由于某种原因)你无法保持持续的连接,你最终将构建一个拉机制。您将每隔 X 秒连接到运营商,看看他们是否有消息在等您。

不过,我确实需要强调两个陷阱:

  1. 世界上的许多运营商在未连接的情况下不会存储甚至接受消息,因此,根据您与哪个运营商交互,您可能被迫使用连续连接。
  2. 大多数运营商不允许您快速连续地打开和关闭连接。一旦断开连接,您将在 X 秒内无法重新连接。

因此,持续的联系才是真正的出路。或者,您可以考虑像 Nexmo 这样的公司,每次消息到达时它都会为您提供 HTTP 调用。

我不确定您使用哪种语言开发应用程序,但如果您使用任何流行的语言(Java、PHP、Perl),都有一些模块可以为您处理基本的 SMPP 连接。在 google 上快速搜索您的语言和“SMPP 客户端”将为您提供参考列表。

You are stating you want to receive messages, as a result at least a bind_receiver is needed. Because you don't know when messages are going to come in, you will have to be constantly connected, rather than disconnecting after each event.

With regards to your question about "push or pull" this depends on how you solve the first problem. If you can build a solution that is constantly connected, the result will be a push (the carrier will push it to you as soon as they receive the message). If (for some reason) you cannot maintain a constant connection, you'll end up building a pull mechanism. You'll connect to the carrier ever X seconds to see if they have a message waiting for you.

I do need to highlight 2 pitfalls though:

  1. A number of carriers in the world, do not store or even accept messages if you are not connected, therefore, depending on which carrier you interact with, you might be forced to use a continuous connection.
  2. Most carriers do not allow you to open and close connections in quick succession. Once you disconnect, you can not reconnect for a time frame of X seconds.

Therefore a constant connection is really the way to go. Alternatively, you can look into a company like Nexmo, which will provide you with a HTTP Call every time a message arrives.

I'm not sure which language your developing your application in, but if you use any of the popular languages (Java, PHP, Perl) there are modules out there that handle basic SMPP Connectivity for you. A quick google search for your language and "SMPP Client" will give you a list of references.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文