Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client unable to fetch update on local machine hosted inside local network (linux server) #21

Closed
lfrallon opened this issue Oct 16, 2024 · 13 comments

Comments

@lfrallon
Copy link

Hi there,

I encountered an error when executing code-push-standalone release-react <app-name> android -d Staging --mandatory true --targetBinaryVersion "<app-version>".

This is the response of the code push server api:

Processing package: v6
Unknown error source
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string or an instance of Buffer or URL. Received undefined
    at Object.mkdirSync (node:fs:1384:10)
    at PackageDiffer.ensureWorkDirectoryExists (/root/code-push-server/api/bin/script/utils/package-diffing.js:297:20)
    at /root/code-push-server/api/bin/script/utils/package-diffing.js:228:27
    at promise (/root/code-push-server/api/node_modules/q/q.js:702:9)
    at PackageDiffer.downloadArchiveFromUrl (/root/code-push-server/api/bin/script/utils/package-diffing.js:227:16)
    at PackageDiffer.generateDiffPackageMap (/root/code-push-server/api/bin/script/utils/package-diffing.js:38:44)
    at processDiff (/root/code-push-server/api/bin/script/routes/management.js:1101:14)
    at /root/code-push-server/api/bin/script/routes/management.js:758:29
    at _fulfilled (/root/code-push-server/api/node_modules/q/q.js:854:54)
    at /root/code-push-server/api/node_modules/q/q.js:883:30

Though I can see the releases on the deployment history, react-native-code-push is unable to fetch the update.

Code Push client logs:

 LOG  [CodePush] Checking for update.
 LOG  [CodePush] Sync already in progress.
 LOG  [CodePush] Downloading package.
 LOG  [CodePush] An unknown error occurred.
 LOG  [CodePush] Failed to connect to /127.0.0.1:10000

Environment Setup

Using local development setup on linux machine (Ubuntu 24.04.1 LTS).

.env

EMULATED=true
AZURE_STORAGE_ACCOUNT=someValue
AZURE_STORAGE_ACCESS_KEY=someValue
SERVER_URL=http://192.168.8.111:3000
GITHUB_CLIENT_ID=someValue
GITHUB_CLIENT_SECRET=someValue
LOG_INVALID_JSON_REQUESTS=true
LOGGING=true

Azurite running on Docker container

docker run --restart always -d -it \
  --name codepush_azurite -v $HOME/data:/data \
  -p 10000:10000 -p 10001:10001 -p 10002:10002 \
  mcr.microsoft.com/azure-storage/azurite

Engine version

  • NodeJS (v18.20.4)
  • npm (10.7.0)
@lfrallon lfrallon changed the title Client unable to fetch update on local setup (linux server) Client unable to fetch update on local machine hosted inside local network (linux server) Oct 16, 2024
@azrulhaifan
Copy link

azrulhaifan commented Oct 16, 2024

@lfrallon seems like your problem is caused by azurite,
if you use emulated storage (azurite), the connection string to azurite is default to local machine, which is 127.0.0.1, and port 10000 is spesific to Azurite Blob Service.

When you test to download the code-push update from server, the server returning blob url with azurite host as is. And that's why your mobile device can't connect to 127.0.0.1 of your host machine.
The easiest way to make it work is to use azure blob storage. but if you want to try more deeper, take a look at my repository here

it just simple code-push-server fork, i'm just adding ENVIRONMENT var "AZURITE_CONNECTION_STRING" to customize azurite connection string

you just need to customize the host of azurite connection string (maybe use your local wifi address for your machine), and tune up your azurite setting if needed.
i hope it help

@lfrallon
Copy link
Author

@lfrallon seems like your problem is caused by azurite, if you use emulated storage (azurite), the connection string to azurite is default to local machine, which is 127.0.0.1, and port 10000 is spesific to Azurite Blob Service.

When you test to download the code-push update from server, the server returning blob url with azurite host as is. And that's why your mobile device can't connect to 127.0.0.1 of your host machine. The easiest way to make it work is to use azure blob storage. but if you want to try more deeper, take a look at my repository here

it just simple code-push-server fork, i'm just adding ENVIRONMENT var "AZURITE_CONNECTION_STRING" to customize azurite connection string

you just need to customize the host of azurite connection string (maybe use your local wifi address for your machine), and tune up your azurite setting if needed. i hope it help

@azrulhaifan that's also what I thought.

Thank you. I'll check it then and also currently looking for different solutions.

@alisyd
Copy link

alisyd commented Oct 23, 2024

@azrulhaifan

@lfrallon seems like your problem is caused by azurite, if you use emulated storage (azurite), the connection string to azurite is default to local machine, which is 127.0.0.1, and port 10000 is spesific to Azurite Blob Service.

When you test to download the code-push update from server, the server returning blob url with azurite host as is. And that's why your mobile device can't connect to 127.0.0.1 of your host machine. The easiest way to make it work is to use azure blob storage. but if you want to try more deeper, take a look at my repository here

it just simple code-push-server fork, i'm just adding ENVIRONMENT var "AZURITE_CONNECTION_STRING" to customize azurite connection string

you just need to customize the host of azurite connection string (maybe use your local wifi address for your machine), and tune up your azurite setting if needed. i hope it help

Hello, there! I am using your fork, but when I am trying to login, I am gettting the following error instead of the access key

Account not found.
Have you registered with the CLI?
If you are registered but your email address has changed, please contact us. 

in my browser, here is my .env file with AZURITE_CONNECTION_STRING

EMULATED=true
SERVER_URL=http://10.13.100.133:3000
AZURITE_CONNECTION_STRING="DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://10.13.100.133:10000/account1;QueueEndpoint=http://10.13.100.133:10001/devstoreaccount1;TableEndpoint=http://10.13.100.133:10002/devstoreaccount1;"

and how do we use the blob storage solution that you pointed out?
any help is very much appreciated

@lfrallon
Copy link
Author

@alisyd I think you need to register again like code-push-standalone register http://10.13.100.133:3000.

@azrulhaifan
Copy link

Account not found.
Have you registered with the CLI?
If you are registered but your email address has changed, please contact us.

try to re-register like what @lfrallon say, or logout than relogin. if you can't achieve it, try to remove your CLI profile manually.
it placed somewhere on your home directory with the name ".code-push.config" (on mac os), than try to relogin again. make sure you have setted up github oath variable.

and how do we use the blob storage solution that you pointed out?
any help is very much appreciated

if you setup a correct AZURITE_CONNECTION_STRING, than your codepush server will serve the blob url (for downloading code update) from it, you just need to make sure the azurite server are published & can be accessed via internet.

and take a look your connection string at :
BlobEndpoint=http://10.13.100.133:10000/account1

i think the correct string is :
BlobEndpoint=http://10.13.100.133:10000/devstoreaccount1

one simple way to make sure your azurite blob server are exposed to internet is by access your IP:PORT on browser, than it will show xml page

@alisyd
Copy link

alisyd commented Oct 24, 2024

Account not found.
Have you registered with the CLI?
If you are registered but your email address has changed, please contact us.

try to re-register like what @lfrallon say, or logout than relogin. if you can't achieve it, try to remove your CLI profile manually. it placed somewhere on your home directory with the name ".code-push.config" (on mac os), than try to relogin again. make sure you have setted up github oath variable.

and how do we use the blob storage solution that you pointed out?
any help is very much appreciated

if you setup a correct AZURITE_CONNECTION_STRING, than your codepush server will serve the blob url (for downloading code update) from it, you just need to make sure the azurite server are published & can be accessed via internet.

and take a look your connection string at : BlobEndpoint=http://10.13.100.133:10000/account1

i think the correct string is : BlobEndpoint=http://10.13.100.133:10000/devstoreaccount1

one simple way to make sure your azurite blob server are exposed to internet is by access your IP:PORT on browser, than it will show xml page

Yep that was it, Changed the connection string and things are working fine. Thanks for the help!

@puresprout
Copy link

Hello

@alisyd @azrulhaifan @lfrallon

What should I give to AccountKey in the url below?

DefaultEndpointsProtocol=http;AccountName=account1;AccountKey=base64key;BlobEndpoint=http://127.0.0.1:10000/account1;QueueEndpoint=http://127.0.0.1:10001/account1;TableEndpoint=http://127.0.0.1:10002/account1;

If the AccountKey is incorrect, the codepush server will throw the following error:

