@On close triggering multiple times

9 views
Skip to first unread message

Ben Kuhl

unread,
May 24, 2013, 3:55:36 PM5/24/13
to portal_...@googlegroups.com
I'm unsure as to the exact cause here.  If I open my browser, it triggers open() correctly.

If I refresh the page, I would expect the events:
  1. Close
  2. Open
But instead, it triggers close twice...
  1. Close
  2. Open
  3. Close
My socket handler:

abstract public class SocketHandler {

    @Wire
    Room socket;

    @On
    public void open(Socket socket) {
        getSocket().add(socket);
    }

    @On
    public void close(Socket socket) {
        getSocket().remove(socket);
    }

    public Room getSocket() {
        return socket;
    }

I'm integrating with AngularJS...:
                $rootScope.socket = portal.open(socketUrl+slug, {
                    transports: ['ws', 'sse'],
                    notifyAbort: true
                });

Ben Kuhl

unread,
May 25, 2013, 1:51:44 PM5/25/13
to portal_...@googlegroups.com
What ends up happening here is that there isn't an open socket.  So my Java app can't send data to the browser.  The browser is able to make requests via the socket to the java side and get a reply - I guess because it opens a new connection.

Any thoughts on what might be the cause?

Ben Kuhl

unread,
May 25, 2013, 1:54:10 PM5/25/13
to portal_...@googlegroups.com
Here's my POM.xml:


        <dependency>
            <groupId>com.github.flowersinthesand</groupId>
            <artifactId>portal-core</artifactId>
            <version>0.6</version>
        </dependency>
        <dependency>
            <groupId>com.github.flowersinthesand</groupId>
            <artifactId>portal-spring</artifactId>
            <version>0.6</version>
        </dependency>
        <dependency>
            <groupId>com.github.flowersinthesand</groupId>
            <artifactId>portal-atmosphere</artifactId>
            <version>0.6</version>
        </dependency>
        <dependency>
            <groupId>org.atmosphere</groupId>
            <artifactId>atmosphere-runtime</artifactId>
            <version>1.0.12</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

Donghwan Kim

unread,
May 26, 2013, 10:59:55 AM5/26/13
to portal_...@googlegroups.com
Let me know how it goes.

-- Donghwan


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

Ben Kuhl

unread,
May 28, 2013, 8:05:05 AM5/28/13
to portal_...@googlegroups.com
The issue I'm experiencing isn't a second connection being opened, it's that once the page is refreshed it closes the connection that was just opened.  So it's firing close() when it shouldn't be.

Ben Kuhl

unread,
May 28, 2013, 8:18:53 AM5/28/13
to portal_...@googlegroups.com
To be more clear... when I visit my URL, it opens a connection.  When I close that tab it closes the connection - which is correct.  If I open a new tab and navigate to the page again, it'll Open/Close the connection when it should just be opening the connection.

Ben Kuhl

unread,
May 28, 2013, 8:26:39 AM5/28/13
to portal_...@googlegroups.com
This seems it may have been my fault as I made a change and the error went away.  I had a section where I was manually closing the Room to ensure everything was disconnected.
Reply all
Reply to author
Forward
0 new messages