Notify pending transactions on TCP/TLS connection close#288
Notify pending transactions on TCP/TLS connection close#288emiago merged 3 commits intoemiago:mainfrom
Conversation
|
Hi @Odinvt . I see the issue you want to catch. Also why not adding ws/wss as well? |
|
Thanks for the feedback @emiago, all addressed: Feature flag: Added Burst effect: You're right, Timer_B naturally spreads termination since transactions are created at different times. This flag collapses that into one event. Go scheduling provides fairness across the spawned goroutines though, but the application is deliberately making that tradeoff, hence the opt-in 👍. WS/WSS: Added. Note: I separated signal from action. The connection-close notification is always wired (all 4 transports > |
|
ok nice. I would use global but ok it can be tranport layer parameter. |
Sorry for not looking deeper into the global var pattern before submitting, I should have checked your conventions first.
Our use case is UAC-heavy (SIP load testing), so client transactions are where I hit this in practice. I haven't faced the server tx side yet, which is why it wasn't included. But looking at the code, here's what I found (please do correct me if I'm wrong): Server tx lifecycle relative to
The When connection dies:
So server transactions already self-terminate on the next write attempt. The difference from client transactions: there's no Timer_B equivalent sitting idle for 32s. The server tx lifecycle is bounded by application code duration (handler runs, calls The concern with including server tx: firing It could still make sense as a separate opt-in, but it needs its own analysis since the failure mode is different: client tx = stuck waiting for a response that will never come, server tx = app handler racing with early termination. Happy to look into it as a follow-up if you think it's worth exploring. |
|
Actually thinking about this more, you're right. Server transactions already have Up to you if you want me to add server transactions to the same flag in this PR or keep it as a follow-up. |
|
yeah we should add server transactions as well. I see no reason not to add this. I think there could be some reason todo this like your example, but as I said it should be flag for now. |
|
Added server transaction termination under the same flag. Thanks for the feedback and the insight on SIP transaction/connection coupling, that is indeed a useful framing. |
Scenario :
When a TCP/TLS connection is closed by the remote end, readConnection exits without notifying the transaction layer. Pending client transactions on that connection wait the full Timer_B (32s) before timing out.
Fix :
This adds a callback from the transport to the transaction layer on connection close. Matching client transactions receive client_input_transport_err, which is already handled in every FSM state. The goroutine pattern matches existing transport error handling in ack()/resend().
How this was found :
During mTLS testing against Kamailio with require_certificate=yes, a client connecting with an invalid certificate completes the TLS handshake (TLS 1.2 sends client cert after ServerHello) but the server immediately closes the connection upon evaluating the cert. Our REGISTER transaction was left hanging for 32 seconds despite the connection being dead.