on 2012 Apr 17 10:38 AM
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?
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; }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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."
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
User | Count |
---|---|
71 | |
11 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.