简体   繁体   中英

HMS AnalyticsKit Demo for Javascript cannot reach server

Here is what I did:

  1. Cloned HMS AnalyticsKit Demo for Javascript - https://github.com/HMS-Core/hms-analytics-demo-javascript.git in Germany Frankfurt AWS EC2
  2. cd hms-analytics-demo-javascript/hmsanalyticskitdemo/
  3. npm install
  4. npm run dev
  5. Use Chrome browser and visit http://xxxx:8080 (EC2), complete the quiz and post score
  6. Inspect Console - https://ibb.co/TKDm586 . There is no CORS or 401 error.

This is what I find in hms-analytics-demo-javascript/hmsanalyticskitdemo/src/main.js :

var agConnectConfig = 
{
    "agcgw":{
      "backurl": "https://lfagcgwtest01.hwcloudtest.cn:15602",
      "url": "https://lfagcgwtest01cn.hwcloudtest.cn:18062"
    },
    "client":{
        "cp_id":"4130086000000637176",
        "product_id":"258913027873047688",
        "client_id":"401147640282098944",
        "client_secret":"ABA91A52EF1FAB651F57AF091CEC149EECAFB01757DF1224FC384D2173828480",
        "app_id":"98751101985125555",
        "api_key":"CgB6e3x9zs8IL+Frjllsf9DoteK4Taz7jAseM9P+ikVZBJhHu87FpdEpqq0CimpayCrJgUrkUnV2RM86fyFiD4FE"
    },
    "service":{
        "analytics":{
            "collector_url":"habackup.hwcloudtest.cn:31405,datacollector-drcn.dt.dbankcloud.cn",
            "resource_id":"p1",
            "channel_id":""
        },
        "cloudstorage":{
            "storage_url":"https://agc-storage-drcn.platform.dbankcloud.cn"
        },
        "ml":{
            "mlservice_url":"ml-api-drcn.ai.dbankcloud.com,ml-api-drcn.ai.dbankcloud.cn"
        }
    },
    "region":"CN",
    "configuration_version":"1.0"
};

Then I change it to my own agconnect-services.json (note that I changed cp_id, product_id, client_id, client_secret, app_id, package_name, api_key. My data storage location is Germany):

var agConnectConfig =
{
    "agcgw":{
        "backurl":"connect-dre.dbankcloud.cn",
        "url":"connect-dre.hispace.hicloud.com"
    },
    "client":{
        "cp_id":"890001000000000000",
        "product_id":"736430070000000000",
        "client_id":"451560030000000000",
        "client_secret":"5950F0F77523D1C95914089A046DED446E09A02036D8AAAAAAAAAAAAAAAAAAAA",
        "app_id":"100000000",
        "package_name":"com.aaaa.aa.aaaaaaa",
        "api_key":"CgB6e3x9LNm1WQuE1uhjpEI6kdQD7xD23LfdkttRcakwi404NmcxlOBVUslatUnb5dJzXXXXXXXXXXXXXXXXXXXX"
    },
    "service":{
        "analytics":{
            "collector_url":"datacollector-dre.dt.hicloud.com,datacollector-dre.dt.dbankcloud.cn",
            "resource_id":"p1",
            "channel_id":""
        },
        "cloudstorage":{
            "storage_url":"https://ops-dre.agcstorage.link"
        },
        "ml":{
            "mlservice_url":"ml-api-dre.ai.dbankcloud.com,ml-api-dre.ai.dbankcloud.cn"
        }
    },
    "region":"DE",
    "configuration_version":"1.0"
}

I repeated step 5, I saw CORS errors - https://ibb.co/HHQvMVL

POST https://datacollector-dre.dt.hicloud.com/webv3.net::ERR_FAILED

If I turn on CORS plugin on Chrome, I saw 401 errors - https://ibb.co/9tXMrHS

POST https://datacollector-dre.dt.hicloud.com/webv3 401

I see no analytics in my app > analytics > real-time overview console.

Is there something wrong with my steps? Could this is be API/server issue?

Thanks.

Your integration procedures are correct. The problem is that the latest version of SDK should be integrated.

The earlier version of the JavaScript SDK has an authentication failure issue, which causes the fault to run the demo. You are advised to download the latest SDK 5.0.4.300 which rectified the authentication failure issue, and perform the verification.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM