-
Notifications
You must be signed in to change notification settings - Fork 19
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
Allow MLLP connections to be proactively monitored with is_closed?/1
#65
Allow MLLP connections to be proactively monitored with is_closed?/1
#65
Conversation
Is it possible you're not using the latest version? We do provide auto-connect features. If the client is truly closing the connection, we would automatically re-connect by default.
There is a rub in here. Let's say you've sent a message, but you've gotten no response (seemingly), you now call I should also note there are two recent PR(s) (#63 and #64), both of which deal with edge / corner cases possibly related to your case. In a nutshell, sometimes it's best to assume you've entered a bad state and hang up the phone :)
It might be better to just put this on MLLP.Client vs on tcp / tls since we dynamically dispatch to the transport module anyway and they would both behave in the same way regardless. |
Unfortunately we're working with a connection peer that simply disappears rather than sending us a
The
Taking a closer look, it looks like this isn't actually the case, at least for sync sends (I could certainly be wrong/misunderstanding, so your review is much appreciated!). A given # lib/mllp/client.ex
def handle_call({:send, message, options}, _from, state) do
...
case state.tcp.send(state.socket, payload) do
:ok ->
# there's no opportunity to intercept bytes right here...
...
case recv_ack(state, timeout) do |
Right. That's expected, but wasn't following you. A fin is actually sent, but since we're not polling the socket (not in any active mode) we don't get a nice little tcp closed message from gen_tcp, it's instead on us.
Correct, 100%. You will not know until you try to send again. I suppose, this is somehow problematic for your case.
That is correct. I was thinking of an edge case, which is a moot point though, since we a) don't expose a I'm tracking what you're saying now though and sounds like you're trying to avoid some latency cost, which makes sense. I think I'm fine with adding this function, it probably should be moved to MLLP.Client though. A slight twist on this might simply be to do this check as part of the maintain reconnect timer polling. Then it would just do the "right thing", optimally the user doesn't need to check anything. However, that may be worth deferring, as we've just about implemented gen_tcp active behaviour at this point, which may be worth doing :) I'd like to hear @vikas15bhardwaj 's thoughts on this as well. |
Couple of points:
WDYT? |
Agreed
Agreed. |
4a8f8ee
to
20272ec
Compare
20272ec
to
1c2036c
Compare
@jgautsch, PR #68 might (at least partially) address the issue. The socket in |
@bokner Nice work! With bokner:active_socket, the client seems to more reliably detect a disconnect and reconnect now. I managed to get this warning if send message is attempted while connection to peer is active and the peer hangs / stops responding rather than disconnecting:
|
@jgautsch Thank you once again for opening this PR and bringing issues to our attention. I think you've found that Boris's refactor / rewrite of the client solves probably all your issues, thus I'm closing this in favor of #68 and let's take any remaining bits of the conversation there 😀 Thank you! ❤️🧡💛💚💙💜 |
Thanks Bryan and Boris! And thanks for open sourcing such an awesome
library!
…On Sat, Jul 15 2023 at 11:48 AM, Bryan Paxton ***@***.***> wrote:
Closed #65 <#65>.
—
Reply to this email directly, view it on GitHub
<#65 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AATKDJ3YQC7PND2IVLHVJLLXQLQWXANCNFSM6AAAAAAXES3KZM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
We have a simple service built around this library that translates HTTP API calls into MLLP messages.
On the receiving end of these messages, our peer sometimes hangs up. We want to reconnect as quickly as possible (and notify ourselves whenever the connection disconnects) instead of waiting until we attempt to send another message.
To do so, we need to introspect the status of a client connection. This PR adds a function to
Client
to do so.Requested points of feedback/review:
recv(socket, _length = 0, _timeout = 1)
appropriate? Does it create a possible race-condition whereby checking the status accidentally intercepts bytes from the socket that should be read elsewhere?is_closed?
function toMLLP.TLS
?cc @mfos239