question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Help/Problem timeout sendandwait

See original GitHub issue

Hello,

I really need help with the Server/Client… My Configuration of the Server is

public static class AsyncServer
    {
        private static string serverIp = "10.0.0.46";
        public static int ServerPort = 9000;
        private static bool useSsl = false;
        private static WatsonTcpServer server = null;
        private static string certFile = "";
        private static string certPass = "";
        private static bool debugMessages = false;
        private static bool acceptInvalidCerts = true;
        private static bool mutualAuthentication = true;

        public static void ConfigServer()
        {
            server = new WatsonTcpServer(serverIp, ServerPort);
            server.ClientConnected += ClientConnected;
            server.ClientDisconnected += ClientDisconnected;
            server.MessageReceived += MessageReceived;
            server.SyncRequestReceived = SyncRequestReceived;
            // server.PresharedKey = "0000000000000000";
            // server.IdleClientTimeoutSeconds = 10;
            logger.Info("Server configuration done");
        }

        public static void StartServer()
        {
            Task serverStart = server.StartAsync();
        }

My client:

public static class AsyncClient
    {
        public static  string ServerIp { get; set; }
        public static int ServerPort { get; set; }
        private static bool useSsl = false;
        private static string certFile = "";
        private static string certPass = "";
        private static bool debugMessages = false;
        private static bool mutualAuthentication = true;
        private static WatsonTcpClient client = null;
        private static string presharedKey = null;

        public static void ConfigClient()
        {
            client = new WatsonTcpClient(ServerIp, ServerPort);
            client.ServerConnected += ServerConnected;
            client.ServerDisconnected += ServerDisconnected;
            client.MessageReceived += MessageReceived;
            client.SyncRequestReceived = SyncRequestReceived;
        }

        public static void StartClient()
        {
            try
            {
                Task startClient = client.StartAsync();
            }
            catch (Exception ex)
            {
                logger.Error("Could not connect to server: {0} Port: {1}", ServerIp, ServerPort);
            }
        }

I want to SendAndWait:

public static void SendAndWait()
        {
            int timeoutMs = 20000;
            string userInput = "testingstring";
            try
            {
                SyncResponse resp = client.SendAndWait(timeoutMs, userInput);
                if (resp.Metadata != null && resp.Metadata.Count > 0)
                {
                    logger.Info("Metadata:");
                    foreach (KeyValuePair<object, object> curr in resp.Metadata)
                    {
                    }
                }
            }
            catch (Exception e)
            {
            }
        }

At server side

private static SyncResponse SyncRequestReceived(SyncRequest req)
        {
            if (req.Metadata != null && req.Metadata.Count > 0)
            {
                logger.Info("Metadata:");
                foreach (KeyValuePair<object, object> curr in req.Metadata)
                {
                    logger.Info("  " + curr.Key.ToString() + ": " + curr.Value.ToString());
                }
            }
            Dictionary<object, object> retMetadata = new Dictionary<object, object>();
            retMetadata.Add("foo", "bar");
            retMetadata.Add("bar", "baz");

            return new SyncResponse(req,retMetadata, "Here is your response!");
        }

It is the same sample as stored in git. If i download the current version from git and test ist, everything is fine. But if i do the same thing with the code above I always get the timeout exception (no msg received after timeout) If i debug then the server recognize the incomming msg and work and “send” back.

Can anybody help me?

nice greetings phil

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
philipphagen87commented, Mar 27, 2020

Sorry for the late answer… i fixed my problem… it was my architecture! thanks for support…

0reactions
jchristncommented, Mar 27, 2020

Awesome thanks @philipphagen87 please let me know if I can help in the future.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to differentiate null response from timeout using Axon ...
I am sending a command and expecting a result via CommandGateway.sendAndWait(Object command, long timeout, TimeUnit unit) method :
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found