nodesocket / quote-stream Goto Github PK
View Code? Open in Web Editor NEWPush JSON stock quotes in real-time over websockets.
Home Page: https://nodesocket.github.com/quote-stream/
License: Apache License 2.0
Push JSON stock quotes in real-time over websockets.
Home Page: https://nodesocket.github.com/quote-stream/
License: Apache License 2.0
I am trying to run it on my local machine for a try-out. The code seems pretty straightforward, so I ran node server.js in command line. Then tried to access localhost:4000/ It returns "Cannot GET /" Am I trying it wrong?
For me, in Google Chrome at least, when I try to use the app the ticker var first gets set to AAPL, but then it gets set to favicon.ico. I would recommend changing '/:ticker' to something like '/symbol/:ticker' or using a traditional parameter like '?symbol=AAPL' and the code will work properly again.
working fine with less then 15 connection
after 15 connection server stop with error events.js on 141
var PORT = 4000;
var FETCH_INTERVAL = 300;
var PRETTY_PRINT_JSON = true;
///
// START OF APPLICATION
///
var express = require('express');
var http = require('http');
var io = require('socket.io');
var app = express();
var server = http.createServer(app);
var io = io.listen(server);
io.set('log level', 1);
server.listen(PORT);
app.get('/', function(req, res) {
res.sendfile(__dirname + '/index.html');
});
io.sockets.on('connection', function(socket) {
socket.on('ticker', function(ticker) {
track_ticker(socket, ticker);
});
});
function track_ticker(socket, ticker) {
//Run the first time immediately
get_quote(socket, ticker);
//Every N seconds
var timer = setInterval(function() {
get_quote(socket, ticker)
}, FETCH_INTERVAL);
socket.on('disconnect', function () {
clearInterval(timer);
});
}
function get_quote(p_socket, p_ticker) {
http.get({
//host: 'www.google.com',
host: 'localhost',
port: 80,
//path: '/webapp/info?client=ig&q=' + p_ticker
path: '/webapp/user/bhavjson.php?check=0&Ses_id=' + p_ticker
}, function(response) {
response.setEncoding('utf8');
var data = "";
response.on('data', function(chunk) {
data += chunk;
});
response.on('end', function() {
p_socket.emit('quote',data);
});
});
}
After about 2 min of connectivity to the server, the express app is dumped with this exception:
Error: connect ETIMEDOUT 172.217.6.4:443
at Object.exports._errnoException (util.js:837:11)
at exports._exceptionWithHostPort (util.js:860:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1060:14)
Do you think this could be Google dropping the connection?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.