Question

We have a solution running on WM 6.5 that connects to our servers but one of our customers has frequent problems where our software loses its gprs connection and is unable to get a new one until the phone is rebooted.

We know that the phone is in a gprs area as we are able to remote desktop into the phone and browse using internet explorer. Our logs show that although we have specified a 2 minute time out, ConnMgrEstablishConnectionSync returns with a waitingForConnection status. Does anybody have any ideas what could be going wrong? eg Is it possible that some 3rd party software is stealing our connection?

Many Thanks.

private void Connect()
    {
        if (_connectionHandle != IntPtr.Zero)
        {
            EventLog.AddLogEntry(LogSeverity.Trace, "connmgr - current handle was:" + _connectionHandle);
            CloseConnection();
        }

        const int connectionTimeout = 120000;

        const int CONNMGR_PARAM_GUIDDESTNET = 1;
        const int CONNMGR_PRIORITY_USERINTERACTIVE = 0x8000;
        const int CONNMGR_FLAG_SUSPEND_AWARE = 0x10; // suspended connections supported
        const int CONNMGR_FLAG_NO_ERROR_MSGS = 0x40; // don't show any error messages for failed connections
        const int CONNMGR_proxies = 0x3;
        const string testUrl = "http://www.bbc.co.uk";

        ConnectionInfo info = new ConnectionInfo();
        info.cbSize = (uint)Marshal.SizeOf(info);
        info.bExclusive = 0;
        info.dwFlags = CONNMGR_proxies | CONNMGR_FLAG_NO_ERROR_MSGS | CONNMGR_FLAG_SUSPEND_AWARE;
        info.dwPriority = CONNMGR_PRIORITY_USERINTERACTIVE;

        Guid networkGuid = Guid.Empty;
        int hResult = MobileNativeMethods.ConnMgrMapURL(testUrl, ref networkGuid, IntPtr.Zero);

        if (hResult != 0)
        {
            EventLog.AddLogEntry(LogSeverity.Trace, "<<Dllimport - ConnMgrMapURL (error) " + hResult.ToString());
            throw new ConnectionUnavailableException("Unable to open connection");
        }

        info.guidDestNet = networkGuid;
        info.dwParams = CONNMGR_PARAM_GUIDDESTNET;
        uint status = 0;
        hResult = MobileNativeMethods.ConnMgrEstablishConnectionSync(ref info, out _connectionHandle, (uint)connectionTimeout, out status);
        if (hResult != 0)
        {
            EventLog.AddLogEntry(LogSeverity.Trace, "<<Dllimport - ConnMgrEstablishConnectionSync (error) " + networkGuid.ToString());
            throw new ConnectionUnavailableException("Unable to open connection: " + (ConnectionStatus) status);
        }
        EventLog.AddLogEntry(LogSeverity.Trace, "<<Dllimport - ConnMgrMapURL Connection OK");
    }
Was it helpful?

Solution

In the end I found out that setting the AlwaysOn setting in the registry to false fixed the issue. I suspect that there is a deeper problem with Honeywell devices and this setting as Motorola devices seemed to work fine regardless of its value.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top