Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vCard error response is not passed back to application as an event #9

Open
arthef opened this issue Oct 5, 2020 · 4 comments
Open
Assignees

Comments

@arthef
Copy link
Contributor

arthef commented Oct 5, 2020

I am attempting to retrieve contact's vcard as described in the issue: #6 (comment)

For some vcard request I am getting responses like this:
Request:

<iq to="[email protected]" id="JAiFXty3u8W0209Ro0EEDxvx" type="get">
  <vcard xmlns="urn:ietf:params:xml:ns:vcard-4.0"/>
</iq>

Response:

<iq to="[email protected]" xmlns="jabber:client" from="[email protected]" type="error" id="JAiFXty3u8W0209Ro0EEDxvx">
  <error type="cancel">
    <service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
  </error>
</iq>

In the library log I can see that the response was not correctly handler:

[EDT] 0:0:10,791 - Mon Oct 05 15:52:46 PDT 2020 [FINE] tigase.halcyon.core.connector.WebSocketConnector: Received: <iq to="[email protected]" xmlns="jabber:client" from="[email protected]" type="error" id="JAiFXty3u8W0209Ro0EEDxvx"><error type="cancel"><service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>
[EDT] 0:0:10,791 - Mon Oct 05 15:52:46 PDT 2020 [FINEST] tigase.halcyon.core.connector.WebSocketConnector: Received element <iq xmlns="jabber:client" from="[email protected]" to="[email protected]" id="JAiFXty3u8W0209Ro0EEDxvx" type="error"><error type="cancel"><service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>
[EDT] 0:0:10,791 - Mon Oct 05 15:52:46 PDT 2020 [FINEST] tigase.halcyon.core.eventbus.EventBus: Firing event ReceivedXMLElementEvent(element=XMLElement[name='iq' hash='929711258']) with 3 handlers
[EDT] 0:0:10,791 - Mon Oct 05 15:52:46 PDT 2020 [WARNING] tigase.halcyon.core.requests.RequestsManager: Error on processing response
tigase.halcyon.core.xmpp.XMPPException

There is an event fired ReceivedXMLElementEvent but it is not really useful in the application space. It would be bette to receive an error event in response to the vcard IQRequest.

@arthef
Copy link
Contributor Author

arthef commented Oct 5, 2020

Also, on the WARNING level the information printed out in the log is very brief providing no information what is this related to or what is this error about:

[EDT] 0:0:10,791 - Mon Oct 05 15:52:46 PDT 2020 [WARNING] tigase.halcyon.core.requests.RequestsManager: Error on processing response
tigase.halcyon.core.xmpp.XMPPException

It would be useful here to have some more context with the error message.

@bmalkow
Copy link
Contributor

bmalkow commented Oct 19, 2020

I added few tests, and for me it works correctly. Every time error response is correctly handled. Also exception during mapping response is correctly converted to Response Failure.
I improved logging a bit to show full stack trace if is provided.

@arthef
Copy link
Contributor Author

arthef commented Oct 26, 2020

Ok, in such a case how can I get the exact error from the response?

My code is like this:

vcardModule.retrieveVCard(jid).response { result ->
    result.onSuccess { vcard ->
        println("Received public vcard for $jid")
        handleVCardEvent(VCardUpdatedEvent(jid, vcard))
    }
    result.onFailure {
        println("Problem retrieving vCard for ${jid}, ${result.exceptionOrNull()}")
    }
}.send()

And all I get in the last println is this:

Problem retrieving vCard for [email protected], tigase.halcyon.core.requests.XMPPError

And the problem here is that this XMPPError does not say much. Whether the server no longer exists or something else. It would be useful to have more detailed information of why there was failure.

@arthef arthef reopened this Oct 26, 2020
@bmalkow
Copy link
Contributor

bmalkow commented Oct 27, 2020

Obtaining error details is common in Halcyon, because kotlin.Result class is used to return request result.
XMPPError is class containing all details of error response returned by server. In other cases, different exception will be provided:

vcardModule.retrieveVCard(jid).response { result ->
	result.onSuccess { vcard ->
		println("Received public vcard for $jid")
		handleVCardEvent(VCardUpdatedEvent(jid, vcard))
	}
	result.onFailure {
		when (it) {
			is tigase.halcyon.core.requests.XMPPError -> println("XMPP Error response: condition=${it.error}; text=${it.description}; responseStanza=${it.response}")
			else -> {
				println("Other error: $it")
				it.printStackTrace()
			}
		}
	}
}.send()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants