internet-available | A module to verify if there 's an active internet | Runtime Evironment library
kandi X-RAY | internet-available Summary
kandi X-RAY | internet-available Summary
A module to verify if there's an active internet connection with Node.js
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Checks if the URL is available for a DNS address .
internet-available Key Features
internet-available Examples and Code Snippets
Community Discussions
Trending Discussions on internet-available
QUESTION
I have developed a scrapping tool, that scraps jobs from all websites and save them into the database. I have made my own default log where I get messages(errors, info) etc. I am using socket.io to update my view in real time and for database too.
The problem is when I start the app it perfectly get make socket, and database connections. But when I try to refresh the page, the same connection is made again twice with the same message and different ID's. As much I refresh the page the connections are made, and the id get changed, but for all made connection they use one ID,
Below is the Log which shows it :
I have uploaded this video, please check this as well. Try to watch the very beginning, and then at 01:41
and 03:06
, before starting scrapping of the first site the connection is established, but when second website scrapping is started, the Internet Connection
message is given twice, and the same stands for when third website scrapping is started, the number of messages get doubled every time. I don't know why.
I have tried following the answer of this question, but still no success. The code is 600+ lines on server
file, and 150+ lines second file and same on the client side, that's why I can't upload all and it's a bit confidential.
But the socket connection on the client and server is like this:
Server Side
...ANSWER
Answered 2018-Sep-05 at 09:03Getting multiple messages
Here are some thumb rules for socketio- if you listen to any event once, you'll get the message once in the callback
- if you listen to any event twice, you'll get the message twice in the callback
if you listen to any event nth time, you'll get the message nth in the callback
If you're listening to any event on page load, don't forget to
listen off
that event before you leave the page (if an event is not globally)- If you forgot to
listen off
and if you again re-visit page. you'll start listening to events multiple times. because on page load you're listening to the event. and the previous event is not yet stopped bylisten off
- If you forgot to
Don't listen to any event in
loop
, It may listen to it multiple time and you'll get multiple messages on a single change.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install internet-available
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page