Results 1 to 10 of 10
  1. #1
    Senior Member
    Join Date
    Jul 2013
    Posts
    39

    HTTP-Polling reconnect

    Hi,

    I wrote a web app for mobile using PhoneGap, LS javascript client. When testing on my HTC mobile (Android 2.3) with wifi, I got several server status changed events: CONNECTING --> CONNECTED:STREAM-SENSING --> CONNECTED:HTTP-STREAMING --> CONNECTED:HTTP-POLLING. Is it normal behavior of LS client?

    I still received snapshot of subscribed item in DISTINCT mode (but I don't know which protocol is used to get that data). I guess LS client soon disconnects to server after received full data since last protocol is HTTP-POLLING.

    When LS client re-connect to server to subscribe/unsubscribe for other item, it receive AGAIN snapshot of the first item. I don't expect that. Is it LS error or my fault?

    Thanks & regards,

  2. #2
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    I wrote a web app for mobile using PhoneGap, LS javascript client. When testing on my HTC mobile (Android 2.3) with wifi, I got several server status changed events: CONNECTING --> CONNECTED:STREAM-SENSING --> CONNECTED:HTTP-STREAMING --> CONNECTED:HTTP-POLLING. Is it normal behavior of LS client?
    It may happen but is obviously not the standard behavior: it means that some fallback mechanism was triggered. When everything is ok the last status you get is CONNECTED:HTTP-STREAMING.


    • How long does the client remain in the HTTP-STREAMING status before switching to HTTP-POLLING?
    • What happens if you visit our online demo on the phone browser eg.: http://demos.lightstreamer.com/ChatDemo/ touch the top left S to read the status)
    • Can you please attach a server log showing your phonegap session?


    When LS client re-connect to server to subscribe/unsubscribe for other item, it receive AGAIN snapshot of the first item. I don't expect that. Is it LS error or my fault?


    If the client does not move to a DISCONNECTED status and if you don't manually unsubscribe and re-subscribe the item, you should not receive a second snapshot. This might also be clarified by the log so I would take a step at a time and start with that.


  3. #3
    Senior Member
    Join Date
    Jul 2013
    Posts
    39
    I attach here my server log. I split it into 2 parts since it's size is too big.

    The first part is logs from server starting --> metadata & data adapter connect --> I open a test web page in desktop browser which contains LS client connect to server using websocker protocol. They all works fine.

    The second part is log for my mobile web app (html + javascript + phonegap) running on my HTC device (android 2.3 factory settings). In my app log, last connected status is Polling and still receive AGAIN snapshot when reconnected.

    How long does the client remain in the HTTP-STREAMING status before switching to HTTP-POLLING?
    Less than 1 second.


    What happens if you visit our online demo on the phone browser eg.:
    http://demos.lightstreamer.com/ChatDemo/ touch the top left S to read the status)
    It shows: "Connected over HTTP in Polling mode".
    Attached Files Attached Files

  4. #4
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    Hi,


    as per the POLLING issue, looks like something between your phone and the server is preventing the streaming connection to flow as expected thus the client willingly switches to polling in order to get the data. Do you have some kind of proxy/firewall/balancer between the phone and the server?

    as per the double snapshot, I see that you start your client with two subscriptions:

    11:22:58,805 --> /lightstreamer/control.js --> LS_mode=DISTINCT&LS_id=MI.HO.1&LS_schema=f0%20f1%20f2%20f3%20f4%20f5%20f6%20f7%2 0f8%20f9&LS_snapshot=true&LS_table=1&LS_req_phase=763&LS_win_phase=31&LS_op=add&LS_uni que=1&LS_session=S7077c6788e928139T2258657& on "Lightstreamer HTTP Server" from 192.168.1.100:47360
    11:22:58,896 --> /lightstreamer/control.js --> LS_mode=MERGE&LS_id=M.HO.1&LS_schema=f4%20f5%20f6%20f7%20f8%20f10%20f12%20f1 4%20f15%20f16%20f17%20f18%20f32%20f33%20f44%20f45% 20f62%20f65&LS_snapshot=true&LS_table=2&LS_req_phase=764&LS_win_phase=31&LS_op=add&LS_uni que=2&LS_session=S7077c6788e928139T2258657& on "Lightstreamer HTTP Server" from 192.168.1.100:47360


    at this point you should have received two snapshots: one for the first subscription and one for the second one.


    after a while you unsubscribe and resubscribe one of the two: is it here that you saw the duplicated snapshot coming through?

    11:35:08,834 --> /lightstreamer/control.js --> LS_table=2&LS_req_phase=764&LS_win_phase=31&LS_op=delete&LS_unique=4&LS_session=S7077c6788e928139T22586 57&
    11:35:24,126 --> /lightstreamer/control.js --> LS_mode=MERGE&LS_id=M.HO.1&LS_schema=f4%20f5%20f6%20f7%20f8%20f10%20f12%20f1 4%20f15%20f16%20f17%20f18%20f32%20f33%20f44%20f45% 20f62%20f65&LS_snapshot=true&LS_table=3&LS_req_phase=765&LS_win_phase=31&LS_op=add&LS_uni que=5&LS_session=S7077c6788e928139T2258657&


    If so that's the intended behavior, if you do not want the snapshot on the third subscription you should set setRequestedSnapshot to "no".
    If not please set LightstreamerLogger.requests and LightstreamerLogger.connections back to INFO and LihtstreamerLogger.connections.push to DEBUG. Then send a log specifying at what time you saw the second snapshot

    HTH

  5. #5
    Senior Member
    Join Date
    Jul 2013
    Posts
    39
    Hi,

    after a while you unsubscribe and resubscribe one of the two: is it here that you saw the duplicated snapshot coming through?
    No, it's not.

    I attach new log here.

    My operation flows:
    1. Start server
    2. Start adapters & connect to server
    3. Open test web page in desktop browser to check. It's ok (websocket mode).
    4. Run mobile app (html + javascript + phonegap + android 2.3)
    i. Connect to server (Polling mode)
    ii. Subscribe 2 items: MERGE M.HO.1 and DISTINCT MI.HO.1 --> ok, received data
    iii. Unsubscribe item MERGE M.HO.1
    iv. Subscribe (again) MERGE M.HO.1 --> ok, received data
    v. Unsubscribe (again) MERGE M.HO.1 --> DISCONNECTED --> retry connection --> receive snapshot of item DISTINCT MI.HO.1

    From step (iv) to step (v), I press BACK button on mobile device (actually, it goes back to do step iii). There is only single global instance of LS client on my app.

    Regards,
    Attached Files Attached Files
    Last edited by tvhnet2013; August 30th, 2013 at 06:48 PM.

  6. #6
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    Hi,

    the snapshot behavior described is correct: when the client enter the DISCONNECTED status it has lost its session and thus upon reconnection a new snaphot is received. You could disable the snapshot when the client becomes disconnected to not receive it again but then you'll have no guarantees that you've lost some data while you were disconnected.

    About the http polling issue, I think that there is something blocking the streaming. Do you have any antivirus or the like installed on your mobile?
    Can you try to connect to our demo using 3g instead of using your wifi?

  7. #7
    Senior Member
    Join Date
    Jul 2013
    Posts
    39
    Hi,

    1. Why does it enter DISCONNECTED state whenever I press BACK button on my mobile? That does not happend if I test on desktop Chrome browser.

    2. About HTTP polling issue: I make "hard-reset" to factory settings on my mobile. There is no antivirus or firewall or apps like that installed. It still uses HTTP polling method when I browser to demos.lightstreamer.com/ChatDemo via both wifi or GPRS.

    My mobile model is HTC Desire S S510e. Android version is 2.3.5.

  8. #8
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    1) Do you use #s to navigate your app?
    The default gingerbread browser would break the currently active connections when pressing the back button. I fear we can't prevent that.

    2) GPRS may be slow enough for the polling timeout to be triggered
    I do not really understand what can be the root cause of your issue, I can see it streaming on a very slow Huawei Ideos and on a faster Desire HD both running gingerbread.
    Any chance to test it on a different wifi or on a different smartphone to understand if the issue is on the mobile or on the network?

  9. #9
    Senior Member
    Join Date
    Jul 2013
    Posts
    39
    1. Yes, I do. Is there any other android / ios version that acts the same?

    2. I suspect of my phone. I will investigate more and let you know result.

    Thank you,

  10. #10
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    1) Not sure about iOS, I know that mobile chrome and the jelly bean browser are not affected. I don't remember about ICS and don't have one at hand right now

 

 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT +1. The time now is 12:02 PM.