SendAndWait works only the first time
See original GitHub issueHi jchristin, today I’m trying to upgrade my program to use the new 4.8.1 version of WatsonTcp from the far 4.1.5 one that always worked finely for me.
I’ve noticed that now it’s very very quick to send messages, with my old 4.1.5 version i could send up to 65 messages per second (async messages), and now with the 4.8.1 i can reach the outstanding speed of 1500 msg/sec!! so awesome!
But sadly thre is also a problem… 😦 If I call on client a SendAndWait it works fine, but only the first time, if then I call another SendAndWait this hangs until the timeout exception…
this is my sample client code:
cli = new WatsonTcpClient("localhost", 23456);
cli.Events.ServerConnected += Cli_ServerConnected;
cli.Events.MessageReceived += Cli_MessageReceived;
cli.Settings.DebugMessages = false;
cli.Connect();
cli.Send("Single message from client-1");
cli.Send("Single message from client-2");
cli.Send("Single message from client-3");
SyncResponse srsp = cli.SendAndWait(30000, "1");
Console.WriteLine(Encoding.UTF8.GetString(srsp.Data));
srsp = cli.SendAndWait(30000, "1"); <<----- this row hangs and after 30 secondt fires a TimeoutException
Console.WriteLine(Encoding.UTF8.GetString(srsp.Data));
and this is the server side that works only for the first time, for the second SendAndWait this is never fired
private static SyncResponse SyncRequestReceived(SyncRequest req)
{
Console.WriteLine($"Syncrequest received from {req.IpPort}: {Encoding.UTF8.GetString(req.Data)}");
SyncResponse ret;
int delay = 0;
int.TryParse(Encoding.UTF8.GetString(req.Data), out delay);
if (delay == 0)
delay = 1;
System.Threading.Thread.Sleep(1000*delay);
ret = new SyncResponse(req, $"Long work done :-) {delay}");
Console.WriteLine("Syncrequest completed");
return ret;
}
many thanks in advance for your great work! Michele
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (7 by maintainers)
Top GitHub Comments
4.8.2 works for me.
I don’t know if this is another issue, but on 4.8.1, when I do WatsonTcpServer.Send (or SendAsync) multiple messages from the server, the client MessageReceived is only fired once, I’ve rolled back to 4.8.0 and it fires for every message.