XSockets 5, disconnects all clients

43 views
Skip to first unread message

Kaj Mählqvist

unread,
Jun 15, 2016, 10:15:16 AM6/15/16
to XSockets.NET Developer forum
Hi, 

We just updated from XSockets 4.2.0 to 5.1.2 and started experiencing problems. When a client disconnect from the server, all other clients are also disconnected.

We ended up creating an entirely new project to test it out with minimal code, and are getting the same problem.

We're running:
XSockets.Owin.Host 5.1.2
XSockets.JsApi 5.0.1

With the following startup code:
using Microsoft.Owin;
using Owin;
using XSockets.Owin.Host;

[assembly: OwinStartup(typeof(Xsockets5Demo.Startup))]

namespace Xsockets5Demo
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            app.UseXSockets();
        }
    }
}

And the following client side code:
<script src="Scripts/XSockets.latest.min.js"></script>
<script>
    var conn = new XSockets.WebSocket('ws://localhost:52059', ['Test']);
    conn.onconnected = () => {
        log.innerHTML += 'Open';
    };

    conn.ondisconnected = () => {
        log.innerHTML += 'Disconnected';
    };
</script>


<div id="log"></div>

We then connected two clients (different browsers) and on one of them we executed "conn.webSocket.close()" in the console. Both clients were disconnected.

To be sure, we also tried downgrading the new test project to 4.2.0, and then it worked, only closing the one client.

Is there a change in version 5 we're missing or whats going wrong here?

Ulf Björklund

unread,
Jun 15, 2016, 10:31:10 AM6/15/16
to XSockets.NET Developer forum
Hi Kaj

Yes, The default behavior of v5 is to disconnect other client(s) with the same persistentId as the connecting client by default.
If you open one browser in incognito mode both clients will stay connected.

I suspect that you open another tab or window and then the same persistentid will be used from localstorage.

If you have some business logic etc in v4 that need to allow several users with the same persistenId let me know and we will help you.

Regards, Uffe

Ulf Björklund

unread,
Jun 15, 2016, 10:32:11 AM6/15/16
to XSockets.NET Developer forum
Btw, there is a new JavaScript API (in TypeScript) on the way as well. So if you are upgrading you might wanna use that as well... Still in pre-release, so just a heads up.

/Uffe

Kaj Mählqvist

unread,
Jun 15, 2016, 1:59:42 PM6/15/16
to XSockets.NET Developer forum
Ok, great, that explains it!

I'll definitely check out the Typescript version, thanks!

Kaj Mählqvist

unread,
Jun 16, 2016, 9:28:48 AM6/16/16
to XSockets.NET Developer forum
Finally got the time to try this out, but It's still giving me problems.

I bypassed the shared persistentId by simply always giving the user a new one and removing the old.

But the problem is still there.

function s4() {
        return Math.floor((1 + Math.random()) * 0x10000)
            .toString(16)
            .substring(1);
    }
    localStorage.removeItem('ws://localhost:53133');
    localStorage.removeItem('test');
    var conn = new XSockets.WebSocket('ws://localhost:53133?persistentId=' + s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4(), ['Test']);

I also tried the past example with Chrome + Chrome incognito and with Chrome + Firefox and got the problem then too.

Ulf Björklund

unread,
Jun 16, 2016, 9:50:06 AM6/16/16
to XSockets.NET Developer forum


 

Hi, Just tried it myself to make sure that things are not broken.
Worked as expected and all clients get connected.

Client:



Server:



Connections in Chrome:


Regards, Uffe



Ulf Björklund

unread,
Jun 16, 2016, 1:16:38 PM6/16/16
to XSockets.NET Developer forum
Important!
Found and patched a critical bug in the OWIN host.
5.3.0 will resolve this serious issue.
Client was randomly disconnected when using OWIN hosting!

A big thank you to Kaj that reported the issue!

Regards, Uffe
Reply all
Reply to author
Forward
0 new messages