1

我们有一个在 WM 6.5 上运行的解决方案,它连接到我们的服务器,但我们的一位客户经常遇到问题,我们的软件失去了 gprs 连接,并且在手机重新启动之前无法获得新的连接。

我们知道手机位于 gprs 区域,因为我们能够远程桌面进入手机并使用 Internet Explorer 浏览。我们的日志显示,尽管我们指定了 2 分钟的超时时间,但 ConnMgrEstablishConnectionSync 以 waitingForConnection 状态返回。有人知道可能出了什么问题吗?例如,是否有可能某些 3rd 方软件正在窃取我们的连接?

非常感谢。

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");
    }
4

1 回答 1

1

最后我发现将注册表中的 AlwaysOn 设置设置为 false 解决了这个问题。我怀疑霍尼韦尔设备存在更深层次的问题,而摩托罗拉设备的这种设置似乎无论其价值如何都可以正常工作。

于 2014-06-17T12:18:43.140 回答