diff --git a/res/res_pjsip_outbound_registration.c b/res/res_pjsip_outbound_registration.c
index 7834367c9bc65ad95197690152e62babc76664c0..6c9aa59dc9acee5daaf8c49414313308ccd6df75 100644
--- a/res/res_pjsip_outbound_registration.c
+++ b/res/res_pjsip_outbound_registration.c
@@ -1533,8 +1533,16 @@ static int handle_registration_response(void *data)
 	response->client_state->auth_attempted = 0;
 
 	if (PJSIP_IS_STATUS_IN_CLASS(response->code, 200)) {
-		/* Check if this is in regards to registering or unregistering */
-		if (response->expiration) {
+		/* Check if this is in regards to registering or unregistering
+		 * Retrieve the requested expiration if possible,
+		 * and check it combined with the received expiration to identify if it is reg or un-reg
+		 * Expiration was provided using the Expires header */
+		pjsip_expires_hdr *expires;
+		int exp_expiration = response->expiration;
+		if(response->old_request && (expires = pjsip_msg_find_hdr(response->old_request->msg, PJSIP_H_EXPIRES, NULL))){
+			exp_expiration = expires->ivalue;
+		}
+		if (exp_expiration && response->expiration) {
 			int next_registration_round;
 
 			response->client_state->is494=0;
@@ -1556,7 +1564,13 @@ static int handle_registration_response(void *data)
 					response->client_state->registration_name);
 			}
 		} else {
-			ast_debug(1, "Outbound unregistration to '%s' with client '%s' successful\n", server_uri, client_uri);
+			if (!exp_expiration && !response->expiration) {
+				ast_debug(1, "Outbound unregistration to '%s' with client '%s' successful\n", server_uri, client_uri);
+			} else {
+				// case1: unregistration request with expiration=0, but got response with non-zero expiration;
+				// case2: registration request with non-zero expiration but got expiration=0 in response
+				ast_debug(1, "Outbound registration/unregistration to '%s' with client '%s' failed, expiration not valid\n", server_uri, client_uri);
+			}
 			response->client_state->is494=0;
 			update_client_state_status(response->client_state, SIP_REGISTRATION_UNREGISTERED);
 			sip_outbound_registration_send_ubus_event("UNREGISTERED",response->expiration,client_uri);