From: Bill Erickson Date: Tue, 12 Jun 2018 15:16:59 +0000 (-0400) Subject: Websocketd error handling improved X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=3d5d30475b089b1c376a025216ff0701a30c8ac0;p=working%2FOpenSRF.git Websocketd error handling improved Signed-off-by: Bill Erickson --- diff --git a/src/websocket-stdio/osrf-websocket-stdio.c b/src/websocket-stdio/osrf-websocket-stdio.c index 662285a..83e3264 100644 --- a/src/websocket-stdio/osrf-websocket-stdio.c +++ b/src/websocket-stdio/osrf-websocket-stdio.c @@ -508,18 +508,6 @@ static void read_from_osrf() { // each message, because any subsequent messages will get stuck in // the opensrf receive queue. Process all available messages. while ( (tmsg = client_recv(osrf_handle, 0)) ) { - - if (tmsg->is_error) { - // tmsg here is likely a bounced message, possibly the result - // of a XMPP cancel code 503 (forbidden) from an attempt to - // send a message to a service that's not available on the - // public XMPP domain. Treat as irrecoverable. - osrfLogError(OSRF_LOG_MARK, - "WS XMPP error [%d] occured, exiting", tmsg->error_code); - shut_it_down(1); - return; - } - read_one_osrf_message(tmsg); message_free(tmsg); } @@ -599,6 +587,16 @@ static void read_one_osrf_message(transport_message* tmsg) { jsonObjectSetKey(msg_wrapper, "log_xid", jsonNewObject(tmsg->osrf_xid)); jsonObjectSetKey(msg_wrapper, "osrf_msg", jsonParseRaw(tmsg->body)); + if (tmsg->is_error) { + // tmsg->sender is the original recipient. they get swapped + // in error replies. + osrfLogError(OSRF_LOG_MARK, + "WS received XMPP error message in response to thread=%s and " + "recipient=%s. Likely the recipient is not accessible/available.", + tmsg->thread, tmsg->sender); + jsonObjectSetKey(msg_wrapper, "transport_error", jsonNewBoolObject(1)); + } + msg_string = jsonObjectToJSONRaw(msg_wrapper); // Send the JSON to STDOUT