-
-
Notifications
You must be signed in to change notification settings - Fork 233
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
Protocol decoder not always working with TCP proxy #364
Comments
@mcollina Any suggestion for this? |
I think this was solved in #334. Or maybe not, I do not have time to dig into this. Please send a PR if interested. |
@getlarge Could you create an example to reproduce this bug? |
Sure, but it's not so simple to reproduce. |
I think a docker compose would be fine :) |
Now i'm confused, i created a test repo for this case and it seems to work well. |
@getlarge Let me know |
@robertsLando So after some more tests, it seems the bug appears "randomly" ( because i don't understand why), that's why i didn't catch it yesterday. |
@getlarge In latest commit nextBatch call in client init has been removed. Coould you use the version from master to test this again? Just run |
I already use the github repo in |
@getlarge So you are not using npm install aedes (that installs latest npm version With |
Yes i cloned it from github to have the decodeProtocol hook. |
The fix has landed yesterday so if you are sure you are running it from the master now that is not the problem. Let's wait if @mcollina has any other suggestion |
In fact i'm going to rename the issue, since the problem occurs ( it seems less often ) when using a simple TCP connection ( with no SSL ). |
The only trick i found to avoid this issue, is to remove the else condition when no data has been extracted from the |
@getlarge When protocol decoder fails, what is the buffer received?
Here: https://github.com/moscajs/aedes/blob/master/lib/client.js#L74 ? |
In fact after some thoughts and tests, this seems fine to fix the issue var { data, isProxy } = client.broker.decodeProtocol(client, buf)
if (data) {
client._parser.parse(data)
} else if (!isProxy) {
client._parser.parse(buf)
} And i would like to suggest to change the condition above this block to Related to this, i'm currently trying to get a reliable source for the proxy server IP to achieve this #338 |
@gnought Thoughts on this? |
@getlarge Shouldn't also clients connected using websockets get them? |
@robertsLando Yes clients using websockets would, ( from socket._socket ) and if broker.trustProxy = true, they would get in priority information from headers set by the proxy server. |
Could it be a protocol or nginx related behaviour to firstly send a packet with empty data field? Should check specs about them to check if this is normal About Anyway this would add a little more complexity to packet parsing, maybe add an option to broker
I think most users doesn't mind to get connection details from their clients cc @mcollina |
It could be related to the specs, but then why this issue would appear randomly ? I tried to reproduce the NGINX proxy behaviour with 2 TCP servers to write a test ( one for the Aedes and one acting as a Proxy ) but the issue never seems to happen. |
@robertsLando following the change with protocolDecoder, you forgot to implement the condition changes that fixes this issue. |
Yes go for it!
Daniel
… On 6 Feb 2020, at 19:34, getlarge ***@***.***> wrote:
@robertsLando following the change with protocolDecoder, you forgot to implement the condition changes that fixes this issue.
Unless it was on purpose ?
Also we suggested that client.broker.trustProxy should not need be true to go through broker.protocolDecoder. Should i make a PR for this ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
@getlarge Any news? |
@robertsLando I saw the discussion on #365 and thought it might be smarter to wait until it goes into aedes to bring the change. |
If you want to join that discussion you are welcome, gnought made some changes in his “next” branch that requires some thoughts about protocol decoder.
Daniel
… On 11 Feb 2020, at 19:32, getlarge ***@***.***> wrote:
@robertsLando I saw the discussion on #365 and thought it might be smarter to wait until it goes into aedes to bring the change.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
@getlarge Could we close this now? |
yes |
There is still an issue in the the protocol decoder when Aedes broker is used behind a TCP proxy which handles SSL termination.
The packet is splitted in two, on one side the protocol proxy header and the TCP buffer on the other.
Any help to solve this would be appreciated.
Originally posted by @getlarge in https://github.com/moscajs/aedes/issues/338#issuecomment-577841457
The text was updated successfully, but these errors were encountered: