socket.io-client-dart icon indicating copy to clipboard operation
socket.io-client-dart copied to clipboard

Socket client creating Multiple Connections to all backend servers

Open codersbet opened this issue 4 years ago • 2 comments

Below is the code for instantiating the socket. in my backend anytime a client connects I store the socketId as well as remove it when it disconnects. When I deploy the app on a physical device, it creates more than one WS connection.

    var namespace = "ns/rtm/socket";


    var url = "$_basePath/gw/service/$namespace";
    var path = "/gw/notifications-service/socket.io";

    var accessToken = await _storageService.getAuthToken();
    _socket = io(
        url,
        OptionBuilder()
            .setTransports(["websocket"])
            .disableAutoConnect()
            .enableReconnection()
            .setPath(path)
            .setQuery({"accessToken": accessToken})
            .build());

    _socket.nsp = "/$namespace";

    _socket.connect();

How do I prevent this behavior

codersbet avatar Aug 11 '21 16:08 codersbet

any update?

bsbilal avatar Sep 07 '21 08:09 bsbilal

Some problem, any idea how to solve it?

mhsystem avatar Sep 21 '21 18:09 mhsystem