ajankovic / smpp

Go library for SMPP 3.4
MIT License
24 stars 21 forks source link

Session close #8

Open Prasannagud opened 4 years ago

Prasannagud commented 4 years ago

Hi, The bind disconnects (session shutdown) happening while read happens .It happens only in receiver mode and when receiving the deliversm request pdu only.It is happening at irregular intervals. The following is the raw byte sequence sent by the sender 0 1 1 57 49 57 49 55 55 49 56 50 54 52 56 0 0 0 73 67 73 79 0 4 1 0 0 0 0 0 0 0 101 105 100 58 48 32 115 117 98 58 48 48 49 32 100 108 118 114 100 58 48 48 49 32 115 117 98 109 105 116 32 100 97 116 101 58 50 48 48 53 49 52 49 49 50 48 32 100 111 110 101 32 100 97 116 101 58 50 48 48 53 49 52 49 49 50 48 32 115 116 97 116 58 68 69 76 73 86 82 68 32 101 114 114 58 48 48 48 32 84 101 120 116 58 84 101 115 116 32 77 115 103 0 30 0 2 48 0 4 39 0 1 2 20 3 0 10 52 52 49 50 51 52 53 54 55 56

And the receiver received 0 1 1 57 49 57 49 55 55 49 56 50 54 52 56 0 0 0 73 67 73 79 0 4 1 0 0 0 0 0 0 0 101 105 100 58 48 32 115 117 98 58 48 48 49 32 100 108 118 114 100 58 48 48 49 32 115 117 98 109 105 116 32 100 97 116 101 58 50 48 48 53 49 49 50 48 32 100 111 110 101 32 100 97 116 101 58 50 48 48 53 49 52 49 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

And the error was smpp: pdu length doesn't match read body length 166 != 96.I dont see any issue with the sender. Any Help urgently required.

Thanks in advance.

DanielKoehler commented 3 years ago

I believe this because the server doesn't handle partial PDUs being added to the buffer (where the rest of the PDU will be written by the next packet).

In func (d *Decoder) Decode() you could replace:

h := make([]byte, 16)
n, err := d.r.Read(h)
if err != nil {}

with:

var h [16]byte
if _, err = io.ReadFull(d.r, h[:]); err != nil {}

( And a similar io.ReadFull for the body based on the length defined in the header. )