-
Notifications
You must be signed in to change notification settings - Fork 94
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
Publish fails after AwaitConnection #247
Comments
Please try 0.21 (probably will not help but slight chance the pinger bug, that was fixed, is the issue). Otherwise, unfortunately, im going to need quite a bit more info (ideally code that replicates the issue, debug logs and broker logs). I understand this can be time consuming to pull together but its difficult to fix an issue I cannot replicate. |
Okay, I’ll try. But at the moment, the info that it should work is already very helpful to me, in the sense that my code snippet above does not lack e.g. a step between |
Your code is basically the same as this example (it runs So your code looks fine. If you are able to provide a reproducible example then I'll have a look (but please note that these issues can sometimes be difficult to replicate and may be broker dependent). |
I ran into something similar today. It ended up being caused by a framework canceling the Context I provided to NewConnection() -- worth checking for anyone else seeing similar behavior. |
As far as I’m concerned, this can be closed as I cannot reproduce it any more. I do see the error message if I have two programs running at the same time and using – erroneously – the same client ID. So maybe this was also the root cause of my original report. |
Are you able to provide these programs? Even if this only happens very occasionally, and in specific circumstances, I'd like to fix it (sounds like there may be a race condition). The issue with this kind of issue is that if you cannot duplicate them then they are hard to trace/fix. |
I put a mini project for reproducing the issue at https://gitlab.com/bronger/mqtt-test. |
Thanks very much for putting this demonstration together. In this case I believe the library is acting correctly; what appears to be happening is:
The simplest way to avoid this would be to use This is tangentially related to #249 (my comments on this PR anyway) in that the client attempts to reconnect immediately when dropped (so when using duplicate ID's the connect/drop/reconnect loop is very quick). |
I see the error also with Probably one should consider |
OK, I'll test this later in the week (that function should succeed regardless of the connection state; the message should go into the queue and be sent when possible). Currently there is no way to tell when the message has actually been sent (that's on the to-do list).
Well |
I have tested this with
This appeared to work successfully (no errors reported) - however note that the So apologies but I've been unable to duplicate the second part of this (using |
Okay, thank you for your investigations and explanations! With |
Does your code look similar to mine? I'm struggling to see how you could get the same error because |
Now revisiting it, I realise that the error is different. It is a WARN and not a panic any more. So everything is fine. |
I use the following code snipped to publish an MQTT message:
Then, I observe sometimes that
err
is “writev tcp 10.xxx.xxx.xxx:39508->192.168.xxx.xxx:1883: use of closed network connection”.I’m confused, and I am not sure whether this is a bug. FWIW, my expectation was that after
AwaitConnection
, the connection is usable. Of course, it can be simply the MQTT broker having an outage in the wrong moment, but two of my jobs died simultaneously with this error message, so I don’t think its due to bad timing.I use “github.com/eclipse/paho.golang v0.20.0”.
The text was updated successfully, but these errors were encountered: