Cannot connect to 127.0.0.1 when offline using Windows Mobile 6.5 Professional emulator

Unanswered Cannot connect to 127.0.0.1 when offline using Windows Mobile 6.5 Professional emulator

  • 2012年2月16日 上午 07:57
     
      包含代碼

    I am trying to integrate a web application (that runs client-side javascript in a browser) with a native app on a Windows Mobile 6.5 Professional platform (Motorola MC9500). I'm developing with the emulator and with the MC9500 device. I'm using an intermediate compact PHP server (PocketHPH) which acts as a message relay between the javascript in the browser and the native app (not my app, so I can't touch its code).

    A requirement is that Opera Mobile browser must be able to connect to the local PHP server on the device when it is offline, i.e., no network connection. Use in the field will involve periods of no connectivity and the apps need to still work locally on the device during these periods.

    When there is network connectivity, the browser can connect to the local PHP server with HTTP requests, e.g., "http://127.0.0.1". This all works fine when the emulator or device is cradled and I have an internet connection through ActiveSync. However, if I uncradle the emulator or device, I can no longer connect to the server even though it's only a local connection (no internet required). If I browse directly to "http://127.0.0.1" while uncradled, I get the following error:

    Internet Explorer was unable to link to the Web page you requested.  The page might be temporarily unavailable.

    "http://localhost" doesn't work either when uncradled.

    I get the same results with both IE Mobile and Opera Mobile. I'm getting the same behavior on both the emulator and the actual device (Motorola MC9598 running Windows Mobile 6.5 Professional).

    It seems that I should be able to connect to a server on the same device even when I'm offline. Does any one know how to fix this?

    Thanks.


所有回覆

  • 2012年2月17日 上午 12:05
     
      包含代碼

    IE checks connection manager's status before attempting a connection. Since CM knows there is no external connection available, IE fails to open the page.

    You can attempt to tell connection manager to connect to 127.0.0.1 and see what happens.

      HRESULT hr = S_OK;
      GUID dest;
      CONNMGR_CONNECTIONINFO connInfo;
    
      hr = ConnMgrMapURL("127.0.0.1", &dest, NULL);
      if (SUCCEEDED(hr)) {
        memset(&connInfo, 0, sizeof( connInfo));
        connInfo.cbSize = sizeof( connInfo );
        connInfo.bDisabled = FALSE;
        connInfo.bExclusive = FALSE;
        connInfo.hWnd = g_hWnd;
        connInfo.guidDestNet = dest;
        connInfo.dwParams = CONNMGR_PARAM_GUIDDESTNET;
        connInfo.dwFlags = CONNMGR_FLAG_PROXY_HTTP;
        connInfo.dwPriority = CONNMGR_PRIORITY_USERINTERACTIVE;
        hr = ConnMgrEstablishConnection(&connInfo, &g_ConnHandle)
      }

    see: http://msdn.microsoft.com/en-us/magazine/dd263096.aspx

    -PaulH

  • 2012年2月17日 上午 01:52
     
     

    Thanks for the info. The pointer to the "How Connection Manager Connects" article was informative and led to my discovery of the default connection mappings for Windows Mobile 6.5: http://msdn.microsoft.com/en-us/library/bb737373.aspx

    Below are the default mappings shown on that page.  It looks to me like "http://127.0.0.1/" matches the first mapping which tells the CM to try the internet.  Bleh.  Now if I can figure out how to create a top priority mapping to a loopback interface instead.

    -----------

    The following table shows the default CM_Mappings Configuration Service Provider information that is loaded by default onto every Windows Mobile device for the four network types.

    Parameter pattern for the value Network name

    *://*.*/*

    The Internet

    *://*/*

    Work

    wsp://*/*

    WAP Network

    wsps://*/*

    Secure WAP Network


    Edward


  • 2012年2月27日 下午 11:39
     
     

    A Motorola support person gave me the following registry settings which fixed the problem for IE Mobile:

    [HKEY_LOCAL_MACHINE\Comm\ConnMgr\Providers\{EF097F4C-DC4B-4C98-8FF6-AEF805DC0E8E}\localhost-null]

    "DestId"="{E8E89F5A-D3BB-4C58-9B4E-08279D31044E}"

    "Type"=dword:00000000

    "Enable"=dword:00000001

    [HKEY_LOCAL_MACHINE\Security\Internet Explorer]

    "MSHTML"=dword:00000000

    However, I must use Opera Mobile 10 for this project (it implements needed JavaScript and canvas functionality).

    Does anyone know the corresponding registry setting for Opera Mobile 10?  Or can infer a fix for Opera given the above information?

    Thanks.


    Edward