<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Client can not connect to the server(may be a bug)]]></title><description><![CDATA[<p dir="auto">Hi victor,<br />
    In netxmns 1.1.6. The server is normally work at most time, But sometimes I can not connect server by my own client that I write with java api. Then I try to connect it by the official console,but it also failure,it said:Unable to connect:Request timed out.. ----but the server is keep success get the agent DCI date and write it to database.<br />
    After I restart the server,both my own client and official console can connect to the server. So I think That problem may not cause by my own client.</p>
<p dir="auto">----------------------------------------------<br />
So I use the GDB to debug it. I found that problem cause by the resource competition with the lock:</p>
<p dir="auto">In Client.cpp: ClientListener()---&gt;if (!RegisterSession(pSession))<br />
When the ClientSessioncreate create , it will register. But the "m_rwlockSessionListAccess" is lock. So the client cann't get the response by the client,and It disappear "Unable to connect:Request timed out."</p>
<p dir="auto">Who get the "m_rwlockSessionListAccess" and not release it?<br />
I found that it is in the client.cpp--&gt;NotifyClientSessions()--&gt;m_pSessionList[i]-&gt;notify(dwCode, dwData); the code is stop in this and it can not continue to run on,so it do not release the "m_rwlockSessionListAccess".</p>
<p dir="auto">How did the notify() is block?<br />
notify()--&gt;sendMessage()--&gt;SendEx()--&gt;MutexLock(mutex, INFINITE)--&gt;send(nSocket, ((char *)pBuff) + (nSize - nLeft), nLeft, nFlags);<br />
The send() is block(I do not know why).so the lock "m_mutexSocketWrite" is keep locking.</p>
<p dir="auto">In a world:<br />
Send() is block--&gt; "m_mutexSocketWrite" can not release--&gt;"m_rwlockSessionListAccess" can not release--&gt;client:Request timed out.<br />
-------------------------------------------------------------------</p>
<p dir="auto">The above is just my speculated, It may need you to check it againg.<br />
Finally,How I should solve that problem?  My friend ask me to set the send() work with unblock(It is block default). By I think it may cause other problem. Is it any good idea?<br />
Thanks.</p>
]]></description><link>https://forum.netxms.org/topic/1761/client-can-not-connect-to-the-server-may-be-a-bug</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 10:21:29 GMT</lastBuildDate><atom:link href="https://forum.netxms.org/topic/1761.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 11 Jun 2012 11:01:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Client can not connect to the server(may be a bug) on Thu, 21 Jun 2012 19:17:33 GMT]]></title><description><![CDATA[<p dir="auto">Hi!</p>
<p dir="auto">I have found a system where I was able to reproduce this problem. And yes, it was solved by switching to non-blocking sockets for client connections. I made necessary changes in svn trunk, and version 1.2.2 will contain this fix. Changes are minimal - see diff below:</p>
<pre><code>Modified: trunk/src/server/core/client.cpp

===================================================================

--- trunk/src/server/core/client.cpp  2012-06-20 17:39:09 UTC (rev 6534)

+++ trunk/src/server/core/client.cpp  2012-06-20 20:25:43 UTC (rev 6535)

@@ -195,6 +195,7 @@

       }



       errorCount = 0;     // Reset consecutive errors counter

+              SetSocketNonBlocking(sockClient);



       // Create new session structure and threads

       pSession = new ClientSession(sockClient, (struct sockaddr *)&amp;servAddr);

@@ -287,6 +288,7 @@

       }



       errorCount = 0;     // Reset consecutive errors counter

+              SetSocketNonBlocking(sockClient);



       // Create new session structure and threads

       pSession = new ClientSession(sockClient, (struct sockaddr *)&amp;servAddr);



Modified: trunk/src/server/core/session.cpp

===================================================================

--- trunk/src/server/core/session.cpp 2012-06-20 17:39:09 UTC (rev 6534)

+++ trunk/src/server/core/session.cpp 2012-06-20 20:25:43 UTC (rev 6535)

@@ -393,7 +393,8 @@

    {

       if ((iErr = RecvNXCPMessageEx(m_hSocket, &amp;pRawMsg, m_pMsgBuffer, &amp;msgBufferSize,

                                             &amp;m_pCtx, (pDecryptionBuffer != NULL) ? &amp;pDecryptionBuffer : NULL,

-                                                                                           INFINITE, MAX_MSG_SIZE)) &lt;= 0) {

+                                                                                           900000, MAX_MSG_SIZE)) &lt;= 0)  // timeout 15 minutes

+              {

          DebugPrintf(5, _T("RecvNXCPMessageEx failed (%d)"), iErr);

          break;
</code></pre>
<p dir="auto">Best regards,<br />
Victor</p>
]]></description><link>https://forum.netxms.org/post/7711</link><guid isPermaLink="true">https://forum.netxms.org/post/7711</guid><dc:creator><![CDATA[victor]]></dc:creator><pubDate>Thu, 21 Jun 2012 19:17:33 GMT</pubDate></item><item><title><![CDATA[Reply to Client can not connect to the server(may be a bug) on Wed, 13 Jun 2012 06:49:45 GMT]]></title><description><![CDATA[<p dir="auto">After you fix the bus. I hope you can tell me how to fix it detailly in these post<br />
Thanks ;D</p>
]]></description><link>https://forum.netxms.org/post/7651</link><guid isPermaLink="true">https://forum.netxms.org/post/7651</guid><dc:creator><![CDATA[165432896]]></dc:creator><pubDate>Wed, 13 Jun 2012 06:49:45 GMT</pubDate></item><item><title><![CDATA[Reply to Client can not connect to the server(may be a bug) on Tue, 12 Jun 2012 20:10:03 GMT]]></title><description><![CDATA[<p dir="auto">Hi!</p>
<p dir="auto">Good catch, thanks for detailed debugging! I'll make a fix for that in a next few days.</p>
<p dir="auto">Best regards,<br />
Victor</p>
]]></description><link>https://forum.netxms.org/post/7644</link><guid isPermaLink="true">https://forum.netxms.org/post/7644</guid><dc:creator><![CDATA[victor]]></dc:creator><pubDate>Tue, 12 Jun 2012 20:10:03 GMT</pubDate></item></channel></rss>