meteor android app won't connect to server - javascript

I have a multiplayer bingo game which I made and im hosting it over Modulus. After uploading the project to Modulus and installing their MongoDB for my project, the multiplayer game works good over the browser, BUT, when I tried to meteor build the game and get the android .apk file to install over my Meizu device the installation got aborted and threw me a parse error so I decided to import the whole project to android studio and build the apk file from there. After installing the apk from Android Studio the application opens up, but it seems that it has no connection to the Modulus hosting server / Modulus db. Can anyone help and point me out my mistakes which I did? the build command was:
meteor build ../pathToBuild --server serverAdress
any help?

well I solved this by hard coding the server's path inside the code
var theURL = "http://myServer";
if (process.env.NODE_ENV === "development") {
// home
theURL = "http://myServer";
// office
//theURL = "http://192.168.10.30:3000";
}
Meteor.absoluteUrl.defaultOptions.rootUrl = theURL;
process.env.ROOT_URL = theURL;
process.env.MOBILE_ROOT_URL = theURL;
process.env.MOBILE_DDP_URL = theURL;
process.env.DDP_DEFAULT_CONNECTION_URL = theURL;
did the trick for me

This is generally to do with the way the server is started rather than the app, try specifying --mobile-server with the same address you use to build it when running the server you want to connect the app to:
meteor --mobile-server http:/app.server:port
If this works or if you don't run the app with the meteor command directly then you can set the DDP_DEFAULT_CONNECTION_URL environmental variable on the server directory you are running from to avoid having to specify it each time you run the app.
Alternatively I think if you upgrade to meteor 1.3 and rebuild/deploy then this bug should disappear.
More info on this thread although it's pretty long there are a few other things that can affect this in there but this method works for me for my cordova android app.

Related

NextJs | _ssgManifest.js, _buildManifest.js 404 and different name for file _app _#### on server build and browser

I have deployed a NextJs app on digitalocean droplet with Ubuntu 22.04.
"next": "12.2.3",
"react": "18.2.0",
I am getting this 404 error for _ssgManifest.js, _buildManifest.js and _next/static/chunks/pages/_app-83b8d0a73a58c453.js files.
enter image description here
I checked the build on server, files are present there, but in broweser they are showing 404. Another thing I noticed that the file _app-83b8d0a73a58c453.js getting fetched on browser but on server build it is with different name i.e. _app-8ba37a8edc5ef34c.js
What I Tried
I checked with and without custom dir for build, but it didn't worked
I checked with custom buildID too
const execSync = require("child_process").execSync;
const lastCommitCommand = "git rev-parse HEAD";
module.exports = {
async generateBuildId() {
return execSync(lastCommitCommand).toString().trim();
},
};
any help would be greatly appreciated
Solution:
These files were not matching to what is asked in browser request to what is available at build on server. In my case the reason was that, after build i was not restarting the application.
if you are using pm2 to serve your application named fe, please run:
pm2 restart fe
Then Hard refresh your website in browser, it will work.
If you are using other tool, then please follow docs for the same to restart the application. And if the issue is diffrent than this in your case, please share your solution here.
Thank you.

Move my MERN app (developped on windows) on a ubuntu machine and access it via LAN network

It's my first time here so please bear with me :)
Basically i developped a full stack MERN web application on my windows 10 machine (node js, express js and Mongodb in the backend + database and react js for the frontend), to run each one of them for now i use vscode (nodemon server for the backend and npm start for the front) all are running on my localhost on different ports.
what i need to do is to move that MERN app to an ubuntu machine and make it accessible via LAN network of that ubuntu continuously.
i guess i need to use git to move the app from windows to ubuntu? (correct me if i'm wrong) but how to make it run correctly there? and should i install a specific server to run it all on the LAN?
Thank you for the help in advance !

How to start big nodejs project virtual classroom?

Developers i'm a nodejs developer with a experience of 1.5 years working in the company my question is i'm doing a project which is called a virtual classroom like a webinar platform where chat support, drawing and etc functionalities are available, so from last 2 month had been done of working in project i had gone through the each component directory and file with it's documents also they have used of docker, redis, proxy server, nginx, session, mongodb these kind of services and it's working fine on server end side but can't able to stablish on my local machine and it's a linux based project where have numbers of powershell files with PM2 library to make it run... so i followed a docs with some code also i success to make the service on and registered a local domain also in hosts file or nginx custom configuration it is working fine... but when i hit my ulr on browser with the local domain it not going to any of the route....
Example - like if we make a node simple project with hello world and it will working on 4500 port so we write localhost:4500 and it will print our responce on browser
but if the run my project through a PM2 or a simple node app.js bcoz this app.js have connected with all nodes services and virtual classroom and you the linux platform we don't need to make serivice on it's by default in runing state monogoDB, redis, docker, nginx but the real question is while firing the command node app.js it shows some json and told port:2178 but when in hit this on browser localhost:2178 not responce to GET request why??? but there is route called localhost:2178/landing/session/v1/classid(which is encrypted code) this url not working what to do ??

ReactNative port 8081 issue : 403 Forbidden

While developing using ReactNative on Windows, I am getting below 403 error. This is because port 8081 which ReactNative uses by default is being used by another program. In my case it was McAfee (Thanks McAfee for making this harder).
Command to run the project : react-native run-android
I searched around a lot and finally figured out how to run this project on a different port. If you have any Antivirus software installed then it may help if you disable the firewall while developing or allow connections manually through settings.
Start ReactNative on a different port
react-native start --port 9080
This will open a new command prompt and start the metro bundler on port 9080 (you can use any other port you want). Wait for the dependency graph to be fully loaded.
Now in a different command prompt (project directory) use the below command to build and install the app on device
react-native run-android
Now once the app is loaded on device you will see the 403 error along with the red screen. To make the device communicate on a different port use below command.
adb reverse tcp:8081 tcp:9080
or if you have multiple device connected then provide the device id (e.g. FA6AA0301277)
adb -s FA6AA0301277 reverse tcp:8081 tcp:9080
To know the list of devices connected use below command
adb devices
That's it, now you should be able to see the index page :)
Happy Coding :)

Node.JS: Why is my connection to localhost:3000 refused?

I'm a student going into back-end development for the first time and are trying to learn Node.JS. I downloaded a pdf book about Node.JS from sitepoint called: "Jumpstart Node.JS". In following the instructions to set up the server on the command line, install the dependencies, and navigate to localhost:3000, i got nothing except the following message: "Connection refused: localhost:3000", Can somebody please tell me what might have went wrong and how to fix it?
Edit1:
The instructions i followed is about setting up a node.js server using the Node command line, thus no code, simply cmd commands, however, here is a quick summary of the process i followed:
Created an account on MongoLabs and then a database using the free pricing plan.
Installed express using the command: npm install -g express#.2.5.8.
Created an applications with default options using this command: express authentication.
modified the package.json file in system32
installed the dependencies by typing cd authentication, hitting enter, and then typing the command: npm install
Typed node app and hit enter.
According to the instructions i should have seen a message: "Welcome to express" but instead got the error message.
In following the instructions to set up the server on the command line, install the dependencies, and navigate to localhost:3000
It seems that you didn't start the server.
Somewhere between installing the dependencies and navigating to the URL you need to actually start the server if you want it to serve the request.
Check that there is no copy of the server running in the background, or that another app is using the port currently.
(Your firewall show allow you to see which app has been allocated to that port)
Because nodejs requires it to be the only app on that port running on your computer.
Also try a different port maybe?

Categories

Resources