Search Posts

Category: socket.io

Socket.io produces random sockets for one session?

I’m trying to build a private messaging app using socket.io. My assumption was that per session there would only ever be one socket.id. If i keep track of my socket.id 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/socket.io/?EIO=3&transport=websocket&sid=E7Doi0kt1WqvOeT2AAAB’ 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 socket.io 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 socket.io.js 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 socket.io

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(‘socket.io’).listen(server1); socket module.exports.sockets = function(https){ io = socketio.listen(https); I tried this […]