Comments (4)
Thank you very much for your feedback. You did a really deep code analysis and found there are some problems.
if ($this->_handshakes[$connectionId]) {//если уже было получено рукопожатие от клиента
return;//то до отправки ответа от сервера читать здесь пока ничего не надо
}
This code is never executed because the $this->_handshakes[$connectionId]
contains an empty string ('') which evaluates to false not true. I will remove this code.
if (!$this->_handshake($connectionId)) {
$this->close($connectionId);
}
You made a mistake. This code close connection only if all headers received:
if (!strpos($this->_read[$connectionId], "\r\n\r\n")) {
return true;
}
if ($write) {
foreach ($write as $client) {
if (is_resource($client)) {//проверяем, что мы его ещё не закрыли во время чтения
$this->_sendBuffer($client);
if ($this->_handshakes[$client] == false) { $this->close($client); }
}
}
}
This code is not enough to send the data from the buffer to the client, you must also make sure that the data is completely gone, and the buffer is empty.
I will fix it in the next version.
- I will translate all comments to English :)
Thank you again for your review.
from websocket.
You were right, that empty string does evaluate to false :)
Also, keep in mind that until handshake is returned to client you would have to redirect normal messages to a separate buffer that gets written once the handshake is completed.
Otherwise the write buffer may contain a message before it contains the handshake reply.
This is why so many websocket classes maintain a client object to keep track of such things.
from websocket.
Daemon.php:
protected function sendToClient($connectionId, $data, $type = 'text') {
if (!isset($this->_handshakes[$connectionId])) {
$this->_write($connectionId, $this->_encode($data, $type));
}
}
until I do not finish a handshake with the client all messages ignored
from websocket.
Then it was a logic error on my behalf :)
I do apologize for that..
Latest websocket specs also no longer mentions http error codes so i guess all is good.
I am having some problems implementing status codes in the close frame as per the latest specs.
Is there any way i can contact you about this issue?
Perhaps we can work together towards a solution that will also work in your project..
You can send an email to the info@ the website address domain specified in my profile.
Thanks in advance!
from websocket.
Related Issues (20)
- Как подружить с pg_notify HOT 4
- GenericEvent считывает не весь буфер HOT 2
- список онлайн юзеров HOT 8
- Отправка изображения через вебсокет
- Работа в Safari HOT 1
- wss timeot HOT 17
- stream_select(): supplied argument is not a valid stream resource HOT 7
- Не закрывает соединение при окончании на сайте HOT 4
- Как сделать многопоточность? HOT 6
- request response order HOT 1
- Можно ли создавать комнаты? HOT 12
- PHP Client HOT 3
- Один конект по сокету на несколько вкладок HOT 2
- Потраченное время на разработку. HOT 4
- Не сбрасываются коннекты HOT 12
- "Залипает" при слишком длинном handshake-сообщение (режим event) HOT 4
- websocket lunch on remote host HOT 1
- Ошибка при остановке HOT 2
- Каково потребление памяти и cpu при нагрузке в 100 000 соединений? HOT 4
- Почему бросили? 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.