socket.io-unity icon indicating copy to clipboard operation
socket.io-unity copied to clipboard

Client Socket Options

Open oofaustoo opened this issue 7 years ago • 1 comments

I will apologize in advance for the "newbie" question, but I am in a steep learning curve for Unity, C#, socketIO and node.js, BUT I would like to configure some client socket options when I create my IO.Socket object per:

var socket = IO.Socket("http://localhost:3000");

I see that there are available options:

    public bool Reconnection;
    public int ReconnectionAttempts;
    public long ReconnectionDelay;
    public long ReconnectionDelayMax;
    public long Timeout;
    public bool AutoConnect

But alas I am unable to find the magic incantation necessary.

I suspect it's in the realm of:

var socket = IO.Socket("http://localhost:3000", { some values in a dictionary });

??

Many thanks in advance if anyone is still around and listening.

oofaustoo avatar Jan 20 '18 23:01 oofaustoo

To answer my own question:

		IO.Options sockopts = new IO.Options();

		sockopts.Reconnection = true;
		sockopts.ReconnectionAttempts = 10000;
		sockopts.ReconnectionDelay = 10000;
		sockopts.ReconnectionDelayMax = 10000;
		sockopts.Timeout = 500;
		sockopts.AutoConnect = true;

		socket = IO.Socket (serverURL, sockopts);

That works fine, but my client appears to only be attempting a single reconnection...

When I stop my node.js server:

Disconnected from server (EVENT_DISCONNECT) Attempting reconnect (EVENT_RECONNECT_ATTEMPT) Reconnecting (EVENT_RECONNECTING)

I get nothing after this... Shouldn't the client attempt ReconnectionAttempts before giving up?

oofaustoo avatar Jan 21 '18 00:01 oofaustoo