diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 44e44f86477437dc90f869ff17c67cad217465dd..32764b8cf7922a9bd4ecaa04967c13478ba60e18 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -11702,14 +11702,19 @@ static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req, return 0; } - /* Initialize the context if it hasn't been already */ + /* Get destination right away */ + gotdest = get_destination(p, NULL); + + /* Initialize the context if it hasn't been already; + note this is done _after_ handling any domain lookups, + because the context specified there is for calls, not + subscriptions + */ if (!ast_strlen_zero(p->subscribecontext)) ast_string_field_set(p, context, p->subscribecontext); else if (ast_strlen_zero(p->context)) ast_string_field_set(p, context, default_context); - /* Get destination right away */ - gotdest = get_destination(p, NULL); build_contact(p); if (gotdest) { transmit_response(p, "404 Not Found", req);