Appcenter-cli: Proxy support for codepush release

Created on 16 Oct 2019  路  9Comments  路  Source: microsoft/appcenter-cli

I'm not able to do a release when running behind an http proxy. Most simple appcenter queries will work fine, but when it comes to submitting a code release, this will fail.

When I run a similar command as below, it always fails.
appcenter codepush release -a appname -t 1.0.0 -d Staging -c ./platforms/android/app/src/main/assets/www --debug

The output ends with the following:

Uploading bundle...Response status code: 200
Body: {"id":"92131e27-9845-4acd-ad77-e1dadf7055a2","upload_domain":"https://file.appcenter.ms","token":"?sv=REDACTED"}
[14:31:03.495]: Setting state: New (0)
[14:31:03.498]: Upload Initialized
[14:31:03.502]: Setting metadata for AssetId: 92131e27-9845-4acd-ad77-e1dadf7055a2
[14:31:03.504]: File name: 6SF1iHNdwDGf63t.zip
[14:31:03.511]: File size: 2661583
[14:31:03.523]: CorrelationId: 92131e27-9845-4acd-ad77-e1dadf7055a2
in sendRequest

  • Uploading bundle...[14:31:03.704]: Set metadata failed: AssetId: 92131e27-9845-4acd-ad77-e1dadf7055a2, StatusCode: none, errorMessage: undefined
    [14:31:03.708]: Setting state: FatalError (500)
    Error: Error: The asset cannot be uploaded. Try creating a new one

I've traced this to appcenter-file-upload-client module which is using the superagent HTTP request library. However, there is no proxy support here. I found that if I manually include and configure the optional add-on superagent-proxy inside the request.js file, I can get this to work.

I couldn't find appcenter-file-upload-client in Github, but this should be a rather simple change. Right now, I don't see how this library can be used in a corporate/enterprise environment.

CodePush Enhancements

Most helpful comment

@ahbilal-ms

  1. This is a new app - no migration.
  2. This is my first time using this tool. If I drop off my corporate network, and goto my home wifi, everything works fine.

All 9 comments

@swbradsh Thanks for sending over the details. We are looking into it and will update you shortly. Thanks

@swbradsh We are still investigating the issue and have few questions for you:

  1. Are you migrating from HockeyApp?
  2. Was the command working before or this is the first time you are using this command? If it was working before, what tools/functions were you using before?

@ahbilal-ms

  1. This is a new app - no migration.
  2. This is my first time using this tool. If I drop off my corporate network, and goto my home wifi, everything works fine.

@swbradsh Thanks! It definitely seems to be an issue with the proxy, which we don't support at this time with our cli offering. Few of our customer have temporarily fixed this issue by enabling whitelist for the following addresses: https://intercom.help/appcenter/en/articles/1881230-urls-and-ip-addresses-to-whitelist-for-app-center

Also, I am working with the team to recommend a feature to fix this issue. I can't comment on the timeline but will come back to you with more updates. Thanks

If anyone wants a work-around for this issue, here is how i solved it.
Install superagent-proxy globally.
npm i -g superagent-proxy

Navigate to your installed appcenter-cli module and edit the request.js file. For me, I found the file here: C:\Users\xxxxxxx\AppData\Roaming\npm\node_modules\appcenter-cli\node_modules\appcenter-file-upload-client\dist\core\request.js

You're adding 2 lines to this file. See below.

....
var request = require("superagent");
require('superagent-proxy')(request);    <------- add this line
function sendRequest(requestOptions, log) {
    var abort = 0;    
    var req = request
        .post(requestOptions.url)
        .proxy(process.env.http_proxy)   <------ add this line
....

Make sure your http_proxy is set in your environment variable, and it should work now. Note, that if you update the appcenter-cli, you might have to make this change again.

My team has been using [email protected] and it has been working fine with our proxy settings. I'm not sure when this was broken.

I am not behind a proxy but still have the issue

how exactly to i set https_proxy?
I'm on MAC and edited the .bash_profile file by adding
export https_proxy=myProxy export http_proxy=myProxy

and now I'm getting failed with exception "Cannot read property 'toLowerCase' of null"

found a simple hack which works 90% of the times,
simply switch the network/wifi you're connected to and then run the command.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mirik999 picture mirik999  路  3Comments

danidev-tempus picture danidev-tempus  路  3Comments

grndvl1 picture grndvl1  路  4Comments

snap608 picture snap608  路  6Comments

ivanmoskalev picture ivanmoskalev  路  3Comments