-
Notifications
You must be signed in to change notification settings - Fork 366
Problem with socket.emit from elephant that does not send properly #68
Comments
Is there any error ? On Friday, August 29, 2014, ToToSe notifications@github.com wrote:
|
No we've got 0 error. it allways show good EDIT : We used winston to try to find where the problem came from and when we send a socket, when it work it show this on nodeJs : 2014-08-29T16:55:34.958Z - info: SocketIO > Connected socket Zi6NAyAZGeO0aiLrAAAQ But when the socket doen't send it show this : As you can see, Elephant.io is able to connect to our server, but the socket doens't emit :/ |
@ToToSe I'm so sorry... I don't understand to your think. Did you send Did you show to debug message of |
Maybe the version about socket.io of nodejs would be 0.X. $socket = new Client(new Version0X('http://ourIpServer:8080'));
$socket->initialize();
$socket->emit('_ServerNewMsg', ['username' => $username,
'message' => $message,
'token' => 'xxx']);
$socket->close(); |
Still doens't work :/, and yes i send ['username' => $username, 'message' => $message, 'token' => 'xxx'] with Client::emit() function on elephant.io |
@ToToSe Can you show to me the source about socket.io of nodejs? If the version of socket.io was used 1.0.0 more, execute of console command like next. anonymous@localhost and |
Could you just paste here your node script that receives this event (just the The thing is, I also had this problem yesterday, but after a while, it seemed to work by itself when I did nothing, so I'm not sure if it is not a problem from socket.io or indeed one from Elephant. Marking this ticket as "support" until a bug is found, if there's one. |
Me too, some time does not send properly. $client = new \ElephantIO\Client(new \ElephantIO\Engine\SocketIO\Version1X('http://localhost:1337'));
$client->initialize();
$emit_result = $client->emit('broadcast', array('sayhi' => 'Hello Hi :: ' .date('Y-m-d H:i:s')));
$client->close();
Test by reload php page every second. Reload 10 times but data send about 6-9 times. |
|
So i'll test it with 2.0 and see if this is a problem of either the payload or something else |
It seems I can't make the legacy example work (an offset not set on the transport), but I think I could reproduce this, but I have no clue as to why it doesn't send all the messages. Sometimes I have all the messages sent, sometimes I don't (for 10 messages sent, I am receiving between 2 to 7 messages) ; even adding a small sleep time via a |
OK, back from some more tests ; It would seem that it indeed comes from a problem within Elephant 3, as the legacy seems to work pretty well. I also tried the I added in the Here is the gist that show how I debugged everything : https://gist.github.com/Taluu/21c30eedabc151d08fc0 @kbu1564 & @ve3 : could you try to add, just at the end of the |
Yes, it works very well. |
I recall we experienced this behavior in 2.x version, and we had to ensure transport went well by adding |
On my tests, it seems that 4ms is enough, but meh, I'll stick to the 100ms then (one never knows). I'm adding a config for that while I'm at it. |
Just as external point of view, it's strange to have to hack like that (sleeping a certain amount of ms). Do you know how the JS socket.io client is handling that behaviour ? |
It doesn't seem so (as far as I can decode node scripts...), but I also think that such a behaviour is strange indeed. But as I have nothing else, and this seems to work, it should work as a temporary patch until someone can gives us more insight on that. |
We might avoid this hack by implementing the callback return to acknowledge the message has successfully been sent before trying to send another one. No ? cc @Taluu |
It's looking like a best design fix this issue :) BTW, this may cause performance regressions... Maybe we could implement an "sending buffer" which is waiting acks of a certain number of messages, instead of just one? |
I tried to check if there was a return (by reading the socket), but it doesn't seem so, or it is gibberish.. Seems to be some leftovers from the socket. If you feel like finding a better solution, feel free to implement it ! Right now, this rudimentary patch should do the trick. |
OK I marked this ticket as fixed ; as I said, if there is a better solution, feel free to open a PR. |
x
The text was updated successfully, but these errors were encountered: