microsoft / appcenter-cli

Command-line Interface (CLI) for Visual Studio App Center
https://appcenter.ms/
MIT License
582 stars 235 forks source link

Proxy support for codepush release #682

Closed swbradsh closed 1 year ago

swbradsh commented 5 years ago

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.

ahdbilal commented 5 years ago

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

ahdbilal commented 5 years ago

@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?
swbradsh commented 5 years ago

@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.
ahdbilal commented 5 years ago

@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

swbradsh commented 4 years ago

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.

michaelgmcd commented 4 years ago

My team has been using appcenter@1.1.19 and it has been working fine with our proxy settings. I'm not sure when this was broken.

aurelN commented 3 years ago

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"


UPDATE I managed to make it work by setting the proxy directly in the jenkins pipeline export http_proxy=myProxy export https_proxy=myProxy export NODE_EXTRA_CA_CERTS=myInternalCRTfile

harshlakhanpal commented 3 years ago

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

frank505 commented 3 years ago

it strange that @harshlakhanpal answer worked for me so strange

puneetkansal04 commented 3 years ago

Hey I am getting the same issue, Checked with changing and restarting network. Not able to get how to resolve in Mac. I was working fine before 1 week.

namlh19 commented 3 years ago

Hey I am getting the same issue, Checked with changing and restarting network. Not able to get how to resolve in Mac. I was working fine before 1 week.

It still work fine at noon. But now i get same issue with you.

aurelN commented 3 years ago

https://status.appcenter.ms/ image

heytulsiprasad commented 3 years ago

Woah is this a recurring issue? Happening for me too. Among the things I've tried are:

  1. npm install -g appcenter-cli@2.5.4 Link
  2. @swbradsh's comment on using superagent-proxy above
  3. Changing my network

I've been trying my way around this since past 2 hours, any help would be appreciated. 👍

Edit: This used to work at approx 10:50AM IST, but not happening lately.

puneetkansal04 commented 3 years ago

@aurelN Thanks may be I will work. Let's wait for sometime and then will try again if it will work.

@heytulsiprasad @namlh19 you can wait as @aurelN mentioned a updated may be it will resolve it. Update here once anybody get a solution.

aurelN commented 3 years ago

@puneetkansal04 Based on the info on the site you also need to update your local cli to the latest version in order to use the new endpoint. "Update - upload.appcenter.ms url has been discontinued - please use file.appcenter.ms instead.

Please update appcenter-cli, Jenkins and Fastlane plugins and App Center ADO Distribute task to the latest version if you have issues with distribution."

But first wait for the maintenance to finish.

dn32 commented 3 years ago

https://status.appcenter.ms/ imagem

This is the problem. Server down. Perhaps when Microsoft starts using AWS it will normalize its operations.

kyle-ssg commented 3 years ago

Yep, to further confirm the above we've been getting this using the latest CLI in CICD as of an hour ago (appcenter-cli@2.10.4).

tarikdem commented 3 years ago

The same issue happening in an Azure DevOps pipeline (macOS-11 with appcenter-cli@2.10.4) when running appcenter distribute release.

DmitriyKirakosyan commented 3 years ago

Hi guys, sorry for the inconvenience. This was caused by some planned work on the backend side. It should work now. Please let me know if someone still experiences this error.

Related issue: https://github.com/microsoft/appcenter-cli/issues/1723/

puneetkansal04 commented 3 years ago

ok now its working fine

On Tue, 9 Nov 2021 at 23:18, Dima @.***> wrote:

Hi guys, sorry for the inconvenience. This was caused by some planned work on the backend side. It should work now. Please let me know if someone still experiences this error.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/microsoft/appcenter-cli/issues/682#issuecomment-964388153, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALSCJCPXQMPXTNWA5CKKTUTULFNGHANCNFSM4JBNRM2A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

mrvincenzo commented 1 year ago

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.

For appcenter-file-upload-client@0.1.0, the change is in node_modules/appcenter-file-upload-client/dist/core/request.js

...
var request = require("superagent");
require('superagent-proxy')(request); // <-- CHANGE #1

function sendRequest(requestOptions, log) {
    var abort = 0;
    var req = request(requestOptions.method, requestOptions.url)
        .set('X-XblCorrelationId', requestOptions.correlationId)
        .set('MS-CV', requestOptions.correlationVector);

    if (process.env.http_proxy) { // <-- CHANGE #2
        req.proxy(process.env.http_proxy)
    }
    ...
}
DmitriyKirakosyan commented 1 year ago

I'm closing this issue. Please let me know if anyone is still facing it.

mrvincenzo commented 1 year ago

@DmitriyKirakosyan the issue is still reproducible. proxy settings are not honored by appcenter-file-upload-client@0.1.0 that is used by appcenter-cli when running appcenter codepush release

DmitriyKirakosyan commented 1 year ago

@mrvincenzo , I just tested uploading release with a proxy and it worked well for me.

Make sure you are using the latest appcenter-cli (2.14.0). The appcenter-file-upload-client-node current version is 1.2.11.

mrvincenzo commented 1 year ago

@DmitriyKirakosyan The code I referenced, appcenter codepush release, doesn't use appcenter-file-upload-client-node. Instead it uses appcenter-file-upload-client, version 0.1.0, which means that the problem is still there

DmitriyKirakosyan commented 12 months ago

@mrvincenzo , you are right. I'm sorry for the confusion. appcenter-file-upload-client doesn't support proxy at this moment.

mrvincenzo commented 12 months ago

@DmitriyKirakosyan ok, now that we are aligned, IMHO there 2 possible fixes

  1. Update appcenter-file-upload-client package to support proxy
  2. Patch appcenter-file-upload-client with patch-package in appcenter-cli

The fix is as simple as: https://github.com/microsoft/appcenter-cli/issues/682#issuecomment-1556180535

SolidTears commented 1 month ago

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

works like a charm lol