Closed sujit-baniya closed 3 years ago
What is wrong with this way of sending concatenated SMS: https://play.golang.org/p/1txaUzsOIer https://play.golang.org/p/UkOZOhFqV41 https://play.golang.org/p/wEOkIzP2kKP
On PDU DeliverSM, I'm not getting the UDH Details for concatenated message. Instead I only receive this 0 0 0 false
Also for NON-GSM Character, on PDU DeliverSM, I'm getting error
panic: invalid gsm7 byte
when doing pd.Message.GetMessage()
How would I fix above
@sujit-baniya I am very sorry for pretty late reply. I and @bachhh had amount of business and personal affair that time.
We will try to provide example of sending concatenated SMS soon. Stay tune :)
func(s *SmppProvider) Submit(srcAddr pdu.Address, destAddr pdu.Address, msg string, encoding data.Encoding) error {
submitSM := pdu.NewSubmitSM().(*pdu.SubmitSM)
submitSM.SourceAddr = srcAddr
submitSM.DestAddr = destAddr
err := submitSM.Message.SetLongMessageWithEnc(msg, encoding)
if err != nil {
log.Fatal(err)
}
submitSM.RegisteredDelivery = 1
messages, err := submitSM.Split()
if err != nil {
return err
}
for _, sub := range messages {
if err := s.Session.Transceiver().Submit(sub); err != nil {
return err
}
}
}
Hi Thank you for your feedback. Please let me know if it's correct way to send concatenated SMS.
Also waiting for best example from you :)
@linxGnu Any plan to add some examples soon?
Hi, my version
trans global var trans, err := gosmpp.NewTransceiverSession( cfg global config array
main() {
---
log.Println("Start proccess SMS: " + p.msisdnto)
if len(p.message) < 256 {
err = trans.Transceiver().Submit(newSubmitSM(p.msisdnfrom, p.msisdnto, p.message))
} else {
newSubmitLongSM(p.msisdnfrom, p.msisdnto, p.message)
}
---
}
func newSubmitSM(srcaddr string, destaddr string, message string) *pdu.SubmitSM {
// build up submitSM
srcAddr := pdu.NewAddress()
srcAddr.SetTon(cfg.SrcSetTon)
srcAddr.SetNpi(cfg.SrcSetNpi)
_ = srcAddr.SetAddress(srcaddr)
destAddr := pdu.NewAddress()
destAddr.SetTon(cfg.DestSetTon)
destAddr.SetNpi(cfg.DestSetTon)
_ = destAddr.SetAddress(destaddr)
submitSM := pdu.NewSubmitSM().(*pdu.SubmitSM)
submitSM.SourceAddr = srcAddr
submitSM.DestAddr = destAddr
err = submitSM.Message.SetMessageWithEncoding(message, data.UCS2)
if err != nil {
if startdaemon {
log.Println(err)
} else {
fmt.Println(err)
}
}
submitSM.ProtocolID = cfg.ProtocolID
submitSM.RegisteredDelivery = cfg.RegisteredDelivery
submitSM.ReplaceIfPresentFlag = cfg.ReplaceIfPresentFlag
submitSM.EsmClass = cfg.EsmClass
return submitSM
}
func newSubmitLongSM(srcaddr string, destaddr string, message string) *pdu.SubmitSM {
// build up submitSM
srcAddr := pdu.NewAddress()
srcAddr.SetTon(cfg.SrcSetTon)
srcAddr.SetNpi(cfg.SrcSetNpi)
_ = srcAddr.SetAddress(srcaddr)
destAddr := pdu.NewAddress()
destAddr.SetTon(cfg.DestSetTon)
destAddr.SetNpi(cfg.DestSetTon)
_ = destAddr.SetAddress(destaddr)
submitSM := pdu.NewSubmitSM().(*pdu.SubmitSM)
submitSM.SourceAddr = srcAddr
submitSM.DestAddr = destAddr
err = submitSM.Message.SetLongMessageWithEnc(message, data.UCS2)
if err != nil {
if startdaemon {
log.Println(err)
} else {
fmt.Println(err)
}
}
var multimessage []*pdu.SubmitSM
multimessage, err := submitSM.Split()
if err != nil {
if startdaemon {
log.Println(err)
} else {
fmt.Println(err)
}
}
submitSM.ProtocolID = cfg.ProtocolID
submitSM.RegisteredDelivery = cfg.RegisteredDelivery
submitSM.ReplaceIfPresentFlag = cfg.ReplaceIfPresentFlag
submitSM.EsmClass = cfg.EsmClass
for _, p := range multimessage {
err = trans.Transceiver().Submit(p)
if err != nil {
log.Println(err)
log.Println("Ошибка отправки")
}
}
return submitSM
}
Thanks @egorkovalchuk.
Is there any rule or anything for defining ProtocolID
, RegisteredDelivery
, ReplaceIfPresentFlag
, EsmClass
?
Are they dependent on anything?
It depends on the SMS center and the network in which it operates
RegisteredDelivery -- parameter about delivery confirmation
https://www.3gpp.org/ftp/tsg_t/tsg_t/tsgt_04/docs/pdfs/TP-99128.pdf
@egorkovalchuk Thanks for your information. I tried above mechanism for concatenated sms and seems some of the first letters from each short message are remove.
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
messages := PrepareMultiPartPdu(srcAddr, destAddr, msg, encoding)
for i, sub := range messages {
message, _ := sub.Message.GetMessage()
fmt.Println(message)
if err := s.Session.Transceiver().Submit(sub); err != nil {
log.Fatal(err)
}
}
gives me
Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text eve
e the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not on
e centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
Why is it so?
I would look at the text encoding. May be, string size is calculated incorrectly
@egorkovalchuk text encoding is GSM 7. For single part, everything works fine... but for concatenated sms, first 6 characters are truncated.
Example code:
msg = "This test. I'm loving itThis test. This test. This test. This test. This test. This test. This test. This test. This test. This test. This test. This test. This test. This test. This test. This test. This test. This test. This test. This test. This test. "
// build up submitSM
srcAddr := pdu.NewAddress()
srcAddr.SetTon(5)
srcAddr.SetNpi(0)
_ = srcAddr.SetAddress("00" + "522241")
destAddr := pdu.NewAddress()
destAddr.SetTon(1)
destAddr.SetNpi(1)
_ = destAddr.SetAddress("99" + "522241")
submitSM := pdu.NewSubmitSM().(*pdu.SubmitSM)
submitSM.SourceAddr = srcAddr
submitSM.DestAddr = destAddr
_ = submitSM.Message.SetLongMessageWithEnc(msg, data.GSM7BIT)
submitSM.ProtocolID = 0
submitSM.RegisteredDelivery = 1
submitSM.ReplaceIfPresentFlag = 0
submitSM.EsmClass = 0
messages, _ := submitSM.Message.Split()
for _, msg := range messages {
message, _ := msg.GetMessage()
fmt.Println(message)
}
Which version do you use, with standard version v0.1.3 I couldn't find below methods:
submitSM.Message.SetLongMessageWithEnc(message, data.UCS2)
submitSM.Split()
@motaz Version 0.1.4 (latest version)
Thank you sujit for your prompt response
I changed the version in mod file to 0.1.4 as below:
require github.com/linxGnu/gosmpp v0.1.4
but I get this error:
go: github.com/linxGnu/gosmpp@v0.1.4: reading github.com/linxGnu/gosmpp/go.mod at revision v0.1.4: unknown revision v0.1.4
@motaz Please try go get -u github.com/linxGnu/gosmpp@master
and this is workable example:
package main
import (
"fmt"
"github.com/linxGnu/gosmpp/data"
"github.com/linxGnu/gosmpp/pdu"
)
func main() {
msg := "This test. I'm loving itThis test. This test. This test. This test. This test. This test. This test. This test. This test. This test. This test. This test. This test. This test. This test. This test. This test. This test. This test. This test. This test. "
// build up submitSM
srcAddr := pdu.NewAddress()
srcAddr.SetTon(5)
srcAddr.SetNpi(0)
_ = srcAddr.SetAddress("00" + "522241")
destAddr := pdu.NewAddress()
destAddr.SetTon(1)
destAddr.SetNpi(1)
_ = destAddr.SetAddress("99" + "522241")
submitSM := pdu.NewSubmitSM().(*pdu.SubmitSM)
submitSM.SourceAddr = srcAddr
submitSM.DestAddr = destAddr
_ = submitSM.Message.SetLongMessageWithEnc(msg, data.GSM7BIT)
submitSM.ProtocolID = 0
submitSM.RegisteredDelivery = 1
submitSM.ReplaceIfPresentFlag = 0
submitSM.EsmClass = 0
messages, _ := submitSM.Message.Split()
for _, msg := range messages {
message, _ := msg.GetMessage()
fmt.Println(message)
}
}
Result:
est. I'm loving itThis test. This test. This test. This test. This test. This test. This test. This test. This test. This test.
est. This test. This test. This test. This test. This test. This test. This test. This test. This test. This test.
I get this error:
go: cannot use path@version syntax in GOPATH mode
when I run:
go get -u github.com/linxGnu/gosmpp@master
I'm using
go version go1.15.5 linux/amd64
is it possible to put gomssp@master version in go.mod file?
Try this please
github.com/linxGnu/gosmpp v0.1.4-rc24
in go.mod
Thanks now I can get the newest version, but there is no backward compatibility, my application that compiled with v0.1.3 couldn't work, there are a lot of removed definitions such as Exception, TCPIPConnection, ServerPDUEvent I'll search the alternative for that
Hopefully you're maintaining repo from where you could revert the changes :)
Yes, I'm using subversion server :)
Thanks you very much for your time
by updating to new version I could finally compile the sample code: https://github.com/linxGnu/gosmpp/edit/master/example/main.go but when I run it I get invalid memory address error:
2021/04/13 15:57:50 EOF
panic: runtime error: invalid memory address or nil pointer dereference
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x78 pc=0x50d8a9]
@motaz 0.1.4 contains breaking changes, bug fixes, lot of improvement as well. We completely rewrite networking layer and processing model, make it easy for app development.
if your app work for 0.1.3, you could let it be.
@linxGnu Why does it truncate the text in the example I showed above?
@motaz For latest version please use valid credentials. For testing, you can obtain from here
https://melroselabs.com/services/smsc-simulator/#smsc-simulator-try
@sujit-baniya let me check your case tomorrow and notify you.
Thank you for playing with gosmpp
@motaz 0.1.4 contains breaking changes, bug fixes, lot of improvement as well. We completely rewrite networking layer and processing model, make it easy for app development.
if your app work for 0.1.3, you could let it be.
My code still not in production yet, and I needed the long message concatenation. When I use SetSar.... it gives me nil pointer exception at TLV.GetData I'm confused now either to use 0.1.3 and try to find solution for long message, or to uee RC version, or wait until stable version is released
if isLong {
submit.SetSarMsgRefNum(sarRef)
submit.SetSarSegmentSeqnum(sarNum)
ex := submit.SetSarTotalSegments(sarTotal)
if ex != nil {
fmt.Println("Error in SetSarTotalSegments: ", ex.Error.Error())
} else {
fmt.Println("No Error")
}
}
@motaz fyi, we used rc version in production env with real smsc (one of biggest Telco in Viet Nam)
We also intend to release gosmpp 0.1.4 in near future.
For your case, I guess RC version might be a good one.
@motaz For latest version please use valid credentials. For testing, you can obtain from here
https://melroselabs.com/services/smsc-simulator/#smsc-simulator-try
Thanks, but I'm using testing it in real SMSC. Currently I have SMS Gateway written in Java, and it is working fine for about 9 years, but that version is started to become complicated, it has a lot of Code Smell, so that I need to re-write it as clean code using Golang
@motaz fyi, we used rc version in production env with real smsc (one of biggest Telco in Viet Nam)
This is an important reference, we should have lower SMS traffic here in Sudan comparing with your country, since we have half of population than Vietnam Tomorrow I'll start re-writing the application using Version 0.1.14-RC
@motaz I think your case is interesting. Could you please create a new issue and give in more detail like:
@motaz I think your case is interesting. Could you please create a new issue and give in more detail like:
* Your code * Stack trace where you got panic
You mean the issue with version 0.1.13 with SetSar.. or version 0.1.14-RC ?
@motaz with v0.1.4RC after rewrite/implementation.
In case you still have trouble, please dont hesitate to create an issue and I will try my best to help.
Is there any example for sending multipart or concatenated SMS