Category : socket.io

I could connect with the socket with the below code. Laravel version ^7.29 It’s showing connected equal false. socket Socket {connected: false, disconnected: true} NOT WORKING CODE WITH 4.4.0 <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.4.0/socket.io.js"></script> <script> const socket_laravel = io(‘http://127.0.0.1:1234’); </script> WORKING CODE WITH 2.1.0 <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.1.0/socket.io.js"></script> <script> const socket_laravel = io(‘http://127.0.0.1:1234’); </script> Sourc..

Read more

i want to add a chat system for my site laravel, using socket.io, everything works fine, it just remains design,i need a professional design. $(function(){ let ip_adress = ‘127.0.0.1’; let socket_port = ‘3000’; let socket = io(ip_adress + ‘:’ + socket_port); let chatInput = $(‘#chatInput’); chatInput.keypress(function(e){ let message = $(this).html(); console.log(message); if(e.which === 13 && ..

Read more

Access to XMLHttpRequest at ‘http://dolphin.test:3001/socket.io/?EIO=4&transport=polling&t=Ni7Nzha’ from origin ‘http://dolphin.test’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. i try to connect socket.io in vuejs but code give me cors error Server side code :-> const express = require(‘express’); const app = express(); var https = require(‘https’); var http = ..

Read more

I created a broadcast channel on laravel. And I created a websocket server in which I subscribe to this channel. const http = require(‘http’).createServer(), io = require(‘socket.io’)(http, { cors: { origin: ‘http://localhost:8081’, }, }), redis = require(‘redis’), client = redis.createClient({ prefix: ‘laravel_database_’, }); //client.subscribe(‘laravel_database_messages-action’); client.subscribe(‘messages-action’); client.on(‘message’, function (channel, message) { console.log(‘message received: ‘ + message); ..

Read more

I am using vue.js(Laravel) to connect with my chat node server, its connect socket but emit not work with function. var socket = io.connect(‘http://localhost:3000/api/message’); socket.on(‘connect’, function () { var mapdata = {chatId: this.chatIdd, userId: this.userIdd} socket.emit("joinChat", JSON.stringify(mapdata) ,function(confirmation){ alert(‘Work’); console.log(confirmation); }); }.bind(this)); socket.on(‘msgReceive’, function () { }.bind(this)); alert(‘Work’) Not showing. How can i resolve this? ..

Read more