New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
\Nats\Connection::handleMSG doesnt read trailing CR+LF #58
Comments
Amazing! 💪 |
Closing as it is solved on #59 |
Hmm I'm not entirely sure that my fix for So I guess that means the |
Ok, I'm reopening this issue and i will try to look further. |
As the documentation states, a MSG has a CR+LF after the payload:
MSG [reply-to] <#bytes>\r\n[payload]\r\n
The handleMSG method only reads the payload and leaves the trailing \r\n in the socket buffer.
I understand that this is not much of a problem, because Connection::wait just ignores such empty lines, but in my case this behaviour causes a big problem.
I'm using nats as a platform to deliver messages TO and FROM a websocket connection. This means i use stream_socket_select to listen for incoming websocket messages and concurrently for incoming nats messages by abusing streamSocket which i extracted out of the Connection class using Reflection since streamSocket is private.
Now the problem is, that since the newline is left in the buffer my stream_socket_select notices that a messages is waiting. Thus my call to wait(1) blocks indefinitely because it only reads those \r\n and waits for the message. This also means that my websocket connection is blocked.
So i would really appreciate it, if you could add something like
$this->receive(2);
in line 387 of \Nats\Connection to have correct protocol parsing.
Many thanks in advance!
The text was updated successfully, but these errors were encountered: