Duplicate events
See original GitHub issueHere I create primitive example of server with socket.io with such stuff:
- socket.io > 0.9.9
├─┬ socket.io@0.9.9
│ ├── policyfile@0.0.4
│ ├─┬ redis@0.7.2
│ │ └── hiredis@0.1.14
│ └─┬ socket.io-client@0.9.9
│ ├─┬ active-x-obfuscator@0.0.1
│ │ └── zeparser@0.0.5
│ ├── uglify-js@1.2.5
│ ├─┬ ws@0.4.21
│ │ ├── commander@0.6.1
│ │ ├── options@0.0.3
│ │ └── tinycolor@0.0.1
│ └── xmlhttprequest@1.4.2
└──────────────────── ●
- node -v > v0.8.7
- https://github.com/Balloon/elephant.io
on x86_64 Linux:
Distributor ID: Ubuntu Description: Ubuntu 12.04.1 LTS Release: 12.04 Codename: precise Kernel: 3.2.0-29-generic GCC version: 4.6 (x86_64-linux-gnu)
var io = require('socket.io').listen(1717);
io.sockets.on('connection', function (socket) {
socket.on('ping', function (data){
console.log(data);
});
socket.on('message', function(data){
console.log(data);
});
});
And PHP-client like this:
#!/usr/bin/php -q
<?php
error_reporting(E_ALL);
require(dirname(__FILE__).'ElephantIO/Client.php');
$elephant = new ElephantIO\Client('http://localhost:1717');
$elephant->init(false);
$elephant->emit('ping', array('test' => 'Hello World!'), '');
// $elephant->send(ElephantIO\Client::TYPE_MESSAGE, null, null, 'Hello World!');
Here is the log of that server:
info - socket.io started
debug - client authorized
info - handshake authorized KAZbMECxcHQBIgTXynHr
debug - setting request GET /socket.io/1/websocket/KAZbMECxcHQBIgTXynHr
debug - set heartbeat interval for client KAZbMECxcHQBIgTXynHr
debug - client authorized for
debug - websocket writing 1::
debug - websocket received data packet 1:::
debug - websocket writing 1::
debug - websocket received data packet 3:::Hello World!
Hello World!
Hello World!
So, every time php-client sends one message or emits event, it’s duplicated on the server side 😦
Issue Analytics
- State:
- Created 11 years ago
- Comments:28
Top Results From Across the Web
If you have duplicate events on your iCloud Calendar
If you see duplicate calendars or events on your iPhone, iPad, iPod touch, Mac, or PC after you set up iCloud Calendar, follow...
Read more >Creating a Duplicate Event in Google Calendar - Dito
Creating duplicate events is easy … let's take a look at how to create these duplicate events below. After you have created the...
Read more >Handling duplicate events - IBM
One possible approach to block duplicate events is to use a string metric to retain the unique event identifiers of the events that...
Read more >Seeing duplicate events from Calendar Sync
Seeing duplicate events from Calendar Sync. Viewing both the source and target calendars at the same time can create the appearance of duplicates....
Read more >Duplicate Events in Google Analytics 4 and How to Fix them
Seeing duplicate events in Google Analytics 4? In this article, you will learn the most common reasons for this and how to fix...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Problem is about where you call you message event " socket.on(‘message’) " must not be inside connection scope in your client js file .
io.sockets.on('connection', function (socket) { });
–> This is out of the scope …
socket.on('message', function(data){ console.log(data); });
Just ran into this issue as well.
Originally, I was attaching listeners on the client like this:
But @EduardJS explains it very well:
My solution was to take the listeners out of the
connect
callback, and only leave my auth check (which I do want to run on every connection attempt):