Skip to content
This repository has been archived by the owner on Aug 15, 2022. It is now read-only.

Only tries to connect once #318

Closed
roa-nyx opened this issue Sep 2, 2019 · 2 comments
Closed

Only tries to connect once #318

roa-nyx opened this issue Sep 2, 2019 · 2 comments

Comments

@roa-nyx
Copy link

roa-nyx commented Sep 2, 2019

Version Number and Operating System(s):

Version 26 from the asset store (Mar 20, 2019), Windows 10 1903

Expected behavior:

Attempt to connect to server 10 times with 3 second delays between attempts. If server is unreachable trigger connectAttemptFailed event on UDPClient.

Actual behavior:

//Snippet from UDPClient.Connect
				Task.Queue(() =>
				{
					do
					{
						// Send the accept headers to the server to validate
						Client.Send(connectHeader, connectHeader.Length, Server.IPEndPointHandle);
						Thread.Sleep(3000);
					} while (!headerExchanged && IsBound && ++connectCounter < CONNECT_TRIES);

					if (connectCounter >= CONNECT_TRIES)
					{
						if (connectAttemptFailed != null)
							connectAttemptFailed(this);
					}
				});

Attempts to connect once, a SocketException occurs in UDPClient.ReadNetwork, which triggers Disconnect(true) which ultimately results in IsBound on the client to be set to false, which pre-empts any further connection attempts.

Additionally because the connectCounter never increments, the connectAttemptFailed is never triggered.

Steps to reproduce:

			comm = new UDPClient();
			comm.connectAttemptFailed += clientConnectFailed;
			comm.serverAccepted += clientConnected;
			comm.bindFailure += clientBindFailure;
			comm.Connect("127.0.0.1", 9789);

Make sure to create your own clientConnectFailed, clientConnected and/or clientBindFailure functions to use this test code.

#180 seems to indicate this is in some way related to IP parsing? But I'm not seeing how. In my case I'm trying to connect to 127.0.0.1.

@andreivreja
Copy link

Already fixed in #315

@roa-nyx
Copy link
Author

roa-nyx commented Sep 2, 2019

@andreivreja thanks for the quick response! I'll apply that patch to my code in the mean time.

@roa-nyx roa-nyx closed this as completed Sep 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants