ERROR in multi main Cannot GET /dist/bundle.js - node.js

i am new to react.js. i am getting this error on production but same code is working on development. can anybody help me.when i am running this code on development.everytime webpack built and generate a dist folder this folder have a bundle.js but webpack is not build on production
/home/ubuntu/.pm2/logs/server-out-0.log last 10 lines:
0|server | Version: webpack 1.13.2
0|server | Time: 566ms
0|server | Asset Size Chunks Chunk Names
0|server | bundle.js 1.52 kB 0 [emitted] main
0|server | chunk {0} bundle.js (main) 28 bytes [rendered]
0|server | [0] multi main 28 bytes {0} [built] [1 error]
0|server |
0|server | ERROR in multi main
0|server | Module not found:
Error:Cannot resolve 'file' or 'directory'
./client/index.html in /var/www/html/AR/server
0|server | # multi main
[STREAMING] Now streaming realtime logs for [all] processes
0|server | Error: Cannot GET /dist/bundle.js
0|server | at raiseUrlNotFoundError
(/var/www/html/AR/node_modules/loopback/server/middleware/url-not-
found.js:20:17)
0|server | at Layer.handle [as handle_request]
(/var/www/html/AR/node_modules/express/lib/router/layer.js:95:5)
0|server | at trim_prefix
(/var/www/html/AR/node_modules/express/lib/router/index.js:312:13)
0|server | at
/var/www/html/AR/node_modules/express/lib/router/index.js:280:7
0|server | at Function.process_params
(/var/www/html/AR/node_modules/express/lib/router/index.js:330:12)
0|server | at next
(/var/www/html/AR/node_modules/express/lib/router/index.js:271:10)
0|server | at SendStream.error
(/var/www/html/AR/node_modules/express/node_modules/serve-
static/index.js:121:7)
0|server | at emitOne (events.js:96:13)
0|server | at SendStream.emit (events.js:188:7)
0|server | at SendStream.error
(/var/www/html/AR/node_modules/express/node_modules/send/index.js:275:17)
Thanks,

Related

Not able to connect my service with Redis

My server is located on client premise.
I'm facing an issue, in that my service(node js) is not able to connect with redis.
If I'm checking the status of redis it's running fine.
Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2023-02-15 14:16:34 EAT; 18h ago
Docs: http://redis.io/documentation,
man:redis-server(1)
Main PID: 3085148 (redis-server)
Status: "Ready to accept connections"
Tasks: 5 (limit: 19104)
Memory: 8.2M
CGroup: /system.slice/redis-server.service
I'm able to connect with the service manually from one server providing host and port.
But the issue is when my service is trying to connect so it's failing.
So can anyone help me in suggesting what could be a possible reason for the same?
Error:
[ioredis] Unhandled error event: Error: connect ETIMEDOUT
16|pdsl_pa | at Socket.<anonymous> (/var/www/stage_env/pdsl_parking_service/node_modules/ioredis/built/redis/index.js:318:37)
16|pdsl_pa | at Object.onceWrapper (node:events:645:28)
16|pdsl_pa | at Socket.emit (node:events:526:28)
16|pdsl_pa | at Socket.emit (node:domain:475:12)
16|pdsl_pa | at Socket._onTimeout (node:net:501:8)
16|pdsl_pa | at listOnTimeout (node:internal/timers:559:17)
16|pdsl_pa | at processTimers (node:internal/timers:502:7)
16|pdsl_pa | [ioredis] Unhandled error event: Error: connect EHOSTUNREACH 172.**.***.***:6379
16|pdsl_pa | at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1157:16)
16|pdsl_pa | [ioredis] Unhandled error event: Error: connect EHOSTUNREACH 172.**.***.***:6379
16|pdsl_pa | at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1157:16)
16|pdsl_pa | [ioredis] Unhandled error event: Error: connect EHOSTUNREACH 172.**.***.***:6379

Why do I keep having to reboot my AWS ec2 instance

I have a nodejs app that I'm running on a ubuntu server on an ec2 instance. The code for the app is just this...
app.listen(port, () => {
HorseRacingAPI()
FootballAPI()
AmericanFootballAPI()
setInterval(() => {
HorseRacingAPI()
}, 1000 * 120)
setInterval(() => {
FootballAPI()
}, 1000 * 120)
setInterval(() => {
AmericanFootballAPI()
}, 1000 * 120)
})
Each of the 3 functions makes a request to an API, reorganises the returned data, and then sends the data to mongodb.
When I run this on my computer, it works great, sometimes a function may fail like 1% of the time, but it runs again 2 minutes later and works. However, when I run this on the ec2 instance, after a couple hours, the ec2 instance fails and won't run the nodejs app again until I reboot the instance and restart the pm2 server.
The pm2 logs look like this...
0|server | at Timeout.<anonymous> (/home/ubuntu/TPL-SCRAPI/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:197:23)
0|server | at listOnTimeout (internal/timers.js:557:17)
0|server | at processTimers (internal/timers.js:500:7)
0|server | MongooseError: Operation `oddsmatchers.updateMany()` buffering timed out after 10000ms
0|server | at Timeout.<anonymous> (/home/ubuntu/TPL-SCRAPI/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:197:23)
0|server | at listOnTimeout (internal/timers.js:557:17)
0|server | at processTimers (internal/timers.js:500:7)
0|server | MongooseError: Operation `oddsmatchers.updateMany()` buffering timed out after 10000ms
0|server | at Timeout.<anonymous> (/home/ubuntu/TPL-SCRAPI/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:197:23)
0|server | at listOnTimeout (internal/timers.js:557:17)
0|server | at processTimers (internal/timers.js:500:7)
0|server | MongooseError: Operation `oddsmatchers.updateMany()` buffering timed out after 10000ms
0|server | at Timeout.<anonymous> (/home/ubuntu/TPL-SCRAPI/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js:197:23)
0|server | at listOnTimeout (internal/timers.js:557:17)
0|server | at processTimers (internal/timers.js:500:7)
Is there anything I'm doing wrong? I need this code to run forever basically, so what do I need to do to make this happen with essentially 100% reliability?

MongoDB Error while running the project with pm2

I am trying to run my code using pm2 and I again and again get the below error. I have provided the complete credential details in mongouri which has the username password the cluster name and the table name, also I have whitelisted my ip and now I dont understand why is this error coming. Any help will be appreciated
3|USDT_CRE | 2020-01-07 06:44 +00:00: name: 'MongoNetworkError',
3|USDT_CRE | 2020-01-07 06:44 +00:00: [Symbol(mongoErrorContextSymbol)]: {} },
3|USDT_CRE | 2020-01-07 06:44 +00:00: [Symbol(mongoErrorContextSymbol)]: {} }
3|USDT_CRE | 2020-01-07 06:46 +00:00: { MongoTimeoutError: Server selection timed out after 30000 ms
3|USDT_CRE | 2020-01-07 06:46 +00:00: at Timeout.setTimeout [as _onTimeout] (/home/ubuntu/creatanium-wallet-blockchain/node_modules/mongodb/lib/core/sdam/server_selection.js:309:9)
3|USDT_CRE | 2020-01-07 06:46 +00:00: at ontimeout (timers.js:466:11)
3|USDT_CRE | 2020-01-07 06:46 +00:00: at tryOnTimeout (timers.js:304:5)
3|USDT_CRE | 2020-01-07 06:46 +00:00: at Timer.listOnTimeout (timers.js:267:5)
3|USDT_CRE | 2020-01-07 06:46 +00:00: name: 'MongoTimeoutError',
3|USDT_CRE | 2020-01-07 06:46 +00:00: reason:
3|USDT_CRE | 2020-01-07 06:46 +00:00: { Error: getaddrinfo ENOTFOUND cluster0-5etkj.mongodb.net cluster0-5etkj.mongodb.net:27017
3|USDT_CRE | 2020-01-07 06:46 +00:00: at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:26)
3|USDT_CRE | 2020-01-07 06:46 +00:00: name: 'MongoNetworkError',
3|USDT_CRE | 2020-01-07 06:46 +00:00: [Symbol(mongoErrorContextSymbol)]: {} },
3|USDT_CRE | 2020-01-07 06:46 +00:00: [Symbol(mongoErrorContextSymbol)]: {} }
Your connection URI is wrong. If you are using Mongo Atlas it cannot end with :27017.
Please log into your admin panel and click "connect" and "connect your application":
http://prntscr.com/ql150h
Copy a fresh string and paste it instead of what you have now inside your app:
http://prntscr.com/ql15cp
If this does not handle contact their assistance, they will help you sort this out.

MongoDB Connection with nodeJs through mongoose in docker-compose environment

I am facing weird issue while connecting MongoDB running in a separate container from my nodejs server container, it displays
the following error while trying to connect to MongoDB
{ MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017]
todo-node-server_1 | at Pool.<anonymous> (/usr/src/app/node_modules/mongodb-core/lib/topologies/server.js:503:11)
todo-node-server_1 | at emitOne (events.js:116:13)
todo-node-server_1 | at Pool.emit (events.js:211:7)
todo-node-server_1 | at Connection.<anonymous> (/usr/src/app/node_modules/mongodb-core/lib/connection/pool.js:326:12)
todo-node-server_1 | at Object.onceWrapper (events.js:317:30)
todo-node-server_1 | at emitTwo (events.js:126:13)
todo-node-server_1 | at Connection.emit (events.js:214:7)
todo-node-server_1 | at Socket.<anonymous> (/usr/src/app/node_modules/mongodb-core/lib/connection/connection.js:245:50)
todo-node-server_1 | at Object.onceWrapper (events.js:315:30)
todo-node-server_1 | at emitOne (events.js:116:13)
todo-node-server_1 | at Socket.emit (events.js:211:7)
todo-node-server_1 | at emitErrorNT (internal/streams/destroy.js:64:8)
todo-node-server_1 | at _combinedTickCallback (internal/process/next_tick.js:138:11)
todo-node-server_1 | at process._tickCallback (internal/process/next_tick.js:180:9)
todo-node-server_1 | name: 'MongoNetworkError',
todo-node-server_1 | message: 'failed to connect to server [localhost:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017]' }
which clearly states that connection refused. The code works absolutely fine when I run all services locally.
connection to MongoDB through mongoose in following manner
const options = {
autoIndex: true, // Don't build indexes
reconnectTries: Number.MAX_VALUE, // Never stop trying to reconnect
reconnectInterval: 500, // Reconnect every 500ms
poolSize: 10, // Maintain up to 10 socket connections
// If not connected, return errors immediately rather than waiting for reconnect
bufferMaxEntries: 0
};
console.log(options);
mongoose.connect('mongodb://localhost:27017/tododb',options).then(
() => { console.log("connected !!!"); },
err => { console.log(err); }
);
docker-compose.yaml
version : '3.3'
services:
mongo-database:
image: mongo
ports:
- "27017:27017"
todo-node-server:
build: server
ports:
- "3000:3000"
links:
- mongo-database
angular4-todoclient:
build: todo-app
ports:
- "4200:4200"
Complete Docker build logs
[~/dev/aguha/docker-compose] $ docker-compose up
dockercompose_mongo-database_1 is up-to-date
dockercompose_angular4-todoclient_1 is up-to-date
Starting dockercompose_todo-node-server_1 ...
Starting dockercompose_todo-node-server_1 ... done
Attaching to dockercompose_mongo-database_1, dockercompose_angular4-todoclient_1, dockercompose_todo-node-server_1
angular4-todoclient_1 |
angular4-todoclient_1 | > todo-app#0.0.0 start /usr/src/app
angular4-todoclient_1 | > ng serve
angular4-todoclient_1 |
angular4-todoclient_1 | ** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
mongo-database_1 | 2018-01-21T07:00:22.275+0000 I CONTROL [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=02d79173d565
mongo-database_1 | 2018-01-21T07:00:22.275+0000 I CONTROL [initandlisten] db version v3.6.2
mongo-database_1 | 2018-01-21T07:00:22.275+0000 I CONTROL [initandlisten] git version: 489d177dbd0f0420a8ca04d39fd78d0a2c539420
mongo-database_1 | 2018-01-21T07:00:22.275+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1t 3 May 2016
mongo-database_1 | 2018-01-21T07:00:22.275+0000 I CONTROL [initandlisten] allocator: tcmalloc
mongo-database_1 | 2018-01-21T07:00:22.275+0000 I CONTROL [initandlisten] modules: none
mongo-database_1 | 2018-01-21T07:00:22.275+0000 I CONTROL [initandlisten] build environment:
mongo-database_1 | 2018-01-21T07:00:22.275+0000 I CONTROL [initandlisten] distmod: debian81
mongo-database_1 | 2018-01-21T07:00:22.275+0000 I CONTROL [initandlisten] distarch: x86_64
mongo-database_1 | 2018-01-21T07:00:22.275+0000 I CONTROL [initandlisten] target_arch: x86_64
mongo-database_1 | 2018-01-21T07:00:22.275+0000 I CONTROL [initandlisten] options: { net: { bindIpAll: true } }
mongo-database_1 | 2018-01-21T07:00:22.276+0000 I STORAGE [initandlisten]
mongo-database_1 | 2018-01-21T07:00:22.276+0000 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
mongo-database_1 | 2018-01-21T07:00:22.276+0000 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
mongo-database_1 | 2018-01-21T07:00:22.276+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=487M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress),
mongo-database_1 | 2018-01-21T07:00:22.308+0000 I CONTROL [initandlisten]
mongo-database_1 | 2018-01-21T07:00:22.308+0000 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
mongo-database_1 | 2018-01-21T07:00:22.308+0000 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
mongo-database_1 | 2018-01-21T07:00:22.308+0000 I CONTROL [initandlisten]
mongo-database_1 | 2018-01-21T07:00:22.308+0000 I STORAGE [initandlisten] createCollection: admin.system.version with provided UUID: a336e5c8-1032-4095-8fc2-37de71d12006
mongo-database_1 | 2018-01-21T07:00:22.318+0000 I COMMAND [initandlisten] setting featureCompatibilityVersion to 3.6
mongo-database_1 | 2018-01-21T07:00:22.321+0000 I STORAGE [initandlisten] createCollection: local.startup_log with generated UUID: 5b3f3374-6f4e-4f63-aee1-4727eeb1c2e1
mongo-database_1 | 2018-01-21T07:00:22.328+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
mongo-database_1 | 2018-01-21T07:00:22.328+0000 I NETWORK [initandlisten] waiting for connections on port 27017
mongo-database_1 | 2018-01-21T07:00:22.898+0000 I NETWORK [listener] connection accepted from 172.18.0.1:57658 #1 (1 connection now open)
mongo-database_1 | 2018-01-21T07:00:28.682+0000 I NETWORK [conn1] end connection 172.18.0.1:57658 (0 connections now open)
todo-node-server_1 |
todo-node-server_1 | > server#0.0.0 start /usr/src/app
todo-node-server_1 | > node ./bin/www
todo-node-server_1 |
todo-node-server_1 | yes,connecting to db....
todo-node-server_1 | { autoIndex: true,
todo-node-server_1 | reconnectTries: 1.7976931348623157e+308,
todo-node-server_1 | reconnectInterval: 500,
todo-node-server_1 | poolSize: 10,
todo-node-server_1 | bufferMaxEntries: 0 }
todo-node-server_1 | done with tries
todo-node-server_1 | { MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017]
todo-node-server_1 | at Pool.<anonymous> (/usr/src/app/node_modules/mongodb-core/lib/topologies/server.js:503:11)
todo-node-server_1 | at emitOne (events.js:116:13)
todo-node-server_1 | at Pool.emit (events.js:211:7)
todo-node-server_1 | at Connection.<anonymous> (/usr/src/app/node_modules/mongodb-core/lib/connection/pool.js:326:12)
todo-node-server_1 | at Object.onceWrapper (events.js:317:30)
todo-node-server_1 | at emitTwo (events.js:126:13)
todo-node-server_1 | at Connection.emit (events.js:214:7)
todo-node-server_1 | at Socket.<anonymous> (/usr/src/app/node_modules/mongodb-core/lib/connection/connection.js:245:50)
todo-node-server_1 | at Object.onceWrapper (events.js:315:30)
todo-node-server_1 | at emitOne (events.js:116:13)
todo-node-server_1 | at Socket.emit (events.js:211:7)
todo-node-server_1 | at emitErrorNT (internal/streams/destroy.js:64:8)
todo-node-server_1 | at _combinedTickCallback (internal/process/next_tick.js:138:11)
todo-node-server_1 | at process._tickCallback (internal/process/next_tick.js:180:9)
todo-node-server_1 | name: 'MongoNetworkError',
todo-node-server_1 | message: 'failed to connect to server [localhost:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017]' }
angular4-todoclient_1 | Date: 2018-01-21T07:00:35.368Z
angular4-todoclient_1 | Hash: 9bc58c25a75cb62a0c88
angular4-todoclient_1 | Time: 9909ms
angular4-todoclient_1 | chunk {inline} inline.bundle.js (inline) 5.79 kB [entry] [rendered]
angular4-todoclient_1 | chunk {main} main.bundle.js (main) 33.9 kB [initial] [rendered]
angular4-todoclient_1 | chunk {polyfills} polyfills.bundle.js (polyfills) 548 kB [initial] [rendered]
angular4-todoclient_1 | chunk {scripts} scripts.bundle.js (scripts) 387 kB [initial] [rendered]
angular4-todoclient_1 | chunk {styles} styles.bundle.js (styles) 546 kB [initial] [rendered]
angular4-todoclient_1 | chunk {vendor} vendor.bundle.js (vendor) 11.1 MB [initial] [rendered]
angular4-todoclient_1 |
angular4-todoclient_1 | webpack: Compiled successfully.
mongo-database_1 | 2018-01-21T07:05:22.332+0000 I STORAGE [thread2] createCollection: config.system.sessions with generated UUID: 276d07dc-b507-4684-a3a6-75e560b44679
mongo-database_1 | 2018-01-21T07:05:22.347+0000 I INDEX [thread2] build index on: config.system.sessions properties: { v: 2, key: { lastUse: 1 }, name: "lsidTTLIndex", ns: "config.system.sessions", expireAfterSeconds: 1800 }
mongo-database_1 | 2018-01-21T07:05:22.347+0000 I INDEX [thread2] building index using bulk method; build may temporarily use up to 500 megabytes of RAM
mongo-database_1 | 2018-01-21T07:05:22.347+0000 I INDEX [thread2] build index done. scanned 0 total records. 0 secs
Please guide where exactly I am missing. Thanks in advance.
Change the connection string "localhost" to "mongo-database"
mongoose.connect('mongodb://mongo-database:27017/tododb',options)
when you use docker-compose it creates two containers so localhost for node is different from localhost to mongo.
run "docker container ls" this will give you the mongo container name use that in the connection string.

