I'm new on node.js and azure.
I want to develop a mobile app which insert and select data in a table.
For the android part - client side I use the code from here.
For the node.js part - server side I use the code from the same repository this code
When I deploy the node.js project on azure I give an error:
I have this message if a use any code for mobile node.js.
In Container diag, the problem is at PORT:
Check your Application Settings to make sure that the PORT setting of your container is correct. You can also view Application Logs to determine if there was a wrong PORT set.
In application logs the port is 8080:
ERROR - Container antaresmobilejs_0_7b069d42 for site antaresmobilejs
has exited, failing site start ERROR - Container
antaresmobilejs_0_7b069d42 didn't respond to HTTP pings on port: 8080,
failing site start. See container logs for debugging.
In my node.js code, I set the port to 8080, but I don't find the port settings in application settings.
Actually, the Node.js backend port for Azure Mobile Apps should be set as below if using Express.js.
app.listen(process.env.PORT || 3000);
It was introduced in the offical document How to use the Mobile Apps Node.js SDK, as the figure below.
It also be coded in the offcal sample code https://github.com/Azure/azure-mobile-apps-quickstarts/blob/master/backend/node/TodoSample/app.js#L35
The code process.env.PORT will read the default port specified by Azure from the environment, and the web.config file will help node backend app to start up by IIS.
The real port of API endpoint for client is 80, because the node app hosted in IIS.
Related
I have a Node.js server using socket.io to connect Android apps and I've been hosting it locally by just running it in my IDE and connecting to my local IPv4 address but I want it to work without me having to keep my PC running constantly so I've tried using Google Cloud and managed to get it mostly working but the client doesn't keep the connection and disconnects consistently.
I followed this tutorial up to step 4 after that I ran gcloud app deploy.
My Node.js server is in one file, it has these declarations at the top.
const express = require("express");
const app = express();
const http = require("http");
const server = http.createServer(app);
const { Server } = require("socket.io");
const io = new Server(server);
I then have this for the initial client connection.
io.on("connection", (socket) => {
console.log("User connected.");
Everything inside of this is just listeners for what gets emitted by the client so I don't think they're the problem.
And then outside of that I have
server.listen(8080, () => {
console.log("Server is listening");
});
I don't know if anything from the package.json file is relevant but I can provide it if need be.
After deploying to Google Cloud using the tutorial there are a few things in the logs that may be the reason behind the problem.
Waiting for network connection open. Subject:"app/invalid" Address:127.0.0.1:8080
Waiting for network connection open. Subject:"app/invalid" Address:127.0.0.1:8081
Wait successful. Subject:"app/invalid" Address:127.0.0.1:8080 Attempts:97 Elapsed:485.916418ms
App is listening on port 8080. We recommend your app listen on the port defined by the PORT environment variable to take advantage of an NGINX layer on port 8080.
These might have simple solutions but I have very little experience with server hosting.
Once my Android client connects to the server, the log outputs "User connected." as it should, then around 10 seconds later it does it again and this repeats. There's no error I can see between the connections just a few socket.io POST/GET requests.
I tried adding session affinity to the app.yaml but hasn't solved it either.
This is my app.yaml if any changes need to be made here
runtime: nodejs16
env: standard
instance_class: F1
automatic_scaling:
min_idle_instances: automatic
max_idle_instances: automatic
min_pending_latency: automatic
max_pending_latency: automatic
network:
session_affinity: true
Thanks for any help, if I need to provide any other files I can do so.
Socket communication requires persistent network connections. So, App Engine Flexible provides an option to keep the network connection alive.
I think you are deploying your app in App Engine Standard , which does not support this option.
So, you can deploy your app in App Engine Flexible and you need to include the following configuration in your app.yaml
network:
session_affinity: true
For refence on session affinity, please refer to this page https://cloud.google.com/appengine/docs/flexible/nodejs/using-websockets-and-session-affinity#session_affinity
So, your updated app.yaml can look like this
runtime: nodejs
env: flex
network:
session_affinity: true
Please refer to this page for supported yaml configuration for flexible environment - https://cloud.google.com/appengine/docs/flexible/nodejs/reference/app-yaml
Messages you have pasted are most likely not indicating a problem. Your application is running in a sandbox environment for which a container instance and a web server must be initialized the first time that your app engine service receives a request. This is also called Loading request and the messages you see indicate the startup of your container instance and your webserver.
You can take a look at Google's own documentation regarding handling requests in node.js or follow a quickstart guide.
If there are no other logs during the disconnection, I would suggest checking the quotas to see if you're not exceeding any.
I'm new to web-crawlers, trying to crawl ridership data of metro from the cellphone maps app(www.amap.com) with Fiddler, but I got this HTTP connect method, which is not viewable. There are icons of locks next to the URL and in 'Response' it says this:
'Encrypted HTTPS traffic flows through this CONNECT tunnel. HTTPS Decryption is enabled in Fiddler, so decrypted sessions running in this tunnel will be shown in the Web Sessions list.'
I found a solution suggesting that customizing rules in fiddler may help, so I followed and added this to its script:
if (oSession.oRequest[‘User- Agent’].IndexOf("Android") > -1 && oSession.HTTPMethodIs("connect")) {
oSession.oResponse.headers["Connection"]="Keep-Alive";
}
The changes to Fiddler Script
But of course, it didn't work, I've tried both iPhone and android and changed the header in the script respectively, none of them helped.
So is this app and HTTP connect method crawlable? The data is constructively helpful to my research, instead, it is not provided in website 'amap', so it has to be done through a cellphone.
If you have HTTPS decryption enabled in Fiddler but you see (mostly) only CONNECT requests this means that the apps on the device try to open a connection but do not trust the Fiddler root certificate.
If you try to use the apps on-device you will notice that there is currently no working network connection available (requests just don't work as the apps don't accept the server certificate created by Fiddler).
On Android devices since Andorid 6 you need root permissions to instal the Fiddler rot certificate or alternatively if you want to monitor a single app you can try to modify and re-sign the app. All details are described in this question and answer:
Some androids apps won't connect through fiddler
I'm trying to create a websocket connection to my Phoenix app from an Android client. I'm trying to use this library but I'm running into this issue and I'm unable to successfully join a channel.
Upon reviewing the source code of the above java phoenix client library, it looks like the initial request from the client to connect to the socket is made with http schema and not ws (the source code explicitly changes the provided url to make sure it always uses http). It's not clear to me how this would work without additional configuration in my Phoenix app: if a socket connect request is made to http://localhost:4000/socket, the request will fail because there is no route for /socket when the schema is http.
There's nothing in the library docs that says any additional config is required in my Phoenix app to make this work, but I don't see how it could work for the reason stated above.
Does a Phoenix app have built in handling for the connection upgrade, etc, required on handshake as specified here?
As a note, I have no issues making websocket connections from my javascript web client to my Phoenix backend.
Any suggestions are appreciated!
Have you tried using the default path for a channel http://localhost:4000/socket/websocket ?
I am developing an app in ionic and I can't connect to the socket server when running on a device.
I have managed to connect my app (port:8100) to a node server(port:9000) locally when developing (via ionic serve), I don have a cors issue, everything runs fine.
Client looks something like this :
socket = new io.connect('http://192.168.1.106:9000');
socket.on('reconnect_attempt',function() {
alert('crap');
});
P.S: the above code is from my own memory, but I know I have provided the ip and port
If the server is working or not I still get the alert...
I have also checked the manifest of the app and it has the appropriate permissions:
android.permission.INTERNET
I also added a js error handler to check if there is a js error:
window.onerror = function (errorMsg, url, lineNumber) {
alert(errorMsg);
}
var MyApp = angular.module('scotch-todo', ['ionic']);
...
I had a small error and fixed it (so the handler works) but now nothing is catched...
If I understand correctly, you can connect when developing on your PC, but now when testing on your physical device.
Since Cordova v4, they changed the default behavior so it won't connect to any address outside its own WebView pages. There exists a cordova whitelist plugin that lets you connect to a list of address in the whitelist
http://docs.ionic.io/docs/cordova-whitelist
i have an app(ruby on rails) running great on my desktop(localhost) which can recognize a request from a browser/mobile phone.Can i check it on my mobile phone too,without using android emulator.Just by hitting my ip will help me out????
rails s is by default binding to all interfaces on your desktop.
So if you know the IP address of your desktop (look it up in ifconfig) you can simply use that IP to access the Rails application.
eg: http://192.168.0.100:3000.
You then inspect the user-agent to find out it's a mobile phone or not.
The rails server can be started with the b flag which specifies the IP address you want to use:
rails s -b 0.0.0.0
deploy your app to heroku or AWS and use git to maintain your app code...Then you can connect to your phone using internet