Android:Autobahn - Cancel requests/sendmessage on websocket

106 views
Skip to first unread message

Chaitanya Duse

unread,
Jul 1, 2014, 9:35:48 AM7/1/14
to autob...@googlegroups.com
Scenario : 1. I have a list view, fetching data on the fly. Due to scrolling what data it might get could be stale.
2. When I implemented HTTP client using a thread , on scroll i would cancel all requests threadHandler.removeMessages(intwhat) so that no stale data was returned.
3. The autobahn Websocket API gives me option to sendmessage and receive its response asynchronously.
4. Can anyone advice me on how to go about cancelling the requests from the WebsocketWriter ? or a work around.
5. If the above description is not sufficient , I can elaborate more.

Tobias Oberstein

unread,
Jul 1, 2014, 10:02:57 AM7/1/14
to autob...@googlegroups.com
Am 01.07.2014 15:35, schrieb Chaitanya Duse:
> Scenario : 1. I have a list view, fetching data on the fly. Due to
> scrolling what data it might get could be stale.
> 2. When I implemented HTTP client using a thread , on scroll i would
> cancel all requests threadHandler.removeMessages(intwhat) so that no
> stale data was returned.
> 3. The autobahn Websocket API gives me option to sendmessage and receive
> its response asynchronously.

sendMessage() cannot be canceled. Upon invoking, it'll forward the
message to the background writer thread, and that thread will send out
the bytes on wire.

What you can do (at app level) is ignore any responses to the sent
message the application expects.

I guess this will be similar for HTTP: issuing a request, but ignore the
response. I don't see how you would actually cancel the request ..

/Tobias

> 4. Can anyone advice me on how to go about cancelling the requests from
> the WebsocketWriter ? or a work around.
> 5. If the above description is not sufficient , I can elaborate more.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Autobahn" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to autobahnws+...@googlegroups.com
> <mailto:autobahnws+...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

Chaitanya Duse

unread,
Jul 1, 2014, 2:52:10 PM7/1/14
to autob...@googlegroups.com
Thank you. 
I the HTTP thread implementation since I have control over the message queue  I can cancel the messages them before they are handled.
May be is should create a message queue for sending over websocket. But since SocketWriter already runs on another thread would want to create a mess of threads. Lets c. 
Ignoring the response would be simpler ..
Thank you,
Chaitanya



For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Autobahn" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/autobahnws/dt53nDtz09I/unsubscribe.
To unsubscribe from this group and all its topics, send an email to autobahnws+unsubscribe@googlegroups.com.

Tobias Oberstein

unread,
Jul 1, 2014, 4:02:58 PM7/1/14
to autob...@googlegroups.com
Hi Chaitanya,

Am 01.07.2014 20:52, schrieb Chaitanya Duse:
> Thank you.
> I the HTTP thread implementation since I have control over the message
> queue I can cancel the messages them before they are handled.
> May be is should create a message queue for sending over websocket. But
> since SocketWriter already runs on another thread would want to create a
> mess of threads. Lets c.

I can see what you mean. However, allowing a user to cancel sending of a
WebSocket message would:

1) require an outgoing message queue in the background writer. The
"queue" maintained between the foreground thread and the background
writer thread by Android itself isn't sufficient

2) require changes to the API of Autobahn, since sendMessage() would
need to return a handle to cancel the message.

3) would only work for WebSocket messages queued that haven't yet
started sending to TCP socket. As soon as the first byte is sent, there
isn't a sane way to cancel (since the WebSocket protocol doesnt have the
ability to abort a started message)

means: canceling on a sent message handle could fail (when sending has
already started or finished).

All of above seems quite heavy. And: I'm not really convinced that it
would apply to a lot of use cases. It only can cancel messages in the
time window between enqueue (sendMessage) and start of writing to socket
(which again is buffered inside the OS networking stack)

> Ignoring the response would be simpler ..

Definitely. Handling at the app level.

> Thank you,
> Chaitanya
>
>
> On Tue, Jul 1, 2014 at 7:32 PM, Tobias Oberstein
> <tobias.o...@gmail.com <mailto:tobias.o...@gmail.com>> wrote:
>
> Am 01.07.2014 15:35, schrieb Chaitanya Duse:
>
> Scenario : 1. I have a list view, fetching data on the fly. Due to
> scrolling what data it might get could be stale.
> 2. When I implemented HTTP client using a thread , on scroll i would
> cancel all requests threadHandler.removeMessages(__intwhat) so
> that no
> stale data was returned.
> 3. The autobahn Websocket API gives me option to sendmessage and
> receive
> its response asynchronously.
>
>
> sendMessage() cannot be canceled. Upon invoking, it'll forward the
> message to the background writer thread, and that thread will send
> out the bytes on wire.
>
> What you can do (at app level) is ignore any responses to the sent
> message the application expects.
>
> I guess this will be similar for HTTP: issuing a request, but ignore
> the response. I don't see how you would actually cancel the request ..
>
> /Tobias
>
> 4. Can anyone advice me on how to go about cancelling the
> requests from
> the WebsocketWriter ? or a work around.
> 5. If the above description is not sufficient , I can elaborate
> more.
>
> --
> You received this message because you are subscribed to the Google
> Groups "Autobahn" group.
> To unsubscribe from this group and stop receiving emails from
> it, send
> an email to autobahnws+unsubscribe@__googlegroups.com
> <mailto:autobahnws%2Bunsu...@googlegroups.com>
> <mailto:autobahnws+_...@googlegroups.com
> <mailto:autobahnws%2Bunsu...@googlegroups.com>>.
> For more options, visit https://groups.google.com/d/__optout
> <https://groups.google.com/d/optout>.
>
>
> --
> You received this message because you are subscribed to a topic in
> the Google Groups "Autobahn" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/__topic/autobahnws/dt53nDtz09I/__unsubscribe
> <https://groups.google.com/d/topic/autobahnws/dt53nDtz09I/unsubscribe>.
> To unsubscribe from this group and all its topics, send an email to
> autobahnws+unsubscribe@__googlegroups.com
> <mailto:autobahnws%2Bunsu...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/__optout
> <https://groups.google.com/d/optout>.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Autobahn" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to autobahnws+...@googlegroups.com
> <mailto:autobahnws+...@googlegroups.com>.
Reply all
Reply to author
Forward
0 new messages