How to reconnect APE without refreshing the page?

34 views
Skip to first unread message

Nicolas

unread,
Jun 21, 2016, 6:12:30 PM6/21/16
to APE Project
Hi all,

I store every command and if they have not been acknowldedged by the server, I resend them.

In my latest tests, I use a program called Clumsy to simulate Internet connection issues.

If connection is cut for a short period, everything falls back into place nicely and I thought that everything was working great!

However, if I cut connection for longer than 10-20 seconds (I am not sure how long exactly), I just realized that the system does not get back on track. The connection seems to be broken for good.

So my question is simple: what is the correct way to handle the problem? How do I reset a connection to APE (with session) without refreshing the page (I can't)?

I have looked at this.reset() which may be the appropriate way. But it does not work for me as on the server I don't accept two sessions for the same user on the server.

Also I have called this.core.initialize(this.core.options);
But then I end up receiving duplicated command, probably exactly like if I had several tabs open.

So in short, I can't find the proper way to start with a new fresh connection to the server, with the same session without refreshing the page. Surely there must be a way.

Thanks for helping!

Pablo Tejada

unread,
Jun 21, 2016, 10:52:46 PM6/21/16
to APE Project
Hey again,

Do note that user sessions and sockets are pruned from the APE server automatically. So probably when you attempt to reconnect the session has already been expired. When I built ApePubSub a few years ago i remember I had to create a custom server command to handle restoring the session. From what I can remember the first command that requires a session will automatically attempt to resume the session. On success, an IDENT and LOGIN raw will be received in the client.

--
--
You received this message because you are subscribed to the Google
Groups "APE Project" group.
To post to this group, send email to ape-p...@googlegroups.com
To unsubscribe from this group, send email to
ape-project...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/ape-project?hl=en
---
APE Project (Ajax Push Engine)
Official website : http://www.ape-project.org/
Git Hub : http://github.com/APE-Project/

---
You received this message because you are subscribed to the Google Groups "APE Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ape-project...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--

Sincerely,

Pablo Tejada

From Mobile

Nicolas

unread,
Jun 22, 2016, 4:36:02 AM6/22/16
to APE Project
Hi Pablo,

I can see that APE disconnects players after 45 seconds. Actually, my players lose their current game when this happens. I suspect this is what you are talking about when saying APE prunes sessions and sockets.
So what I am interested in is the period between 10-20 seconds and 45 seconds. I manage to reconnect in the first 10 seconds, but not later.

Other than that, I have a few questions.

1) Does the event apeDisconnect work? I have tried quickly yesterday evening, but it did not seem to be raised ever.

2) I told you I receive duplicated (4-5 times actually) raws from the server after calling this.core.initialize(). 
Are there really several communication channels open at that time? Are there duplicates on the client or on the server? How can I see where the duplication takes place? In the APE client, I can't seem to see related to that when I go through the hierarchy of the object.
If I could find these duplicates, maybe I could just delete the old ones and go on from there.

3) I use Websockets at the moment. Do you think the default mode instead would behave differently?

Nicolas.

Nicolas

unread,
Jun 22, 2016, 5:58:12 AM6/22/16
to APE Project
I'll reply to question 1) myself.

With Websockets, apeDisconnect is never fired.
With default protocol however, it is fired between 15 and 30 seconds after cutting the connection.

Also noticeable:
With default protocol, I also have no issue with duplicated content.

So I am starting to wonder if I should not simply go back to default protocol. Websockets does not seem to work as I would like it to work. I have not yet found a way to reconnect softly after the communication is broken more than 10-20 seconds.

So new questions:

4) Is Websocket really much better than default protocol? Is is supposed to be faster? More reliable? Would you advise me to go back to default protocol if it is easier to make it work?

Thanks!

Pablo Tejada

unread,
Jun 22, 2016, 8:20:06 AM6/22/16
to APE Project

I am not sure about the apeDisconnect event. I am more familiar with the APE protocol then with JSF itself. Are you listening for this event in a channel or the client?

Since the APE backend is written in C I can only assume how some parts work. If you try to reconnect  to the same frequency then APE will flush a queue of raws that have been waiting to be sent. This behavior was only experienced with websockets. When attempting to reconnect a new frequency should be used, as if a new browser tab was opened.

With that been said i dont think JSF was built to resume connectivity the way you are trying to. New connection, new APE client. 

Pablo Tejada

unread,
Jun 22, 2016, 8:35:52 AM6/22/16
to APE Project

Each protocol works different. The websocket transport is suppose to be better for your app and the server itself. Websockets uses a single bi-directional connection while long polling makes a new connection on every raw.

Even the lifespan of a socket might be different for the websocket transport. It can be 20 instead of 45 seconds.

I had a demo to compare the two but is not working

http://ptejada.com/script/ApePubSub/demo/payloadTest/

Reply all
Reply to author
Forward
0 new messages