Search Posts

Category: emit not working properly inside express route

I use in Node.js it’s working fine, but there is an issue in the routes files. Below is my code and flow. I have server.js file where I define io. var express = require(‘express’), app = express(), http = require(‘http’).Server(app); var io = require(‘’).listen(http); //io from server.js io.on(‘connection’, function (socket) { socket.emit(‘getDevicePostData’, { message : ‘Hi from server!!’ }); socket.on(‘sendDevicePostData’, function(“Hi from server”) {}); }); // pass io to routes file var smart_control = […]

socket io Connection closed before receiving a handshake

So I already tried to find the solution but can’t seem to find the right one. In this post. the solution was to find if your defining the socket-io twice. But i already checked my code app.js if i defined it twice and I didn’t. It’s working/detecting if a user connected but its throwing me an error. ERROR WebSocket connection to ‘ws://localhost:3000/’ failed: Connection closed before receiving a handshake response Here’s my code.. server-side /*jshint […] produces random sockets for one session?

I’m trying to build a private messaging app using My assumption was that per session there would only ever be one If i keep track of my and console.log it, it’s constantly chnaging and I dont know why. Here a snippet if how I am saving a new user. //Listen on the connection for incoming sockets io.on(‘connection’,function (socket) { //Add the users to the socket session socket.on(“add-user”, function(username){ oCurrentUser = { username: […]

gulpfile network issue during WebSocket handshake: Unexpected response code: 400 @ browser-sync

Facing below error while requesting .net web API post request with localhost in angular, same code is working fine with other machine at my home with different network :- WebSocket connection to ‘ws://localhost:3000/browser-sync/’ failed: Error during WebSocket handshake: Unexpected response code: 400 n.doOpen @ browser-sync-client.js?v=2.18.1:2 // Task to run build server for testing final app gulp.task(‘build:serve’, function () { browserSync({ server: { baseDir: “./build/” } })}) Source: AngularJS

Realtime notification implementation in Laravel

I am developing an ERP using Laravel and Angulajrs, Now I want to implement real time notification in my application like facebook live notification, I have done bit research and I found is using to implement this, how can I use this in my laravel application? Or is there any other good approach to implement this? I am using windows for development and hosting in ubuntu. Please help to me reach in a good […]

Use socket in nodejs and angularjs

I am new in socket.I have problem while using socket in my existing project.I have include file in my project and also create factory for using the socket. socket Request is going successfully from angular side. I want to do when something is changed in my API response it automatically calls and show result in my page.So here is my code.I dont know how can i achieve this with socket app.get(‘/ttms/getAlertsMessage/:customerid/:timstmp’, getCookies, ttms.getAlertsMessage);// route […]

App with the counter of clicks displayed in real time using Socket.IO

Imagine that I have an app that only shows the button and the user is able to click on this button. Below the button there is a counter of clicks. It will display a sum of all clicks from all user. The idea is similar to the cookie clicker game, but I would like to make this like a multiplayer game. Is this possible to see this counter in real time in app ? I […]

populate and refresh html table using

I am making an application on using Node.js and angular as fronthand. There I am getting one text file which is log information of users and continously growing. The data is as below, 13:24:24:007,Peter,male,3720,yes 13:24:24:007,John,male,1520,yes 13:24:24:023,John,male,9720,yes 13:24:24:023,Mario,male,9820,no 13:24:24:023,Katy,female,4320,no 13:24:24:038,John,male,3620,no ….. ….. I want to show the aggregate report data in table format to the client html page for dashboard kind of thing as below. username firstlogin lastglogin minamount maxamount Peter 13:24:24:007 13:24:24:007 3720 3720 John […]

Failed to connect socket using https in nodejs

While developing a chat application using nodejs,angular i am trying to connect with socket with the help of namespace using http , it was perfectly working.While i am running the same application with https, it was not connecting to socket code. server require(‘./libs/socketioCode.js’).sockets(https); var options = { key: fs.readFileSync(‘privkey.pem’), cert: fs.readFileSync(‘cert.pem’) }; var server = http.createServer(app).listen(3000); var server1 = https.createServer(options, app).listen(3443); var io = require(‘’).listen(server1); socket module.exports.sockets = function(https){ io = socketio.listen(https); I tried this […]

Next Page »