Unknown storage error.
Error: Server failed to authenticate the request. Make sure the value of the Authorization header is formed correctly including the signature.
RequestId:90e2171e-b288-4e91-8aae-413975826666
Time:2024-11-04T07:34:47.929Z

Thanks in advance.

@puresprout
Copy link

puresprout commented Nov 4, 2024

AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;
BlobEndpoint=http://MyIP:9000/devstoreaccount1

I changed the IP and port for queue and table and blob and accountKey,
and confirmed that it works normally until the update check.

However, It still see 127.0.0.1 like below when downloading. ㅜㅜ

 LOG  [CodePush] Sync already in progress.
 LOG  [CodePush] Checking for update.
 LOG  [CodePush] Awaiting user action.
 LOG  [CodePush] Downloading package.
 LOG  [CodePush] An unknown error occurred.
 LOG  [CodePush] Failed to connect to /127.0.0.1:10000

@alisyd @azrulhaifan @lfrallon

What could have gone wrong?

@alisyd
Copy link

alisyd commented Nov 4, 2024

AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==; BlobEndpoint=http://MyIP:9000/devstoreaccount1

I changed the IP and port for queue and table and blob and accountKey, and confirmed that it works normally until the update check.

However, It still see 127.0.0.1 like below when downloading. ㅜㅜ

 LOG  [CodePush] Sync already in progress.
 LOG  [CodePush] Checking for update.
 LOG  [CodePush] Awaiting user action.
 LOG  [CodePush] Downloading package.
 LOG  [CodePush] An unknown error occurred.
 LOG  [CodePush] Failed to connect to /127.0.0.1:10000

@alisyd @azrulhaifan @lfrallon

What could have gone wrong?

Using Azurite connection string in .env works with @azrulhaifan fork of code-push-server, if you are using the one from this repo, It would not work

@puresprout
Copy link

puresprout commented Nov 5, 2024

@alisyd @azrulhaifan

Hello,
Here's what I did:

I cloned this repository below.

https://github.com/azrulhaifan/code-push-server-freedom.git

.env

EMULATED=true
LOGGING=true
SERVER_URL={IP:8090}
GITHUB_CLIENT_ID={}
GITHUB_CLIENT_SECRET={}
AZURITE_CONNECTION_STRING="DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://{IP}:9000/devstoreaccount1;QueueEndpoint=http://{IP}:9001/devstoreaccount1;TableEndpoint=http://{IP}:9002/devstoreaccount1"

I gave it 0.0.0.0 to accept remote requests.

azurite --debug ./debug.log --blobHost 0.0.0.0 --blobPort 9000 --queueHost 0.0.0.0 --queuePort 9001 --tableHost 0.0.0.0 --tablePort 9002

# Even if I change 0.0.0.0 to {IP}, the result is still the same and it fails.
azurite --debug ./debug.log --blobHost {IP} --blobPort 9000 --queueHost {IP} --queuePort 9001 --tableHost {IP} --tablePort 9002

PORT=8090 npm run start:env

Checking for updates was successful, but downloading still fails with IP address 127.0.0.1.
At app

 LOG  [CodePush] Sync already in progress.
 LOG  [CodePush] Checking for update.
 LOG  [CodePush] Awaiting user action.
 LOG  [CodePush] Downloading package.
 LOG  [CodePush] An unknown error occurred.
 LOG  [CodePush] Failed to connect to /127.0.0.1:10000

@simonadenic
Copy link

@puresprout Did you resolve the issue with downloadUrl being directed to local (127.0.0.1)

@puresprout
Copy link

@simonadenic
Please refer to following

#34 (comment)

@shubhamkes
Copy link

shubhamkes commented Feb 6, 2025

@azrulhaifan thanks for the forked repo. Can we host the azurite server on a different machine? I am trying with your changes on azure-storage, and hosted azure on a different machine. I am able to get the xml response on curl request to this server as well.
but Codepush server is not able to communicate with azurite.

AZURITE_CONNECTION_STRING="DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://24.49.88.101:10000/devstoreaccount1;QueueEndpoint=http://24.49.88.101:10001/devstoreaccount1;TableEndpoint=http://24.49.88.101:10002/devstoreaccount1;"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants