You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Users/kylecameronryanfahey/Documents/Github/serverSentiment/node_modules/express-ws/lib/index.js:69
request.ws = socket;
^
TypeError: Cannot set property 'ws' of undefined
at WebSocketServer.<anonymous> (/Users/kylecameronryanfahey/Documents/Github/serverSentiment/node_modules/express-ws/lib/index.js:69:16)
at emitTwo (events.js:106:13)
at WebSocketServer.emit (events.js:194:7)
at handleUpgrade (/Users/kylecameronryanfahey/Documents/Github/serverSentiment/node_modules/ws/lib/WebSocketServer.js:88:16)
at WebSocketServer.completeUpgrade (/Users/kylecameronryanfahey/Documents/Github/serverSentiment/node_modules/ws/lib/WebSocketServer.js:270:5)
at WebSocketServer.handleUpgrade (/Users/kylecameronryanfahey/Documents/Github/serverSentiment/node_modules/ws/lib/WebSocketServer.js:197:10)
at Server.WebSocketServer._ultron.on (/Users/kylecameronryanfahey/Documents/Github/serverSentiment/node_modules/ws/lib/WebSocketServer.js:87:14)
at emitThree (events.js:116:13)
at Server.emit (events.js:197:7)
at onParserExecuteCommon (_http_server.js:462:14)
at onParserExecute (_http_server.js:421:3)
Google doesn't turn up anything...
Bin:
(() => {
const APP = require('../app.js');
})();
app.js
'use strict';
var express = require('express');
var app = express();
var expressWs = require('express-ws')(app);
var port = 3000;
app.get('/', function(req, res) {
res.send('Congratulations, you sent a GET request!');
console.log('Received a GET request and sent a response');
});
app.listen(port, function() {
console.log('App now listening on port', port);
});
require('dotenv').config()
var Twit = require('twit')
var T = new Twit({
consumer_key: process.env.TWITTER_CONSUMER_KEY,
consumer_secret: process.env.TWITTER_CONSUMER_SECRET,
access_token: process.env.TWITTER_ACCESS_TOKEN,
access_token_secret: process.env.TWITTER_ACCESS_SECRET,
})
app.use(function (req, res, next) {
console.log('middleware');
req.testing = 'testing';
return next();
});
app.get('/', function(req, res, next){
console.log('get route', req.testing);
res.end();
});
app.ws('/', function(ws, req) {
ws.on('message', function(msg) {
console.log(msg);
});
console.log('socket', req.testing);
});
app.ws('/tweets', function(ws, req) {
ws.on('connect', function(req) {
console.log(req)
ws.send(req);
});
const stream = T.stream('statuses/filter', { track: ['POTUS', 'trump', 'president', 'realDonaldTrump'] })
stream.on('tweet', function(tweet){
console.log(tweet)
ws.send(tweet)
})
})
app.ws('/trump', function(ws, req) {
const stream = T.stream('statuses/user_timeline', { screen_name: ['POTUS', 'realDonaldTrump'] })
stream.on('tweet', function(tweet) {
console.log(tweet)
ws.send(tweet)
})
})
The text was updated successfully, but these errors were encountered:
Hello,
On connection I get
Google doesn't turn up anything...
Bin:
app.js
The text was updated successfully, but these errors were encountered: