Android:Autobahn - Cancel requests/sendmessage on websocket

#1

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.

0 Likes

#2

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

···

Am 01.07.2014 15:35, schrieb Chaitanya Duse:

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.

0 Likes

#3

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

···

On Tue, Jul 1, 2014 at 7:32 PM, Tobias Oberstein 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.

  1. 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.

  1. 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

  1. Can anyone advice me on how to go about cancelling the requests from

the WebsocketWriter ? or a work around.

  1. 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+unsub...@googlegroups.com.

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.

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

0 Likes

#4

Hi Chaitanya,

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.

···

Am 01.07.2014 20:52, schrieb Chaitanya Duse:

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%2...@googlegroups.com>
        <mailto:autobahnws+_...@googlegroups.com
        <mailto:autobahnws%2...@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%2...@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>.
For more options, visit https://groups.google.com/d/optout.

0 Likes