HelpKRelay reconnect handler bug

Posts 1–9 of 9 · Page 1 of 1
KRelay reconnect handler bug
Whenever I connect to a portal with multiple clients all in about a second, only one of them makes it into the portal and the others go to nexus or get disconnected. I think KRelay's reconnect handler might be messing up the portal keys, or maybe it has trouble reading/writing to files in the reconnect folder since multiple threads are trying to read the file at once.
Please solve it asap, any help appreciated.
As a first note make sure you are using the most up to date k-relay, preferably from KrazyShank/Kronks as older versions do not support multiple clients. Are you trying to enter the portal on each client one after another. This messes up the reconnect packet for me. If you wait for the client to load and then enter the portal on the next client does this work for you?
Quote Originally Posted by DonJuan13 View Post
As a first note make sure you are using the most up to date k-relay, preferably from KrazyShank/Kronks as older versions do not support multiple clients. Are you trying to enter the portal on each client one after another. This messes up the reconnect packet for me. If you wait for the client to load and then enter the portal on the next client does this work for you?
Yes I downloaded the krelay with version i think 27.7.3/4.
And thanks for the suggestion, it works when I wait for one client to connect.
Sometimes i get the error when krelay cant access currentservers.txt because it is being used by another process/thread, and I wonder if using files are required.
Quote Originally Posted by tmwilliamlin168 View Post
I wonder if using files are required
I'm not exactly sure what you mean by this. I may be misinformed but k-relay does not write to currentservers.txt. Those servers are not the realm or portal servers/keys. I think this error is incurred when the game is updated and k-relay is run with the old packets.xml. As long as you keep that up to date you shouldn't have a problem with the server text file. Correct me if I am wrong.
Quote Originally Posted by DonJuan13 View Post
I'm not exactly sure what you mean by this. I may be misinformed but k-relay does not write to currentservers.txt. Those servers are not the realm or portal servers/keys. I think this error is incurred when the game is updated and k-relay is run with the old packets.xml. As long as you keep that up to date you shouldn't have a problem with the server text file. Correct me if I am wrong.
From github.com/TheKronks/K_Relay/blob/ca2c36af13b67fcc393acc13e031a456a3c3a052/K_Relay/Util/ConClient.cs (one of krelay's class sources) (I hope this link is allowed):
Code:
public void Save(string text)
{
	if (_toConnect.PlayerData.Name == "") return;

	string path = Directory.GetCurrentDirectory();
	path += "\\Plugins\\";
	Directory.CreateDirectory(path);
	path += "CurrentServers.txt";
	if (!File.Exists(path))
	{
		File.WriteAllLines(path, new string[] { String.Empty });
	}
	string[] lines = File.ReadAllLines(path);
	bool found = false;
	for (int i = 0; i < lines.Length; i++)
	{
		string line = lines[i];
		string[] values = line.Split(',');
		if (values[0] == _toConnect.PlayerData.Name)
		{
			found = true;
			lines[i] = _toConnect.PlayerData.Name + "," + text + "," + lastRealm + "," + lastRealmIP + "," + lastRealmTime;
		}
	}
	File.WriteAllLines(path, new string[] { String.Empty });
	File.WriteAllLines(path, lines);
	if (!found)
	{
		using (StreamWriter file = File.AppendText(path))
		{
			file.WriteLine(_toConnect.PlayerData.Name + "," + text + "," + lastRealm + "," + lastRealmIP + "," + lastRealmTime);
		}
	}
}
When I open currentservers.txt, I see character name, server name, realm name, ip address, and a number that I think represents some sort of time.

Oh, and to answer your question, I mean that do they need to access files, or do they have an alternative for using files, because multiple processes accessing a file at the same time causes problems
Make sure to run K-Relay as administrator. Other than that it should have no problems accessing the file.
I created my own external reconnect handler, without using files.
However, I still can't use portals at the same time without messing up the reconnect packets.
Have you tried the PluginUtils.Delay method? Since waiting to use the portals on each client worked for you maybe it would work to just simply delay the sending of each Packet. I assume you store your clients in some sort of dictionary or array (i.e. _clients) so maybe something to the effect of:
Code:
foreach (cl in _clients) {
    PluginUtils.Delay(1500, () =>
    {
        SendReconPacket(cl); //insert magical method for sending the reconnect packet
    }
}
Or perhaps just wait for the HELLO packet of the previous client before sending the next reconnect packet.

If you want to send me the code I can try to better help. (Sorry for crappy syntax. Mainly Java developer + not on main computer = fakeittillimakeit)

In addition can you print out each of the reconnect packets that you send and see if all the values seem to be correct.
Quote Originally Posted by DonJuan13 View Post
Have you tried the PluginUtils.Delay method? Since waiting to use the portals on each client worked for you maybe it would work to just simply delay the sending of each Packet. I assume you store your clients in some sort of dictionary or array (i.e. _clients) so maybe something to the effect of:
Code:
foreach (cl in _clients) {
    PluginUtils.Delay(1500, () =>
    {
        SendReconPacket(cl); //insert magical method for sending the reconnect packet
    }
}
Or perhaps just wait for the HELLO packet of the previous client before sending the next reconnect packet.

If you want to send me the code I can try to better help. (Sorry for crappy syntax. Mainly Java developer + not on main computer = fakeittillimakeit)

In addition can you print out each of the reconnect packets that you send and see if all the values seem to be correct.
I kind of already solved the issue by waiting for the proxy client_connected listener to see if the client connected or not before sending another useportalpacket (sent when you use a portal).

I'm good with my plugin now, it's just that I want to make this a tiny bit faster, and hopefully I can gain some experience with krelay during this process.

However, by going through the code, I think the reconnect packets are fine, it's just that the way krelay is set up makes it unable to process two reconnects at the same time.

What seems to be happening is that krelay modifies the reconnect packets to make them connect to localhost (this part is fine). The first client connects, and the variable Proxy.defTempServer (which i think stands for default temporary server) has the ip address 54.168.179.62 (one of the servers). When the second client connects while the first has not finished the variable is not the same (the ip becomes the nexus ip), which might be causing the problem. Every time if I wait for the first client to finish, the variable is always the same.

The reconnect packets are same except for their time and i think key.

Maybe kronks might know more, just don't know how to contact him.

P.S. I'm mostly java too, can't really find a java proxy.
Posts 1–9 of 9 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?