Summary: | ASTERISK-24863: res_pjsip: No endpoint events raised via AMI when contacts cannot be reached/qualified | ||
Reporter: | Dmitriy Serov (Demon) | Labels: | |
Date Opened: | 2015-03-11 08:53:47 | Date Closed: | 2015-04-17 10:32:06 |
Priority: | Major | Regression? | No |
Status: | Closed/Complete | Components: | Resources/res_pjsip |
Versions: | 13.2.0 | Frequency of Occurrence | |
Related Issues: | |||
Environment: | Attachments: | ||
Description: | Using res_pjsip I have not any AMI events when lost connection to outgoing SIP server.
Endpoint configured as a trunk, outbound authentication. Qualify changes status of contact. But endpoint does not change own status, no AMI events I see. | ||
Comments: | By: Matt Jordan (mjordan) 2015-03-11 09:43:06.910-0500 Relevent conversation from #asterisk-dev: {quote} {noformat} (08:32:32 AM) Demon_VoIP: mjordan, What do you think about... PJSIP: endpoint configured as a trunk, outbound authentication. Should the endpoint status change on the Unavailable when all contacts (from aor) become Unavailable? (08:33:51 AM) ***mjordan wonders if he just walked into a trap (08:34:06 AM) mjordan: what do you mean by "contacts from AoR become Unavailable" (08:34:38 AM) Demon_VoIP: now i have not any AMI events when lost connection to outgoing SIP server :( (08:37:18 AM) mjordan: Hm. (08:37:45 AM) mjordan: what state are you expecting to be unavailable? The device state of the PJSIP endpoint for the trunk? (08:43:01 AM) Demon_VoIP: qualify chaned statues of contact. But no AMI events i see. Am I wrong? (08:43:01 AM) Demon_VoIP: sorry for mistakes :( (08:44:43 AM) mjordan: I wouldn't think it would change the device state. It should change the endpoint state. (08:44:45 AM) Demon_VoIP: I am expecting AMI event peerstatus with unavailable. And it will be best changing endpoint status to unavailable. (08:44:45 AM) Demon_VoIP: chan_sip has such behavior (08:45:06 AM) mjordan: I'm aware :-P (08:45:13 AM) mjordan: I think it is probably a bug. (08:45:27 AM) Demon_VoIP: Yes. It should change the endpoint state (08:45:52 AM) Demon_VoIP: It was my question: Should the endpoint status change on the Unavailable when all contacts (from aor) become Unavailable? :) (08:46:28 AM) mjordan: endpoint is an overloaded term. In this case, I wanted to make sure you meant the internal ast_endpoint, and not necessarily something else. (08:46:37 AM) mjordan: please file a bug. {noformat} {quote} By: Matt Jordan (mjordan) 2015-03-11 09:45:44.767-0500 When we determine that a contact is unreachable, that never actually translates into an {{ast_endpoint}} state. As a result, we don't raise a Stasis message or AMI event indicating that the endpoint is unreachable. Further, that doesn't then get reached in {{chan_pjsip}} when we calculate the device state. Currently, we appear to only do this when a contact is created/deleted (as the result of a received REGISTER request or un-REGISTER request): {code} /*! \brief Callback function for changing the state of an endpoint */ static int persistent_endpoint_update_state(void *obj, void *arg, int flags) { struct sip_persistent_endpoint *persistent = obj; char *aor = arg; RAII_VAR(struct ast_sip_contact *, contact, NULL, ao2_cleanup); RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref); if (!ast_strlen_zero(aor) && !strstr(persistent->aors, aor)) { return 0; } if ((contact = ast_sip_location_retrieve_contact_from_aor_list(persistent->aors))) { ast_endpoint_set_state(persistent->endpoint, AST_ENDPOINT_ONLINE); blob = ast_json_pack("{s: s}", "peer_status", "Reachable"); } else { ast_endpoint_set_state(persistent->endpoint, AST_ENDPOINT_OFFLINE); blob = ast_json_pack("{s: s}", "peer_status", "Unreachable"); } ast_endpoint_blob_publish(persistent->endpoint, ast_endpoint_state_type(), blob); ast_devstate_changed(AST_DEVICE_UNKNOWN, AST_DEVSTATE_CACHABLE, "PJSIP/%s", ast_endpoint_get_resource(persistent->endpoint)); return 0; } {code} However, that doesn't help the case where we are qualifying an already registered endpoint (or for things with a static contact, but with no network connectivity). By: George Joseph (gjoseph) 2015-04-06 17:31:05.592-0500 I've created 2 patches for this issue. If you'd like to test, read and apply them in order to branches/13 https://reviewboard.asterisk.org/r/4585/ https://reviewboard.asterisk.org/r/4587/ Let me know how they work. By: George Joseph (gjoseph) 2015-04-06 17:58:05.371-0500 Can you test please? By: Dmitriy Serov (Demon) 2015-04-07 04:32:39.346-0500 asterisk 13.3.1 patching file res/res_pjsip.c Hunk #2 succeeded at 1814 (offset -21 lines). Hunk #3 succeeded at 2754 (offset -21 lines). Hunk #4 succeeded at 2933 (offset -21 lines). Hunk #5 succeeded at 2950 (offset -21 lines). Hunk #6 succeeded at 2990 (offset -21 lines). Hunk #7 succeeded at 3022 (offset -21 lines). Hunk #8 succeeded at 3044 (offset -21 lines). Hunk #9 succeeded at 3072 (offset -21 lines). Hunk #10 succeeded at 3090 (offset -21 lines). Hunk #11 succeeded at 3354 (offset -21 lines). Hunk #12 succeeded at 3676 (offset -45 lines). Hunk #13 FAILED at 3795. 1 out of 13 hunks FAILED -- saving rejects to file res/res_pjsip.c.rej patching file include/asterisk/res_pjsip.h Hunk #1 succeeded at 1254 (offset -2 lines). The procedure unload_pjsip has changed. I don't dare to try to fix it and run it :( I'll try on trunk soon. By: Dmitriy Serov (Demon) 2015-04-07 06:10:30.868-0500 Two patches tested on trunk. Wonderful! The status changes when lost connection and when connection is restored. Due AMI events come. Thank you very much! |