Asterisk and SPA disagree about hangup

I make a call out from Asterisk through my SPA3000 to the PSTN. I get a busy signal - fine I expected that. I hang up.

The FXS side goes on-hook, but the FXO side stays off-hook. If I try to make another call out the FXO it reports back that it is busy, which is consistent, but wrong. Why doesn’t the FXO side go on-hook when Asterisk wants to hang up?

I see this in the SIP DEBUG output coming back from the FXO port of the SPA:

SIP/2.0 488 Not Acceptable Here To: <sip:NXXXXXX@>;tag=3507c1057a13ab 36i1 From: "Anonymous" <sip:homephone@>;tag=as35969a98 Call-ID: 73c65d7f71d1d31623bada8f18ae19c8@ CSeq: 104 INVITE Via: SIP/2.0/UDP;branch=z9hG4bK347c01cc Contact: verizon <sip:NXXXXXX@> Warning: 304 spa "Media type not available" Server: Sipura/SPA3000-2.0.13(GWg)

Just before this Asterisk had sent another INVITE (a re-invite) as part of how it wants to terminate the call. I don’t know why. Apparently the SPA objects to this, and just sits there holding the FXO port off-hook. meanwhile Asterisk thinks it has hung up.

My dialout script looks like this:

; Dial $ARG1 outbound with error detection.
exten => s,1,Dial(${ARG1},30)
exten => s,n,Noop(${DIALSTATUS})
exten => s,n,Goto(s-${DIALSTATUS},1) ; Jump based on status (NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,ANSWER)

exten => s-NOANSWER,1,Answer
exten => s-NOANSWER,2,Playtones(congestion)
exten => s-NOANSWER,3,Congestion
exten => _s-.,1,Goto(s-NOANSWER,1) ; Treat anything else as no answer too[/code]

It seems to me Asterisk should be sending a BYE or CANCEL.