Kue connect Redis at AWS EC2 fail, show `Caught exception: AbortError`

I use docker to run redis on AWS EC2 and I use kue to connect to it at my node server.
But it shows error like below.
How could I fix this? I use redis-cli to ping to IP and GUI tool to connect redis are woring fine.
Caught exception: AbortError
11:05:00 0|server | at RedisClient.flush_and_error (/Users/Project/node_modules/kue/node_modules/redis/index.js:357:23)
11:05:00 0|server | at RedisClient.connection_gone (/Users/Project/node_modules/kue/node_modules/redis/index.js:659:14)
11:05:00 0|server | at Socket.<anonymous> (/Users/Project/node_modules/kue/node_modules/redis/index.js:293:14)
11:05:00 0|server | at Object.onceWrapper (events.js:293:19)
11:05:00 0|server | at emitNone (events.js:91:20)
11:05:00 0|server | at Socket.emit (events.js:188:7)
11:05:00 0|server | at endReadableNT (_stream_readable.js:974:12)
11:05:00 0|server | at _combinedTickCallback (internal/process/next_tick.js:80:11)
11:05:00 0|server | at process._tickDomainCallback (internal/process/next_tick.js:128:9)
11:05:00 0|server | code: 'UNCERTAIN_STATE',
11:05:00 0|server | command: 'BLPOP',
11:05:00 0|server | args: [ 'q:processSendEMail:jobs', 0 ] }

Resources