Comments (15)
Excuse me, but what did you do exactly?
from websocket.
Sample server:
date_default_timezone_set('UTC');
require_once "vendor/autoload.php";
if (!defined('HOA')) {
die("Failed start daemon: Hoa-socket lib not found");
}
// get unique client ID
function getClientId($bucket) {
return $bucket->getSource()->getConnection()->getCurrentNode()->getId();
}
// server run
$websocket = new Hoa\Websocket\Server(
new Hoa\Socket\Server('tcp://0.0.0.0:3333')
);
$websocket->on('open', function ( Hoa\Core\Event\Bucket $bucket ) {
echo 'new connection #', getClientId($bucket), "\n";
return;
});
$websocket->on('message', function ( Hoa\Core\Event\Bucket $bucket ) {
$data = $bucket->getData();
echo '> message ', $data['message'], "\n";
$bucket->getSource()->send($data['message']);
echo '< echo', "\n";
return;
});
$websocket->on('close', function ( Hoa\Core\Event\Bucket $bucket ) {
echo 'connection closed #', getClientId($bucket), "\n";
return;
});
$websocket->run();
Sample Client:
http://fulledu.ru/websocket/
<input type="text" id="input" placeholder="Message…" />
<hr />
<pre id="output"></pre>
<script>
function mySocketServer() {
var host = 'ws://fulledu.ru:3333';
var socket = null;
var input = document.getElementById('input');
var output = document.getElementById('output');
var print = function ( message ) {
var samp = document.createElement('samp');
samp.innerHTML = message + '\n';
output.appendChild(samp);
return;
};
input.addEventListener('keyup', function ( evt ) {
if(13 === evt.keyCode) {
var msg = input.value;
if(!msg)
return;
try {
socket.send(msg);
input.value = '';
input.focus();
}
catch ( e ) {
console.log(e);
}
return;
}
});
try {
socket = new WebSocket(host);
socket.onopen = function ( ) {
print('connection is opened');
input.focus();
return;
};
socket.onmessage = function ( msg ) {
print(msg.data);
return;
};
socket.onclose = function ( ) {
print('connection is closed');
setTimeout(function(){mySocketServer()}, 1000 * 2);
return;
};
}
catch ( e ) {
console.log(e);
}
}
mySocketServer();
</script>
Result screenshot with Internet Explorer:
http://static.fulledu.ru/example_bug.png
onClose event not work...
from websocket.
Which version of Internet Explorer are you using?
from websocket.
I assign @camael24 on this one. He will try to reproduce.
from websocket.
"Internet Explorer 11"
The same bug can be reproduced if connection is broken off by the third party.
For example:
- At the client the Internet was gone
- Connection with the client was broken off by nginx on timeout (if use nginx proxy for server)
or etc..
from websocket.
Is it the same issue you reported #31, #32 and #30?
from websocket.
Possibly it is other mistakes, for certain I can't tell.
from websocket.
I try to reproduce tomorrow :)
from websocket.
I confirm the "bug", i reproduce it on IE11
from websocket.
It is required that the event of onClose would work anyway if the client was disconnected from the server.
from websocket.
It's going to be difficult to debug, I don't have Windows. Any idea how could I do that?
from websocket.
With an VM ? and an demo key
from websocket.
https://www.modern.ie/fr-fr/virtualization-tools
from websocket.
Perfect! Thanks.
from websocket.
Here is what need to be considered.
IE sends an unsollicited PONG
frame. The RFC6455 says:
A Pong frame MAY be sent unsolicited. This serves as a
unidirectional heartbeat. A response to an unsolicited Pong frame is
not expected.
Several implementations out there (Play, Spring, Go etc.) encountered this issue because receiving an unsollicited PONG
was not expected and was creating a bug. In Hoa\Websocket
, this is not the case because we handle it as required by the RFC. IE has the fin
parameter set to 1, not 0, so this is a valid frame and we don't respond to it.
Since we don't respond, IE sends a random frame that is not a valid one. And yes, random, I don't receive the same frame twice.
After some searches, it seems that this is a known bug in IE10 (not 11). To fix that, we may return a PING
. This is what I did, but it does not fix anything. Maybe on IE10, but not on IE11.
Because the bug is still opened on IE10, we can assume this is still present in IE11.
I close this issue because I can't do anything to avoid that… The connection is closed by the server because of the malformed/invalid message we receive after the PONG
. IE does not fire the CloseEvent
properly despites the server sends a valid close frame!
Sorry for that. If you find a server that handles IE11 properly, I would be glad to know them and look inside the code to see what workaround they found.
from websocket.
Related Issues (20)
- Try to change the stream resource with an invalid one; given unknown type when trying to broadcastIf in on close. HOT 2
- Closing client from server closes other clients as well? HOT 8
- how can i get url query string value? HOT 2
- How can I do action every x seconds/ticks/whatever ? HOT 6
- Same connection used by two clients ?
- Close a given node by nodeId
- Always crash server when client disconnect.
- Dependabot can't resolve your PHP dependency files
- Dependabot can't resolve your PHP dependency files
- Operation timed out (nothing to accept)
- Cannot find how to send message to customized Node
- Dependabot can't resolve your PHP dependency files
- Dependabot can't resolve your PHP dependency files
- Connection is closed
- About audio streaming HOT 1
- Send message to a specific Client from another place than $server->on('message'..) HOT 4
- Vue and websocket HOT 3
- Data read from socket doesn't match expected length HOT 6
- Test failure HOT 1
- Bucket Send problem HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from websocket.