ably-java
ably-java copied to clipboard
Add a log message after a WebSocket message is successfully sent
Originates from this suggestion: https://github.com/ably/ably-asset-tracking-android/issues/862#issuecomment-1365921656. When investigating that issue, we saw the following log lines:
18-12-22 19:48:58.572: io.ably.lib.transport.WebSocketTransport: send(); action = presence
18-12-22 19:48:58.589: io.ably.lib.transport.WebSocketTransport: send(): presence: {"action":14,"channel":"tracking:bo:22607777","count":0,"flags":0,"msgSerial":1,"presence":[{"data":"{\"rawLocations\":false,\"type\":\"PUBLISHER\"}","action":3}],"timestamp":0}
This is logged here:
https://github.com/ably/ably-java/blob/8c619a62e32483bea0b1be102541096654e430e4/lib/src/main/java/io/ably/lib/transport/WebSocketTransport.java#L110
We misinterpreted this log message as meaning that the client had successfully sent the WebSocket message, but it is actually emitted before the call to wsConnection.send(…)
. It would be useful to have a second log message which confirms that the data was successfully sent.
➤ Automation for Jira commented:
The link to the corresponding Jira issue is https://ably.atlassian.net/browse/SDK-3203
I'm not really clear about what client-side event you're aiming to log that signifies that the data was actually sent. If the call to write()
on the underlying socket OutputStream
returns without throwing an exception, it doesn't mean that the data has been sent - it just means that the TCP stack and other intervening layers haven't yet realised there's a problem. It definitely doesn't mean that the transport connection is intact and capable of delivering the data to the server.
Oh, I was definitely not aware of that! Is there a place I could find out more about this? man 2 write
wasn't hugely illuminating.
Yeah, I understand what Paddy meant now. We can close this one.