1
Vote

connect event does not always fire

description

The connect event does not always fire, This is very undesirable can someone provide insight on this

comments

jstott wrote Jun 10, 2014 at 3:14 AM

Do you have anymore details to go on?

Is it random, under a particular situation, do you have a project that will reproduce the issue?

jasonjava2003 wrote Jun 10, 2014 at 10:52 AM

yes it is random. I have made some modifications using namespaces now and it seems (just seems) that the situation may be better, will give more details after more testing on this if needs be. But the issue is when I connect without using namespaces, sometimes the client does not receive the connect event. Yes I am working on a project

jasonjava2003 wrote Jun 10, 2014 at 11:19 AM

Try this code consistently for a long period of time an notice the behaviour

class Program
{
    static void Main(string[] args)
    {
        for (int i = 0; i < 10; i++)
        {

            Client socket1 = new Client("http://127.0.0.1:30145/");
            IEndPointClient chatEndPoint;
            socket1.On("connect", (fn) => {
                chatEndPoint = socket1.Connect("/chat");
                chatEndPoint.On("connect", (cn) => {
                    Console.WriteLine("\r\nSocket 1 Connected ...\r\n");
                });

            });
            socket1.Connect();
            Console.ReadLine();
            socket1.Close();
            Console.WriteLine("Press Enter to continue");
            Console.ReadLine();
        }
    }
}

jstott wrote Jun 11, 2014 at 1:16 AM

I would just connect with the namespace 'chat' from the get go:
You can see the same being done in the documentation at https://socketio4net.codeplex.com/wikipage?title=Namespace

As it is, your asking the current socket1 connection to (re)establish a new connection to the 'chat' namespace - immediately after you've connected to the '/' default namespace - that doesn't seem the ideal way to go? If you need multiple namespace connections - make distinct connections to where you want to be connected to. You can also use 'rooms' if you need to receive messages from a more general connection perspective - and join / leave as needed.
void direct_Example()
{
    var directSocket = new Client("http://127.0.0.1:3000/chat"); // url to the nodejs
    directSocket.Connect();
    directSocket.On("connect", (fn) =>
    {
        Console.WriteLine("\r\nConnected event...\r\n");
    });

    directSocket.On("traceEvent", (eventLog) =>
        {
            // do something with eventLog
        });

    directSocket.Emit("messageAck", new { hello = "papa" });
}

jasonjava2003 wrote Jul 7, 2014 at 3:03 PM

Hello, I am still experiencing similar problems with socketio4net, Have you had similar problems. If yes have you found a solution