cancel
Showing results for 
Search instead for 
Did you mean: 

Check if mobilink server is running

Former Member
4,710

Hello, I want to check if my Mobilink server is running from a C# application and notify the user if there is a problem and the server is down. Is there a way to do something like ping?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

This is how i did this. I used the PingOnly option in sync params.

try
        {
            ULCreateParms createParms = new ULCreateParms();
            createParms.CaseSensitive = true;
            createParms.UTF8Encoding = true;
            ULConnectionParms openParms = new ULConnectionParms();
            string appPath = System.IO.Path.GetDirectoryName(Application.ExecutablePath);
            string testPingDbFileName = System.IO.Path.Combine(appPath, "ping.udb");
            openParms.DatabaseOnDesktop = testPingDbFileName;

            if (System.IO.File.Exists(testPingDbFileName) == false)
            {
                iAnywhere.Data.UltraLite.ULDatabaseManager.CreateDatabase(
                openParms.ToString(),
                createParms.ToString()
              );
            }

            ULConnection cn = new ULConnection(openParms.ToString());

            cn.Open();
            cn.SyncParms.PingOnly = true;
            cn.SyncParms.UserName = "sa";
            cn.SyncParms.Stream = ULStreamType.HTTP;
            cn.SyncParms.StreamParms = string.Format("host={0};port={1}",mobilinkServer,mobilinkPort);
            cn.SyncParms.Version = mobilinkVersion;
            cn.Synchronize();
            object a = cn.SyncResult;
            cn.Close();
            isOnline = true;
        }
        catch (Exception ex)
        {
            isOnline = false;
        }

Answers (3)

Answers (3)

Former Member

Would the SQL Anywhere monitor be an option?

"The SQL Anywhere Monitor, also referred to as the Monitor, is a browser-based administration tool that provides you with information about the health and availability of SQL Anywhere databases (including databases in read-only scale-out and mirroring systems), MobiLink servers, MobiLink server farms, and Relay Server farms."

Former Member
0 Kudos

I want to implement it in my application, not to use any other monitoring tools. In a period of time to try to sync or to ping and see if there is connection to the server, if there is not a connection to show the user who is working a message.

jeff_albion
Advisor
Advisor
0 Kudos

In addition to Volker's comments, and you're using SQL Anywhere 12, you could also launch "mlreplay -ping seconds" from your application and check the return code for the utility:

  • -1 - Indicates that an error occurred.
  • 0 - Indicates that mlreplay was able to ping the server and the server is ready to receive synchronizations.
  • 1 - Indicates that mlreplay tried to ping the server but got no response; therefore, the server is not ready to receive synchronizations.

Another API alternative is to use the DBTools DBSynchronizeLog function, and pass in a "a_sync_db" structure with the "ping" struct member set to "TRUE". See: http://dcx.sybase.com/index.html#1201/en/mlclient/mc-dbtools.html.

VolkerBarth
Contributor
0 Kudos

I guess the ML client ping utility will do:

dbmlsync -pi -c connection_string ...


Apparently, the DbmlSync .NET API has an according method with a very different goal - see Reg's explanation:

DbmlsyncClient class Ping method

regdomaratzki
Product and Topic Expert
Product and Topic Expert

The Ping method in the dbmlsync client API (either the C++ or .NET implementation) is a ping of the dbmlsync process, and not the MobiLink Server.

If you are using a SQL Anywhere remote, then dbmlsync -pi is perfect, and if you are using UltraLite, setting the "ping" member of the synch info class you pass to the Synchronize function will perform a minimal connection to the MobiLink Server.