1
我们有WM 6.5连接到我们的服务器,但我们的一个客户有频繁的问题,在那里我们的软件失去了它的GPRS连接,无法得到一个新的,直到手机是运行的解决方案重新启动。ConnMgrEstablishConnectionSync经常失败,“WaitingForConnection”
我们知道手机位于gprs区域,因为我们可以将手机远程桌面连接到手机并使用Internet Explorer进行浏览。我们的日志显示,虽然我们指定了2分钟的超时时间,但ConnMgrEstablishConnectionSync会返回waitForConnection状态。有没有人有任何想法可能会出错?例如,某些第三方软件是否有可能窃取我们的连接?
很多谢谢。
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");
}
什么是ConnMgrProxy = 0x03,此常量值未在http://msdn.microsoft.com/en-us/library/bb840031.aspx上列出。由于通过ConnMgr建立的连接通常是共享的,您是否考虑过使用bExclusive?另一个问题是,如果用户试图手工使用所提供的连接设备上的连接会发生什么,这意味着:如果用户试图打开InternetExplorerMobile的网站,会怎样? - 如果电话在语音模式下使用,ConnMgr通常不能建立数据连接。 – josef
您好约瑟夫,在我的黑客中尝试解决我添加的问题,它是启用HTTP和WAP代理的合并。我有和没有它一样的问题。我没有尝试过独家,因为我们的软件保持长期连接,所以它会杀死其他应用程序。我想到其他一些应用程序可能会设置独占标志。有什么方法可以检查吗?用户已经报告说,他能够使用Internet Explorer,而我们的通讯科下降 –
所以,你的意思是另一个应用打开了独家连线?如果是这样,为什么用户使用现有的连接浏览互联网?可能你可以在开始你自己的connmgr连接之前尝试一个http请求。如果http请求失败(不应该发生这种情况,因为这会启动互联网连接),您可以启动connmgr连接请求。可能你的连接设置有错误。也许你会尝试使用MSDN connmgr C#示例http://msdn.microsoft.com/en-us/library/bb840031.aspx或OpenNetCF。我会寻找一个ConnMgr记录器。 – josef