linxGnu / gosmpp

Smpp (3.4) Client Library for Go
Apache License 2.0
152 stars 59 forks source link

When using WindowedRequestTracking, if the enquire_link expires, the bind is closed but doesnt restart #151

Open laduchesneau opened 1 week ago

laduchesneau commented 1 week ago

The OnExpiredPduRequest is using the transceivable.go Close() function. This uses the ExplicitClosing state. Therefor the OnClosed() and the session restart() functions are not called.

if t.settings.OnExpiredPduRequest != nil {
    bindClose := t.settings.OnExpiredPduRequest(request.PDU)
    if bindClose {
        _ = t.Close()
    }
}

The normal behavior when any PDU expires, the user should be is given the choice to restart the bind by returning true to the closeBind variable. When its requested, the ConnectionIssue state should be used.

if t.settings.OnExpiredPduRequest != nil {
    bindClose := t.settings.OnExpiredPduRequest(request.PDU)
    if bindClose {
        t.closing(ConnectionIssue)
    }
}

func (t *transceivable) closing(state State) {
    if atomic.CompareAndSwapInt32(&t.aliveState, Alive, Closed) {
        t.in.closing(StoppingProcessOnly)
        t.out.closing(StoppingProcessOnly)

        // close underlying conn
        _ = t.conn.Close()

        // notify transceiver closed
        if t.settings.OnClosed != nil {
            t.settings.OnClosed(state)
        }
    }
    return
}